Solved

java.lang.ClassFormatError

Posted on 2002-07-09
10
1,927 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
  • 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
 

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now