Skip to main content

java.lang.IllegalAccessError for ...opt.Const

12 replies [Last post]
alexkos
Offline
Joined: 2008-02-21
Points: 0

I am using JAXB RI 20071219 with JDK 6. Everything seams to be working fine.

To test how Unmarshaller handles invalid data (schema is NOT set), I have modified the input XML and put text into an element for which float is expected.

The result is the following java.lang.IllegalAccessError (substituted MYCLASS and MYPROPERTY):

java.lang.IllegalAccessError: tried to access class com.sun.xml.bind.v2.runtime.reflect.opt.Const from class MYCLASS$JaxbAccessorM_getMYPROPERTY_setMYPROPERTY_float
at MYCLASS$JaxbAccessorM_getMYPROPERTY_setMYPROPERTY_float.set(MethodAccessor_Float.java:59)
at com.sun.xml.bind.v2.runtime.reflect.Accessor.receive(Accessor.java:171)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.endElement(UnmarshallingContext.java:486)
at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.endElement(SAXConnector.java:145)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:211)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:184)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:137)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:142)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:151)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:169)
at MYTESTMETHOD(XMLprocess.java:240)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

Now, why the code went to Const makes sense. There was a problem parsing a float (which by the way is gracefully reflected by ValidationEventCollector) and JAXB tries to consult Const to see what default value to set into my JavaBean.

Why IllegalAccess I don't know... probably something to do with ClassLoaders. I would really appreciate some expert advice (I've honestly googled myself to death - sorry if this is a known issue, I couldn't find it).

-Alex

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
drNeo
Offline
Joined: 2012-02-08
Points: 0

Customize your jars accordingly

bob8484
Offline
Joined: 2009-04-25
Points: 0

hey

i m facing same issue . What work around you did . I mean what exactly we can do if we have jboss server running application. Is it fine to modify jar directly and make members public or make anther jar and include it in class path web-inf/lib

alexkos
Offline
Joined: 2008-02-21
Points: 0

I entered issue 490 (https://jaxb.dev.java.net/issues/show_bug.cgi?id=490) in March, 08. No votes for it (perhaps because of the available workaround) or progress yet.

freightdawg
Offline
Joined: 2009-05-18
Points: 0

This issue bit me today on Weblogic 10.3 with JAXB 2.1.6. I cast my votes for fixing it. It's a shame that something so easy to fix has been sitting around for over a year.

edwardotis
Offline
Joined: 2004-09-08
Points: 0

Make that 2 years.

david_beutel
Offline
Joined: 2009-02-12
Points: 0

The 490 fix seems to solve this in JAXB/JAX-WS 2.2 (released) and JAXB 2.1.13 (not released), but I wonder when either will be updated in Java 6. (I also wonder what caused this bug in the first place.)

A work-around seems to be to provide a value for parameters of types that have primitive equivalents (e.g., Holder), so JAXB does not attempt to get the default value from Const.

pulkitsinghal
Offline
Joined: 2007-12-05
Points: 0

Hi David, that is a very interesting statement. Can you help me out? I want to look at the java 6 sdk on my machine and figure out exactly which jar has the JAXB/JAX-WS code so that i can then inspect the bundled version from its manifest file. Hopefully then I will know for sure if the bundled version is below 2.2 and that is why I too am seeing these errors. Also perhaps on any given application server, I can't count on the correct sun jdk to be used so it will help me go and inspect the jar on application servers as well.

Basically I just don't know where the classes for the JAXB/JAX-WS have been jar'ed and so I don't know where to look for the manifest file or the version info.

Your help would be much appreciated!

deetzen
Offline
Joined: 2008-06-05
Points: 0

I have the same issue currently on my system. Has this issue been successfully solved? I'm using Tomcat 5.5, JAX-WS 2.1.4 and JDK 6.

sauvage
Offline
Joined: 2004-03-04
Points: 0

same issue here

alexkos
Offline
Joined: 2008-02-21
Points: 0

I have managed to work around this problem by making Const class and its properties public and placing it (jar with the object file) in front of other jars on the class path.

I guess it makes sense since the code that accesses Const is no longer in the same package but rather instrumented (am I right here?) in my java bean, so that code can no longer legitimately access Const, which is package protected.

This now looks like a bug to me... Could some one from the RI development team please comment.

jitu
Offline
Joined: 2003-06-14
Points: 0

May be, you should file a bug on JAXB with a test case.

stasico
Offline
Joined: 2008-04-18
Points: 0

In my case the same problem happened under jdk1.5.0_13 for JAXWS2.1.3-20071218.
However JAXWS2.1.2.1-20071219 works good.