Solved

java.lang.ClassFormatError

Posted on 2002-07-09
10
1,947 Views
Last Modified: 2007-11-27
Anybody has any idea why I take this error ?

Ussualy I know from experience that it simply needs to erase all classes and recompile, but it doesn't seem to work in this case.

I use RMI as well, maybe this has a connection.

The error i being printed indefinetely until I stop the application.

It starts like that:

java.lang.ClassFormatError: Unknown constant tag in .class file
     at javax.swing.JComponent.getComponentGraphics(JComponent.java:489)
     at javax.swing.JComponent.paint(JComponent.java:756)
     at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21)
     at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
     at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)
     at java.awt.Container.paint(Container.java:1268)
     at sun.awt.RepaintArea.paint(RepaintArea.java:180)
     at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:260)
     at java.awt.Component.dispatchEventImpl(Component.java:3586)
     at java.awt.Container.dispatchEventImpl(Container.java:1582)
     at java.awt.Window.dispatchEventImpl(Window.java:1581)
     at java.awt.Component.dispatchEvent(Component.java:3367)
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:445)
     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:191)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:144)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)
     at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)
java.lang.ClassFormatError: Unknown constant tag in .class file
     at javax.swing.JComponent.shouldDebugGraphics(JComponent.java:1637)
     at javax.swing.JComponent.getGraphics(JComponent.java:1574)
     at javax.swing.JComponent._paintImmediately(JComponent.java:4616)
     at javax.swing.JComponent.paintImmediately(JComponent.java:4464)
     at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:404)
     at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
     at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:443)
     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:191)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:144)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)
     at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)
java.lang.ClassFormatError: Unknown constant tag in .class file
     at javax.swi.............................
0
Comment
Question by:pouli
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 

Author Comment

by:pouli
ID: 7142378
Here is a better printout and more up to date:
The error is raised when the client tried to lookup the server. Although I provide the class that describes the server's interface, seems like it cannot find it or it needs something else.

It raises an AccessControlException (nested) although I use a java.policy file that grants the permissions:

Interface exception: error unmarshalling return; nested exception is:
      java.lang.ClassNotFoundException: access to class loader denied
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
      java.lang.ClassNotFoundException: access to class loader denied
      at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
      at java.rmi.Naming.lookup(Naming.java:83)
      at com.TavliGame.Interface.Interface.<init>(Interface.java:217)
      at StartClient.<init>(StartClient.java:10)
      at StartClient.main(StartClient.java:31)
Caused by: java.lang.ClassNotFoundException: access to class loader denied
      at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:421)
      at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:159)
      at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:629)
      at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:257)
      at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:200)
      at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1503)
      at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1425)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1616)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1264)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:322)
      ... 5 more
Caused by: java.security.AccessControlException: access denied (java.io.FilePermission \c:\project\computer1\server\- read)
      at java.security.AccessControlContext.checkPermission(AccessControlContext.java:270)
      at java.security.AccessController.checkPermission(AccessController.java:401)
      at java.lang.SecurityManager.checkPermission(SecurityManager.java:542)
      at sun.rmi.server.LoaderHandler$Loader.checkPermissions(LoaderHandler.java:1128)
      at sun.rmi.server.LoaderHandler$Loader.access$000(LoaderHandler.java:1082)
      at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:385)
      ... 14 more
java.lang.ClassFormatError: Unknown constant tag in .class file
      at javax.swing.JComponent.getComponentGraphics(JComponent.java:489)
      at javax.swing.JComponent.paint(JComponent.java:756)
      at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21)
      at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
      at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)
      at java.awt.Container.paint(Container.java:1268)
      at sun.awt.RepaintArea.paint(RepaintArea.java:180)
      at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:260)
      at java.awt.Component.dispatchEventImpl(Component.java:3586)
      at java.awt.Container.dispatchEventImpl(Container.java:1582)
      at java.awt.Window.dispatchEventImpl(Window.java:1581)
      at java.awt.Component.dispatchEvent(Component.java:3367)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:445)
      at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:191)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:144)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)
java.lang.ClassFormatError: Unknown constant tag in .class file
      at javax.swing.JComponent.shouldDebugGraphics(JComponent.java:1637)
      at javax.swing.JComponent.getGraphics(JComponent.java:1574)
      at javax.swing.JComponent._paintImmediately(JComponent.java:4616)
      at javax.swing.JComponent.paintImmediately(JComponent.java:4464)
      at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:404)
      at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:443)
      at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:191)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:144)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)
java.lang.ClassFormatError: Unknown constant tag in .class file
      at javax.swing.JComponent.shouldDebugGraphics(JComponent.java:1637)
      at javax.swing.JComponent.getGraphics(JComponent.java:1574)
      at javax.swing.J
0
 

Author Comment

by:pouli
ID: 7142379
The server is at c:\project\computer1
The client_1 is at c:\project\computer2

The error message is raised by the client_1
0
 
LVL 35

Expert Comment

by:girionis
ID: 7142760
 Are you sure that your policy file is properly set up and allows access to desired classes? Are you also sure that these callses can be found by the class loader? I am not sure which one causes the exception first but if you have a correct policy file make sure that your class is compiled by a newer (or older) compiler. The ClassFormatError means that your class has been compiled by an older compiler (while you are using a newer VM) or by a newer one (and you are using an older VM).

  Hope it helps.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:pouli
ID: 7142963
Hi, girionis
Thank you for your comment

I have requested fromt he moderators to delete this question because I found the answer but you were quicker than them :)

I think that now is not possible to delete the question.

You have a point I forgot to update the policy file and I was looking in other places for the error.

I found very useful the following address as well that speaks about the codebase:
http://java.sun.com/j2se/1.3/docs/guide/rmi/codebase.html

I will give you the points but could you please answer a small and quick question because the 1 that you answered was already solved.

I have the server that extends the UnicastRemoteobject and the client.

When the client get the reference to the remote object it passes itself a reference of itslef as an attirbute to the calling method.

This makes the client server right ? With this logic in mind I extended the UnicastRemoteObject at the x_Impl class.

Although is working I am not sure if it needed.
What is your opinion ?
0
 
LVL 35

Accepted Solution

by:
girionis earned 100 total points
ID: 7143011
 With regards to the points. I do not mind if I do not receive them. If you have solved the question on your own there is no point to award these points to anyone, so a moderator can lock the question with no need to award these points to me :-).

  With regards to the UnicastRemoteObject. It is up to you how you can do it.

  You can extend the UnicastRemoteObject in your <classname>Impl class (which should be the implementation for the remote service) and have the server class (the one with the main method) to provide the essentials for hosting, or you can have both of them in your server class and make your server class extend the UnicastRemoteObject (by the way it is not necessary to extend the UnicastRemoteObject in order to make your server class available remotely).

  The client can also be a server. In some architectures, a server may need to make a remote call to a client. For instance if the server needs to warn the client for possible problems. In order to accomplish this, a client must also act as an RMI server. In these cases, a remote object can prepare itself for remote use by calling the static method from the UnicastRemoteObject:

UnicastRemoteObject.exportObject (<remote_object>)

  Hope it helps.
0
 

Author Comment

by:pouli
ID: 7143051
From waht you say I can infer that the UnicastRemoteObject is not essentil for remote objects.

If this is true then waht is the usefulness of this ?

Do I load my download time by extending the UnicastRemoteObject ? Probably not because the browser just looks the plg-in for these classes right ?
0
 
LVL 35

Expert Comment

by:girionis
ID: 7143107
 Yes this is right. It is not necessary to extend UnicastRemoteObject in order to make your remote object capable of receiving remote calls.

  UnicastRemoteObject supplies implementation of several of java.lang.Object's methods so that they are defined and implemented appropriately for remote objects. By not extending UnicastRemoteObject you would have to manually define and implement these methods to fit the needs of remote objects and your remote object implementation will have to explicitly call the exportObject method (see my previous comment when a client can act as a server as well) to indicate to the RMI runtime that there exists a remote object and that this object can accept remote incoming calls. So I guess at the end of the day it comes down to more additional (unecessary) work.

  You could also extend the java.rmi.activation.Activatable which is used to create remote objects that execute on demand. But you would still have to export the remote object by using either: UnicastRemoteObject.exportObject or Activatable.exportObject

  Hope it helps.
 
0
 

Author Comment

by:pouli
ID: 7143630
I think now I can give the points with honour :)
0
 
LVL 35

Expert Comment

by:girionis
ID: 7143685
 Thank you :-) I am glad I helped.
0
 

Author Comment

by:pouli
ID: 7144279
Could you please have a look at another question ?
title:

Running RMI out of the Localhost
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HashTable highest marks enumeration alternative 9 59
jsp login check 12 62
pagenation logic how it is working in my code 1 80
jboss 7.1 start up error 1 82
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question