java.lang.ClassFormatError

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.............................
pouliAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
girionisConnect With a Mentor Commented:
 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
 
pouliAuthor Commented:
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
 
pouliAuthor Commented:
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
girionisCommented:
 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
 
pouliAuthor Commented:
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
 
pouliAuthor Commented:
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
 
girionisCommented:
 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
 
pouliAuthor Commented:
I think now I can give the points with honour :)
0
 
girionisCommented:
 Thank you :-) I am glad I helped.
0
 
pouliAuthor Commented:
Could you please have a look at another question ?
title:

Running RMI out of the Localhost
0
All Courses

From novice to tech pro — start learning today.