Discussion:
How do I sovle the "java.lang.ClassNotFoundException" problem
Peter Shi
2009-03-11 23:53:07 UTC
Permalink
I am developing a module which is dependent upon the jaxb 2.1 libraries on NB
6.5. Here is my problems:

(1) If I create a library wrapper module which includes the jaxb-api,
jaxb-impl etc. jars, at the run-time, I run into a

SEVERE [global]
javax.xml.bind.JAXBException: Provider com.sun.xml.bind.v2.ContextFactory
not found
- with linked exception:

[java.lang.ClassNotFoundException: Will not load class
com.sun.xml.bind.v2.ContextFactory arbitrarily from one of
org.netbeans.StandardModule$***@869470[org.netbeans.libs.jaxb]
and
org.netbeans.StandardModule$***@b524aa[com.xxxx.test.lib];
see http://wiki.netbeans.org/DevFaqModuleCCE]

if I remove the jaxb-api,jaxb-impl etc jars from the library wrapper module,
the library wrapper module only contain my stub classes, at the run-time, I
got another ClassCastException:


SEVERE [global]
java.lang.ClassCastException: com.sun.xml.bind.v2.runtime.JAXBContextImpl
cannot be cast to javax.xml.bind.JAXBContext
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:150)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:286)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:337)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:244)
at com.xxxx.runtime.holders.JaxBHuskHolder.getJAXBContext(Unknown
Source)
at com.xxxx.runtime.util.WSUtil.serialize(Unknown Source)
at com.xxxx.runtime.WebServiceProxyImpl.dispatchRequest(Unknown Sour

How do I solve the dilemma?

(2) I looked the jabx library module in the NB6.5, Actually it is friend
package, no public API are exposed. Could I dynamically register my libarary
as a friend package to jaxb library module ?

Any help is appreciated.

Thanks
--
View this message in context: http://www.nabble.com/How-do-I-sovle-the-%22java.lang.ClassNotFoundException%22-problem-tp22467153p22467153.html
Sent from the Netbeans RCP/Platform Users (Open API) mailing list archive at Nabble.com.
Wade Chandler
2009-03-12 14:32:24 UTC
Permalink
If that common library doesn't expose all its APIs, the common ones, then to me that would be a bug in the sense it doesn't work towards sharing libraries. Now, that said, you should be able to define an implementation dependency on it and that will take care of it as long as they don't do something like update the 2.1 library leaving the name the same only changing the version if the JAR is ever released as 2.1.1 or something like that.

Then if you are relying on this library from an IDE perspective, not RCP where you have a copy of the 6.5 platform or IDE in source control versus relying purely on the default in any IDE, then you would have to release a module for the specific IDE release and remember to watch the IDE releases and your dependencies as you'll be tied to that more so with an implementation dependency.

I mentioned the RCP versus IDE part as you can better manage when to upgrade to a new platform with an RCP application/project, but when you are working with the IDE (IDE plugins/modules) then you are tied to what ever release you shall support, and the most successful plugins are going to track the recent releases to stay current.

Wade

==================
Wade Chandler, CCE
Software Engineer and Developer
Certified Forensic Computer Examiner
NetBeans Dream Team Member and Contributor


http://www.certified-computer-examiner.com
http://wiki.netbeans.org/wiki/view/NetBeansDreamTeam
http://www.netbeans.org



----- Original Message ----
Sent: Wednesday, March 11, 2009 7:53:07 PM
Subject: [openide-dev] How do I sovle the "java.lang.ClassNotFoundException" problem
I am developing a module which is dependent upon the jaxb 2.1 libraries on NB
(1) If I create a library wrapper module which includes the jaxb-api,
jaxb-impl etc. jars, at the run-time, I run into a
SEVERE [global]
javax.xml.bind.JAXBException: Provider com.sun.xml.bind.v2.ContextFactory
not found
[java.lang.ClassNotFoundException: Will not load class
com.sun.xml.bind.v2.ContextFactory arbitrarily from one of
and
see http://wiki.netbeans.org/DevFaqModuleCCE]
if I remove the jaxb-api,jaxb-impl etc jars from the library wrapper module,
the library wrapper module only contain my stub classes, at the run-time, I
SEVERE [global]
java.lang.ClassCastException: com.sun.xml.bind.v2.runtime.JAXBContextImpl
cannot be cast to javax.xml.bind.JAXBContext
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:150)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:286)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:337)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:244)
at com.xxxx.runtime.holders.JaxBHuskHolder.getJAXBContext(Unknown
Source)
at com.xxxx.runtime.util.WSUtil.serialize(Unknown Source)
at com.xxxx.runtime.WebServiceProxyImpl.dispatchRequest(Unknown Sour
How do I solve the dilemma?
(2) I looked the jabx library module in the NB6.5, Actually it is friend
package, no public API are exposed. Could I dynamically register my libarary
as a friend package to jaxb library module ?
Any help is appreciated.
Thanks
--
http://www.nabble.com/How-do-I-sovle-the-%22java.lang.ClassNotFoundException%22-problem-tp22467153p22467153.html
Sent from the Netbeans RCP/Platform Users (Open API) mailing list archive at Nabble.com.
Peter Shi
2009-03-12 17:14:53 UTC
Permalink
Thank for your reply. But I still do not know what I can do to solve the
problem. I found jaxb libarary module boundle with NB6.5 is not a public
API, that is, they are not seen in the module development. if they are not
public API, why my module could discover it and try to access the API ?

I did this test, I moved the org-netbeans-libs-jaxb.jar into some temp
folder, and restart the NB, it prompt some modules which are dependent upon
the lib will be disabled, I continued. then I run my module (depended its
jaxb-lib,etc jars) successfully

Thanks.
--
View this message in context: http://www.nabble.com/How-do-I-sovle-the-%22java.lang.ClassNotFoundException%22-problem-tp22467153p22481173.html
Sent from the Netbeans RCP/Platform Users (Open API) mailing list archive at Nabble.com.
Wade Chandler
2009-03-12 18:33:26 UTC
Permalink
OK, without copying the module off or any of that, go to your modules libraries. Locate the JAXB 2.1 library. Highlight it. Then click the "Edit" button. There you will find some radio buttons. Choose implementation dependency. Now, that will tie you to that specific version shipped with the IDE. So, if the IDE module ever updates you have to use it as well.

Part of the problem is there must be friend APIs there which are able to access the modules libraries. Friend modules can do that. Now, you really need to go to:
http://www.netbeans.org/community/issues

and file a DEFECT against the library, you can use ide as the component if you don't know which it should be attached. With that filed issue be sure and enter in all your issues and difficulties and how that makes it hard to use other libraries along with this one. I think your initial issue, aside from not being able to depend on the module was related to some other module you are depending on using that JAXB 2.1 library and then your module creating JAXB classes from the one in the JDK/JRE. So, you had a class issue as the two classes, even if from copies of the same library (possibly), were loaded from two different class loaders. The easiest solution is to be able to depend on that JAXB library and it have its classes exposed, and as that is a standard Java library there is no valid re
ason I can see why they can't expose those libraries and APIs.

Wade

==================
Wade Chandler, CCE
Software Engineer and Developer
Certified Forensic Computer Examiner
NetBeans Dream Team Member and Contributor


http://www.certified-computer-examiner.com
http://wiki.netbeans.org/wiki/view/NetBeansDreamTeam
http://www.netbeans.org



----- Original Message ----
Sent: Thursday, March 12, 2009 1:14:53 PM
Subject: Re: [openide-dev] How do I sovle the "java.lang.ClassNotFoundException" problem
Thank for your reply. But I still do not know what I can do to solve the
problem. I found jaxb libarary module boundle with NB6.5 is not a public
API, that is, they are not seen in the module development. if they are not
public API, why my module could discover it and try to access the API ?
I did this test, I moved the org-netbeans-libs-jaxb.jar into some temp
folder, and restart the NB, it prompt some modules which are dependent upon
the lib will be disabled, I continued. then I run my module (depended its
jaxb-lib,etc jars) successfully
Thanks.
--
http://www.nabble.com/How-do-I-sovle-the-%22java.lang.ClassNotFoundException%22-problem-tp22467153p22481173.html
Sent from the Netbeans RCP/Platform Users (Open API) mailing list archive at Nabble.com.
Peter Shi
2009-03-13 00:08:24 UTC
Permalink
No progress has been made even following your instruction. I still got the
same problem. I attached several snapshots that may help you to identify my
problems. Loading Image... library1.GIF

First image showing my library wrapper module, the second is my testing
module which is dependent on the first one.
Loading Image... module1.GIF

if I run the tester module I would get a CassNotFoundException, In this
case, my understanding is that Netbeans find two place to load the
implementation, it does not load any one since NetBeans forbids ambiguous
delegations.

OK, If remove the three jars outlined in Red from my lib module, added the
Netbeans WS lib references in my tester module
Loading Image... module2.GIF , (I did select
implementation verion)when I run the tester module, I
got a classCastException, my understanding is that JaxbContextImpl has been
loaded by another class loader, it can not be accessed by my lib module.

It seems I get the dead end for this.
--
View this message in context: http://www.nabble.com/How-do-I-sovle-the-%22java.lang.ClassNotFoundException%22-problem-tp22467153p22487796.html
Sent from the Netbeans RCP/Platform Users (Open API) mailing list archive at Nabble.com.
Wade Chandler
2009-03-13 02:50:55 UTC
Permalink
hmm. Do you have some specific code you are calling you can share? That might help.

Wade

==================
Wade Chandler, CCE
Software Engineer and Developer
Certified Forensic Computer Examiner
NetBeans Dream Team Member and Contributor


http://www.certified-computer-examiner.com
http://wiki.netbeans.org/wiki/view/NetBeansDreamTeam
http://www.netbeans.org



----- Original Message ----
Sent: Thursday, March 12, 2009 8:08:24 PM
Subject: Re: [openide-dev] How do I sovle the "java.lang.ClassNotFoundException" problem
No progress has been made even following your instruction. I still got the
same problem. I attached several snapshots that may help you to identify my
problems. http://www.nabble.com/file/p22487796/library1.GIF library1.GIF
First image showing my library wrapper module, the second is my testing
module which is dependent on the first one.
http://www.nabble.com/file/p22487796/module1.GIF module1.GIF
if I run the tester module I would get a CassNotFoundException, In this
case, my understanding is that Netbeans find two place to load the
implementation, it does not load any one since NetBeans forbids ambiguous
delegations.
OK, If remove the three jars outlined in Red from my lib module, added the
Netbeans WS lib references in my tester module
http://www.nabble.com/file/p22487796/module2.GIF module2.GIF , (I did select
implementation verion)when I run the tester module, I
got a classCastException, my understanding is that JaxbContextImpl has been
loaded by another class loader, it can not be accessed by my lib module.
It seems I get the dead end for this.
--
http://www.nabble.com/How-do-I-sovle-the-%22java.lang.ClassNotFoundException%22-problem-tp22467153p22487796.html
Sent from the Netbeans RCP/Platform Users (Open API) mailing list archive at Nabble.com.
Peter Shi
2009-03-13 23:07:42 UTC
Permalink
Hi, Wade:

Thank you very much for you to help me out. When I was to compile a test
case for you, I found my problem is exactly described in the link :

http://wiki.netbeans.org/DevFaqModuleCCE


Following the work around code, I made the test case work. Although actual
case is a little complex than sample, I am confident to make it work.

Thanks again.
--
View this message in context: http://www.nabble.com/How-do-I-sovle-the-%22java.lang.ClassNotFoundException%22-problem-tp22467153p22506776.html
Sent from the Netbeans RCP/Platform Users (Open API) mailing list archive at Nabble.com.
Michal Bachorik - Sun Microsystems - Prague Czech Republic
2009-03-13 07:15:24 UTC
Permalink
did you try to put needed jaxb jar files to "release/modules/ext" folder
of your module? i had similar issue with my project (classloader issue
in the libraries), which was solved like this.

http://wiki.netbeans.org/DevFaqWrapperModules

m.
Post by Peter Shi
No progress has been made even following your instruction. I still got the
same problem. I attached several snapshots that may help you to identify my
problems. http://www.nabble.com/file/p22487796/library1.GIF library1.GIF
First image showing my library wrapper module, the second is my testing
module which is dependent on the first one.
http://www.nabble.com/file/p22487796/module1.GIF module1.GIF
if I run the tester module I would get a CassNotFoundException, In this
case, my understanding is that Netbeans find two place to load the
implementation, it does not load any one since NetBeans forbids ambiguous
delegations.
OK, If remove the three jars outlined in Red from my lib module, added the
Netbeans WS lib references in my tester module
http://www.nabble.com/file/p22487796/module2.GIF module2.GIF , (I did select
implementation verion)when I run the tester module, I
got a classCastException, my understanding is that JaxbContextImpl has been
loaded by another class loader, it can not be accessed by my lib module.
It seems I get the dead end for this.
Loading...