• Post Reply Bookmark Topic Watch Topic
  • New Topic

java.lang.IllegalAccessError when running code  RSS feed

 
Matthew Yeend
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm in the process of making an application in Java that loads and displays an X3D model, and I've downloaded all the correct jars and placed them in the project and I can see each of the classes that each of the jars contains. However, when I run my code in NetBeans, I get the following error:



The java code that I have for the project at time point is shown below:



As you can see from the error message that I'm receiving, I'm getting an exception that's java.lang.IllegalAccessError and I'm wondering how I'd go about fixing it. Thanks.
 
Les Morgan
Rancher
Posts: 768
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are missing this library: org.j3d.aviatrix3d
 
Matthew Yeend
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I already have that library in my project as you can see here
 
Matthew Yeend
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All the jars that I have in the project are listed as follows.

 
Les Morgan
Rancher
Posts: 768
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then the next place I would start to look is this, and in this order:
1 - corrupt library
2 - version issue (java version not supporting that library version)
3 - issue with the OS and Java version you are running with relation to your libraries
4 - an anomaly on my local machine (misconfiguration, library is in a corrupt drive space, etc...)

I have had these problems before, and when it isn't #1, then it usually comes down to an issue about support between softwares that reside locally.

Matthew Yeend wrote:All the jars that I have in the project are listed as follows.

 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
aviatrix3d-all
aviatrix3d-all_2.2.0

Is that two different versions of that jar file deployed there?
 
Matthew Yeend
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would I go about checking if there's a corrupt library within the project?

As you can see, there are two different variations of the same jars, the reason for this is because the older jars don't have some of the classes need and the new ones do, and vise versa
 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then you have an issue.
Your code isn't working precisely because there are two versions of jars.
It is picking the first copy of a class it encounters.
So if class A is picked from version 2 and has a dependency on class B, but that ends up picked from version 1, then they are quite likely not to function if there has been a change to B between version 1 and 2.
This looks like the issue you have here.

You need to figure out exactly what version is needed and use only that one, for each dependency.

Do these have any maven files associated with them? Is there a maven repo possibly?
 
Matthew Yeend
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just so I understand what I have to do, I have to look through each of the jars that I have two versions of and see which one I need? And I'm unsure on how to check if there's a Maven file associated with the jars
 
Matthew Yeend
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've just taken them out and when I have done and run it to see if it works, I carried on getting errors says that I needed the classes from the jars that I took out so I put them back in and took the others out and got the same errors.
 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without knowing what you've taken out and put back we can't say anything, I'm afraid.
Same with the errors.
 
Matthew Yeend
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I first took out the jars that are the old ones, the ones without the suffix, and tested it and I got errors saying that a class was missing, so I put them back and took the jars out that had the suffix like the aviatrix3d-all_2.2.0.jar and ran the code and got errors saying that a class was missing, so I put them back in and ran it and now I have the same error as the question says.
 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot have two version of the same jar file in your classpath at the same time.

So that needs fixing.

You need to figure out what version of xj3d you should be using and get hold of jar files for that version, and that version only.
 
Matthew Yeend
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand that. I've looked here and that's where I've found what jars I need and a few others given the output when I've ran the code. So should I only have the jars that are listed there and the others such as aviatrix3d-all_2.2.0? And should I move some of the classes round so they're all in the same jar?
 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the "Setting up the environment" section you need these jar files:
dis.jar
gnu-regexp-1.0.8.jar
httpclient.jar
j3d-org-images.jar
j3d-org.jar
uri.jar
vlc_uri.jar
xj3d-config.jar
xj3d-common.jar
xj3d-core.jar
xj3d-ecmascript.jar
xj3d-external-sai.jar
xj3d-java-sai.jar
xj3d-jaxp.jar
xj3d-net.jar
xj3d-norender.jar
xj3d-parser.jar
xj3d-render.jar
xj3d-runtime.jar
xj3d-sai.jar
xj3d-sav.jar
xj3d-script-base.jar
xj3d-xml-util.jar

Only one of each.
They are (according to that page) in the precompiled release.

After that you need a renderer, which is
either
java 3d, so you need that jar plus the xj3d-j3d.jar
or
OpenGL, for which you need JOGL and the following 3 jars:
xj3d-ogl.jar
aviatrix3d-all.jar
vecmath.jar - This is available from the Java3D project

You seem to have gone for both of those options at once.
 
Matthew Yeend
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you suggest having the jars that are listed in the 'Setting up the environment' section and having only one renderer? Sorry for the lateness of the reply
 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not suggesting it.
The XJ3D page is stating it, and I can only assume they understand their software.

They list the jar files they expect to be there.
 
Matthew Yeend
Ranch Hand
Posts: 111
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dave, thanks for the help. I've managed to get the application to work now
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!