users@jaxb.java.net

Re: java.lang.IllegalAccessError occured during JAXBContext.newInstance("package name");

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Thu, 4 Dec 2008 20:03:26 +0100

Of course, the class loader you get in the session bean context is the
restricted laoder. You have to use
  ClassLoader theOriginalLoader =
Thread.currentThread().getContextClassLoader();
at a time when the session bean is not yet active! Pass the saved original
class loader to your session bean and then call
   JAXBContext.newInstance("timeout.vo", passedInOriginalLoader )

-W



On Thu, Dec 4, 2008 at 2:40 AM, yankings <yankings_at_hotmail.com> wrote:

>
> Hi,
>
> Thanks for your reply, i try to change the statement as follow:
> JAXBContext context =
>
> JAXBContext.newInstance("timeout.vo",Thread.currentThread().getContextClassLoader());
>
> but the same exception throws :java.lang.IllegalAccessError: tried to
> access
> class javax.xml.bind.ContextFinder from class javax.xml.bind.JAXBContext
>
> I am using the jdeveloper 10.1.3.3 and the embedded server for
> development.
> I try to use the JAXB 1.0 embedded in the jdeveloper, it works fine. After
> import the 2.1.6 lib to the IDE, it can generate the related vo based on
> the
> xsd, but always fail in the above statment if i put it in the session bean.
>
>
>
>
> Wolfgang Laun-2 wrote:
> >
> > Call the JAXBContext.newInstance with an additional ClassLoader
> > argument, set to the initial ClassLoader you obtain by calling
> > Thread.getcurrentTrhead().getContextClassLoader().
> >
> > Session beans are loaded by a special class loader which does
> > not provide access to all the things in your initial class path.
> >
> > -W
> >
> >
> > On Wed, Dec 3, 2008 at 3:20 AM, yankings <yankings_at_hotmail.com> wrote:
> >
> >>
> >> Hi,
> >>
> >> i am try to perfrom marshalling by JAXB 2.1.6, the marshalling process
> is
> >> carried out inside a session bean, exception is throw when the system
> >> reached this statement JAXBContext context =
> >> JAXBContext.newInstance("package name");
> >>
> >> The exception message is :
> >> java.lang.IllegalAccessError: tried to access class
> >> javax.xml.bind.ContextFinder from class javax.xml.bind.JAXBContext
> >> oracle.oc4j.rmi.OracleRemoteException: java.lang.IllegalAccessError:
> >> tried
> >> to access class javax.xml.bind.ContextFinder from class
> >> javax.xml.bind.JAXBContext
> >>
> >> I try to switch the marshalling process to a standalone java class (just
> >> have void main method), the process works fine, can someone help me
> above
> >> this?
> >>
> >> Thanks A lot!!
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/java.lang.IllegalAccessError-occured-during-JAXBContext.newInstance%28%22package-name%22%29--tp20805508p20805508.html
> >> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> >> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/java.lang.IllegalAccessError-occured-during-JAXBContext.newInstance%28%22package-name%22%29--tp20805508p20825634.html
> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>