Link to home
Start Free TrialLog in
Avatar of lrygiel
lrygielFlag for United States of America

asked on

How to remove ClassCastException: com.sun.xml.bind.v2.runtime.JAXBContextImpl cannot be cast to javax.xml.bind.JAXBContext?

Help Me to resolve this issue:

I am deploying  war file in JBOSS server, which is processing Weblogic Queue messages .
I was implemented below code to access and unmarshal xml messages from the Queue
.-----------------------------------------------------------------------------
public void onMessage(Message message) {
textMessage = (TextMessage) message;
stringMessage = textMessage.getText();

BILGMSG bilgMsg = null;
Line 166: JAXBContext jc = JAXBContext.newInstance("com.bopeep.gen");
Unmarshaller unmarshaller = jc.createUnmarshaller();
bilgMsg = (BILGMSG) unmarshaller.unmarshal( new StreamSource( new StringReader(stringMessage)));

---------------------------------------------------------------------------------
I am using import javax.xml.bind.JAXBContext; package from JDK 1.6 and JRE6.
JBOSS - jboss-eap-5.0, Spring Listeners.
---------------------------------------------------------------------------------
I am getting the following exception:

2011-08-23 09:32:07,694 WARN  [org.springframework.jms.listener.DefaultMessageListenerContainer] (jmsListenerContainer-1) Execution of JMS message listener failed, and no ErrorHandler has been set.
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:149)
      at javax.xml.bind.ContextFinder.find(ContextFinder.java:285)
      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.dnb.bopeep.jms.listener.CobsBillingQ.onMessage(CobsBillingQ.java:166)

Note: Please see the attached file with full log. server.log server.log server.log server.log
Avatar of for_yan
for_yan
Flag of United States of America image



Maybe this could be of some help:

http://forum.springsource.org/showthread.php?47947-ClassCastException-with-JAXB-on-JBoss

I finally figured it out. There are so many things included in JBoss that dependency management becomes really tricky there. In fact, in the default configuration, there is a jbossws.sar application which includes jaxb-api and jaxb-impl.
So if we deploy the application with jaxb-api in it, there is a NullPointerException caused by a ClassCastException because ContextImpl is an instance of the server-wide Context, and not an instance of the application-local Context interface.
So the solution is just to scope jaxb-api dependency as provided and we're all set.

and this:

http://terrycmartin.blogspot.com/2009/05/jboss-seam-rss-feeds-on-jboss-as-423.html

Terry C. Martin

Thursday, May 14, 2009
JBoss Seam RSS Feeds on JBoss AS 4.2.3

I need to keep this short cuz I'm ready to go to bed. Ran into this error:

jboss com.sun.xml.bind.v2.runtime.JAXBContextImpl cannot be cast to javax.xml.bind.JAXBContext (this is the top of the resulting stack trace rather)

when I tried to click on a link on my Seam app that links to an RSS page I created. This app with its RSS functionality worked just fine on my dev box, but prod gave me that error. Lemme cut to the chase... I ended up removing jaxb-api.jar from my war file (I unzipped it, removed the file, then zipped it back up and redeployed it) and that fixed the problem. Apparently, I had some other jaxb lib in my JBoss AS classpath... somewhere... causing that trouble. Incidentally, I was running the same version of JBoss AS on dev & prod and same JVM too. I don't even feel like searching around for the conflicting jaxb lib right now... just wanted to jot this note down cuz I'll almost CERTAINLY forget i encountered this issue before.
Avatar of lrygiel

ASKER


Thanks for your response.

1:
Added  scope jaxb-api dependency in my POM file and build the war file, but issue is not resolved.
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.1</version>
<scope>compile</scope>
</dependency>

2:
But i checked in my generated war file i do not have any jaxb-api.jar file. But i found having jar in JBOSS Server, Location : C:\jboss-eap-5.0\jboss-as\lib\endorsed -jaxb-api.jar.

I deleted this from this folder and build war and deployed again, but issue is not resolved.
It still seems logical that the issue is in the mix between jaxb-api.jar and jaxb-impl.jar
If you look in your lib and in application specific folders and find all the jars and make sure
that they come from the same package - you'll most probably find it
Avatar of lrygiel

ASKER


Yan,
Application specific, i did not find any jar with this name, i checked in POM files and Buildpath too.

We have one jar file in the JBOSS location:
C:\jboss-eap-5.0\jboss-as\lib - jaxb-impl.jar.

I deleted this from this folder and build war and started server, getting following Exception.
Server needs this JAR for start .

Exception:

14:29:22,383 ERROR [AbstractKernelController] Error installing to Instantiated: name=deployers-classloader:0.0.0 state=Described
java.lang.RuntimeException: Error creating VFS file for file:/C:/jboss-eap-5.0/jboss-as/lib/jaxb-impl.jar
        at org.jboss.classloading.spi.vfs.dependency.VFSClassLoaderPolicyModule.determineVFSRoots(VFSClassLoaderPolicyModule.java:178)
        at org.jboss.classloading.spi.vfs.dependency.VFSClassLoaderPolicyModule.determinePolicy(VFSClassLoaderPolicyModule.java:210)
        at org.jboss.classloading.spi.vfs.dependency.VFSClassLoaderPolicyModule.determinePolicy(VFSClassLoaderPolicyModule.java:52)
No you have to have such jar - if you see only one of it don't delete it.
What about jaxb-api.jar

Avatar of lrygiel

ASKER


I added text in previous comment.

I found one,  having jar in JBOSS Server, Location : C:\jboss-eap-5.0\jboss-as\lib\endorsed -jaxb-api.jar.

Only one i have .
I do not have this jar in application specific folders.

And just added and tested  in POM file. But no use,
I am deleting this from the pom file.

 <dependency>
<groupId>sun-jaxb</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.1.4</version>
</dependency>

<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.1</version>
<scope>compile</scope>
</dependency>
make a copy of your jaxb-api.jar and jaxb-impl.jar files into some temp or any other folder
rename these copies to .zip and open them with winzip
Check that they are form related packages
in your error you have .JAXBContextImpl  from one package and JAXBContext frok another:
com.sun.xml.bind.v2.runtime.JAXBContextImpl cannot be cast to javax.xml.bind.JAXBContext
Avatar of lrygiel

ASKER



from jaxb-api.war - javax\xml\bind -JAXBContect.class

from jaxb-impl.jar - com\sun\xml\bind\v2\runtime - JAXBContextImpl.class

I am attaching jars u can see.
I think EE does not allow to attach jar's

My guess is that JAXBContextImpl.class should extend JAXBContext
but there is some mixup of jars and this is not happenning


Check this (it is with weblogic, so I'm not sure the solutyion with apply, but the situation is similar)

http://old.nabble.com/ClassCastException%3A-com.sun.xml.bind.v2.runtime.JAXBContextImpl-in-WebLogic-10-td26719107.html


After I put those jars into WEB-INF/lib and restarted, I got the
following:

java.lang.ClassCastException:
com.sun.xml.bind.v2.runtime.JAXBContextImpl

It appears that after I constructed an EAR for this project, put my jars
into the EAR, and set "prefer-application-packages", I stopped getting
this error.
Do you knwo if both these jars came form the same source?
Say, both from JBOSS installation or maybe one from JBOSS, another came with application?
Avatar of lrygiel

ASKER


You are right, JAXBContextImpl.class extending  JAXBContext. I saw in api in initial time.

But we have these classes in our jar files which are there in JBOSS server.

I am asking you, need to add these jars in war file?

Well, it makes sense to try; maybe there is still this class somewhere else where
we do not see it and it clashes. So put them togetehr in war, maybe it will work
Avatar of lrygiel

ASKER


If like that, i added dependencys for both jars, and created jars in and able to see those jars in WebINF/lib folder in war file, when i unzip that war file.

I think both are same , i guess no need to add these explicitly in war file.
Yes, maybe you are right.

Could you extract those two classes with zip and post them here, just two of them.
I think EE allows to attach .class


read this:
https://forum.hibernate.org/viewtopic.php?f=9&t=1005522
eneven though t is about hibernate, but they talk about jaxb

they are saying taht JDK 1.6 has its own JAXB classes.
If so and if you are using JDK 1.6 - maybe you should remove both of them.
Have you tried this way?

Aniother option - maybe you can try to run JBOSS with JDK 1.5 with both jars present - is it possible?
Avatar of lrygiel

ASKER

Please see both classes from both jars.


JAXBContext.class
JAXBContextImpl.class
Avatar of lrygiel

ASKER

If i remove jaxb-api.jar, nothing problem

if i delete jaxb-impl.jar, JBOSS will be efect to start, it wont start.

I tried with both deleted.

Could you check if your jaxb-impl.jar conrtains com.sun.xml.bind.api.JAXBRIContext ?

Then maybe post it also
Avatar of lrygiel

ASKER


I Tried with JDK 5 and JRE 5, got same problem.

12:40:27,929 WARN  [DefaultMessageListenerContainer] Execution of JMS message listener failed, and no ErrorHandler has been set.
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:149)
        at javax.xml.bind.ContextFinder.find(ContextFinder.java:285)
        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.dnb.bopeep.jms.listener.CobsBillingQ.onMessage(CobsBillingQ.java:166)
        at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.jav
        at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:
Avatar of lrygiel

ASKER



Your Question:Could you check if your jaxb-impl.jar conrtains com.sun.xml.bind.api.JAXBRIContext ?


My Answer: YES
jaxb-impl.jar - com\sun\xml\bind\api  - JAXBRIContext.class
JAXBRIContext.class

It looks like com.sun.xml.bind.v2.runtime.JAXBContextImpl  is extending com.sun.xml.bind.api.JAXBRIContext
so if com.sun.xml.bind.api.JAXBRIContext extends javax.xml.bind.JAXBContext then
it should be able to cast com.sun.xml.bind.v2.runtime.JAXBContextImpl   to javax.xml.bind.JAXBContext
That's why I wanted to look at this com.sun.xml.bind.api.JAXBRIContext.class


So let's review a litle bit, as I maybe already forgot something - so you have both jaxb-api.jar and jaxb-impl.jar coming both form the
same installation of JBOSS - one would assume that they should work with one another.

Then you have war file which comes from different sources even probably with some stuff from weblogic.
Does this war contain any jars  referring to jaxb ?


Avatar of lrygiel

ASKER

TRUE.

See the below link. Just for ref:

URL: http://www.docjar.org/docs/api/com/sun/xml/internal/bind/v2/runtime/JAXBContextImpl.html

Like this :
com.sun.xml.internal.bind.v2.runtime
public final class: JAXBContextImpl [javadoc | source]

java.lang.Object
   javax.xml.bind.JAXBContext
      com.sun.xml.internal.bind.api.JAXBRIContext
         com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl
This class provides the implementation of JAXBContext.
Avatar of lrygiel

ASKER


I am using Eclipse to setup the app and JDK JRE 6. Implemented JMS -MessageListener,
This Listener is retriving message from the Weblogic Q. And validating, processing and storing data in the DB.
 Using Maven script to build the app.
Usingmvn command :  mvn clean install. (creating war file)
This war file doesnt contain any jaxb-iml or jaxb-api.jar files.
If i add dependency in pom file it will be there in war file.
Its creating war file. And we are using JBOSS -eap 5.0 server to deploy.


Maybe it is sometghing related to this:
from:
http://hg.nuxeo.org/nuxeo/nuxeo-distribution/raw-file/5.2/nuxeo-distribution-jboss/src/main/resources/jboss/readme-jboss.html


JBossAS 4.2.3.GA

    JBossAS 4.2.3.GA can be compiled with both Java5 & Java6. The Java5 compiled binary is our primary/recommended binary distribution. It has undergone rigorous testing and can run under both a Java 5 and a Java 6 runtime. When running under Java 6 you need to manually copy the following libraries from the JBOSS_HOME/client directory to the JBOSS_HOME/lib/endorsed directory, so that the JAX-WS 2.0 apis supported by JBossWS are used:
        jboss-jaxrpc.jar
        jboss-jaxws.jar
        jboss-jaxws-ext.jar
        jboss-saaj.jar
        jaxb-api.jar

Have you copied these jars?
Avatar of lrygiel

ASKER


We have only one jar file
C:\jboss-eap-5.0\jboss-as\client - jaxb-api.jar, remaining jars are not avaialble in this folder


and i have jaxb-iml.jar too.
But this jaxb-api.jar you copied it to JBOSS_HOME/lib/endorsed directory ?

Read the following from
http://bimalesh.blogspot.com/2007/05/jboss-jaxb-and-jdk-16.html

especially about Eclipse situation little bit  below:


While using JBoss 4.0.2, JAXB 2.1 and JDK 1.6 (a.k.a J2SE 6.0) if you get a linkage error similar to one discussed here then you should put jaxb-api.jar from JAXB RI into the endorsed directory used by Jboss. Putting it under jre/lib/endorsed directory has no affect as JBoss overrides the endorsed directory with its own. Place the jaxb-api.jar into $jboss-home/lib/endorsed directory instead. It should solve the linkage problem.

JoPe said...

    Let me add one more thing: If you start your JBoss from Eclipse using JBoss Tools, just putting the jaxb-api.jar into JBOSS_HOME/lib/endorsed won't help, because the JBoss Tools launch configuration ignores this directory unless you enter the VM argument -Djava.endorsed.dirs=YOUR/JBOSS/HOME/lib/endorsed in the properties of the JBoss server configuration. I spent a frustrating day finding out... :-(
    1:17 AM
Anonymous said...

    Thanks! This also fixed a little different problem for me. However, it was a caused by a conflict in my servlet using Jaxb as does Jboss. I was getting:
    java.lang.ClassCastException: com.sun.xml.bind.v2.runtime.JAXBContextImpl

    I'm using Jaxb-api 2.1
    10:42 PM
Avatar of lrygiel

ASKER


Starting JBOSS from the eclipse and directly using run.bat file from the JBOSS folder.

Both are getting same problem like what we have now.
I still have a feeling taht we are somewhere close to understanding

read this from
http://metro.java.net/guide/Using_JAX_WS_2_1_with_JavaSE6.html
and i came here form this page which talks about very similar error:
https://forums.oracle.com/forums/thread.jspa?threadID=2223594
---------------------------
2.8. Using JAX-WS 2.1 with JavaSE6

JavaSE6 ships with JAX-WS 2.0 API in rt.jar, which causes some trouble when you try to run applications that use JAX-WS 2.1 API. This document collects information about how to solve this issue.
2.8.1. Endorsed directory

One way to fix this is to copy jaxws-api.jar and jaxb-api.jar into JRE endorsed directory, which is $JAVA_HOME/lib/endorsed (or $JDK_HOME/jre/lib/endorsed)

Some application containers, such as Glassfish, modifies the location of the endorsed directory to a different place. From inside the JVM, you can check the current location by doing System.out.println(System.getProperty("java.endorsed.dirs"));

Obviously you still need other JAX-WS jars in your classpath.

Please do not put all the jars to the endorsed directory. This makes it impossible for JAX-WS RI to see other classes that it needs for its operation, such as servlet classes on the server-side, or Ant classes in the tool time. As those are not loaded by the bootstrap classloader, you'll get NoClassDefError on servlet/Ant classes.
-----------------------------

Also read this from
the bottom of
http://weblogs.java.net/blog/ramapulavarthi/archive/2007/01/problems_using.html

-------------------------------------------
Sometimes its pretty clear what the error is, but not in all cases. JAXB 2.0 and JAX-WS 2.0 are part of JDK 6. To use JAX-WS 2.1 with JDK 6, newer versions of API jars (JAX-WS 2.1 and JAXB 2.1 API jars) need to be in bootclasspath before rt.jar. To do this you can use Java endorsed mechanism to override whats in Java platform. See http://java.sun.com/j2se/1.5.0/docs/guide/standards/ for more details on Endorsed Standards Override Mechanism.

To get around this issue, You can simply copy jaxb-api.jar, jaxws-api.jar to <java-home>/lib/endorsed Here <java-home> refers to the directory where the runtime software is installed (which is the top-level directory of the J2SE Runtime Environment or the jre directory in the JDK).

If you prefer to not change JDK, For invoking wsimport and wsgen tools in JAX-WS 2.1, you can set WSIMPORT_OPTS=-Djava.endorsed.dirs=%JAXWS_HOME%/lib & WSGEN_OPTS=-Djava.endorsed.dirs=%JAXWS_HOME%/lib, where JAXWS_HOME points to JAX-WS 2.1 installation.

If you use ant tasks, you can pass -Djava.endorsed.dirs=%JAXWS_HOME%/lib as jvmarg while calling wsimport and wsgen ant tasks. For this to work, you need to set fork="true" attribute of wsimport and wsgen ant tasks.

-----------------------------------------------------



Also read this general useful info about what to do when you want to override some classes
which are sitting in rt.jar by the newer versions:
http://download.oracle.com/javase/6/docs/technotes/guides/standards/
Avatar of lrygiel

ASKER


I did not installed any JAX-WS 2.1 separately. Just i add JAVA-HOME and JBOSS-HOME in the classpath.

I coudnt find any like $JAVA_HOME/lib/endorsed (or $JDK_HOME/jre/lib/endorsed).

If installed  JAX-WS 2.1  then i can set  
WSIMPORT_OPTS=-Djava.endorsed.dirs=%JAXWS_HOME%/lib & WSGEN_OPTS=-Djava.endorsed.dirs=%JAXWS_HOME%/lib, where JAXWS_HOME points to JAX-WS 2.1.

Could you tell where JAX-WS jars will be rside.
Avatar of lrygiel

ASKER


One thing i want to say.

I tested with war file which is created by relese guys. That war is generated with same source and build using Hudson. I took that war file deployed in my local JBOSS server and passed messages to Queues In WL in my local. Wonder it was working fine, i did not see any issues, able to process Queue message and processed and stored data in the database.

Here In production or DEV environment they changed folder structure in JBOSS server.
Could you guess any thing wrong in change the folder structure?

I am using default folder structure only.
I don't think you need to install anything. And you don't have any lib/endorsed folder because you didn't need to override anytjing in your standard libraryt bbefore. I think you need to create endorsed folder in JAVA_HOME/lib and copy to that folder jaxb-api from your JBOiSS locattion. Then resytart JBOSS and try
if it is working fine, what may be the pproblem with changed folder structure? Don't think it matters.
Avatar of lrygiel

ASKER


created endorsed folder in JAVA_HOME/lib and copy to that folder jaxb-api and next copied jaxb-impl,jar too.
C:\Program Files\Java\jdk1.6.0_26\lib\endorsed

But got the sme exception.
Avatar of lrygiel

ASKER

Yan,

Still issue is not resolved, could you give any direction to solve the issue,

Thanks
This war appliaction - is it something that you wrote youself, or did you get it from someone?
Is it processing WebLogic messages - just works as the client?
If you wrote it - maybe you can extrct those parts and make just simple client application of it
and see if it works. In this way you'll disconnecte from JBoss depndencies and we can check
which jars are working and which are not. With that knowledge it would probably be better to trty to
figure out what to do on the server
Avatar of lrygiel

ASKER


This is JAVA Web application, implemented and checked in subversion, I am as a new guy wants to setup app on my system. So i took source from the subversion  and created WAR in my local with MAVEN build tool. No issues to create war. Then i am deploying in My local JBOSS server. This app reading Queue mesaages from Weblogic Q(Which is also in my local). App reading Message properly and printing the message in the console. After that needs to unmarshal using JAXBContect class.
that JAXBContect line166 giving the problem.

Ref Code:

public void onMessage(Message message) {
textMessage = (TextMessage) message;
stringMessage = textMessage.getText();

BILGMSG bilgMsg = null;
Line 166: JAXBContext jc = JAXBContext.newInstance("com.bopeep.gen");
Unmarshaller unmarshaller = jc.createUnmarshaller();
bilgMsg = (BILGMSG) unmarshaller.unmarshal( new StreamSource( new StringReader(stringMessage)));
error:
java.lang.ClassCastException: com.sun.xml.bind.v2.runtime.JAXBContextImpl cannot be cast to javax.xml.bind.JAXBContext

Please see the full error log in above responses.

2nd Response:
We are using JBOSS server specific DataSource connection creation, using xxx-ds.xml file.and using properties files for setup Weblogic server address and Queue names. These properties files are configuring in spring.xml file.

<bean class="org.springframework.core.io.FileSystemResource">
            <constructor-arg>
              <bean class="org.springframework.jndi.JndiObjectFactoryBean">
                <property name="jndiName" value="external/config/dnb_bopeep_billing/application.properties" />
              </bean>
            </constructor-arg>
          </bean>
          <bean class="org.springframework.core.io.FileSystemResource">
            <constructor-arg>
              <bean class="org.springframework.jndi.JndiObjectFactoryBean">
                <property name="jndiName" value="external/config/dnb_bopeep_billing/bopeep_scheduling.properties" />
              </bean>
            </constructor-arg>
          </bean>

Note: Same way doing in production, but production war file deployed in my local JBOSS server and accesses Queues from My local WL Queues. Its fine, no issues.

I am using pure xml format message, getting this as string and unmarshling using JAXBContext.like

stringMessage = textMessage.getText();
bilgMsg = (BILGMSG) unmarshaller.unmarshal( new StreamSource( new StringReader(stringMessage)));

I di dnot get  your point like (If you wrote it ), could ypou tell me clearly?

Thanks
No, if you downloaded the source, then my suggestion would be  not appropriate.

Didi you see this thread:
http://www.eclipse.org/forums/index.php/m/719379/
There is no confirmation of resolution, still you ca try some suggestions
Avatar of lrygiel

ASKER


Yan,

Could you help me where can i find DomainClass.class.getClassLoader()
Just i added in my code like

JAXBContext jc = JAXBContext.newInstance("com.dnb.bopeep.gen", DomainClass.class.getClassLoader());

But DomainClass.classnot gound, could you tell need to download any jar or?

Thnaks
Maybe you can try this.class.getClassLoader() ?
Avatar of lrygiel

ASKER


I am sorry,

this.class, getting class identifier expecting. Showing error.

Sorry, I guess, this will work (I mean will not write this latest error):

 this.getClass().getClassLoader()
Avatar of lrygiel

ASKER

Hi Yan,

I used like below

JAXBContext jc = JAXBContext.newInstance("com.bopeep.gen", this.getClass().getClassLoader());

but got the same exception.
I was thinking you are using JBoss, but the log files you posted are talking something about Catalina and Tomcat

So you are running Tomcat and JBoss?


in this link
http://www.java.net/node/693919
which describes similar ClassCast excepton

I read:
-------------
Yes, seems like standalone JAXB RI is being picked up whereas JAX-WS is still used from JDK.
Can you use JDK 6u14 that has JAX-WS 2.1.6 RI directly without the endorsed mechanism?
-------------

Which minor version of JDK6 are you using?



Avatar of lrygiel

ASKER



Hi Yan,

I am not using  Catalina, i did not find any word in my log file like " Catalina".

Yesterday only i tried to deploy on Tomcat, but i did not send any log file regarding that.
If you want i can send today JBOSS log file

I am using jdk1.6.0_26 and jre6.

I am trying to use JDK 6u14 (Which you suggested)

Thanks
No, I think jdk1.6.0_26 is later than JDK 6u14
so you don't need to change -I understan their remark that  you should not be on earlier JDK, but later should be OK.

These are the lines form the very first log file you posted bove - you see it has a lot of words about Tomcat, Cataklina, etdc

(by the way I could have seen there that you are using 1.6.0_26


2011-08-23 09:31:41,452 INFO  [org.apache.catalina.core.AprLifecycleListener] (main) The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.6.0_26\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files\Serena\Dimensions 12.1\CM\prog64;C:\Program Files\Serena\Dimensions 12.1\CM\prog;C:\Program Files\Serena\Dimensions 12.1\CM\prog\Microsoft.VC90.MFC;C:\Program Files\Serena\Dimensions 12.1\CM\prog\Microsoft.VC90.CRT;C:\Program Files\Serena\Dimensions 12.1\CM\prog\Microsoft.VC90.ATL;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Common Files\Ulead Systems\MPEG;C:\Program Files\RSA Security\RSA SecurID Software Token\;C:\Program Files\Lenovo\Access Connections\;C:\SWTOOLS\ReadyApps;C:\Program Files\Common Files\Lenovo;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Java\jdk1.6.0_26/bin;C:\jboss-eap-5.0\jboss-as/bin;C:\apache-maven-2.2.1/bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;.
2011-08-23 09:31:41,499 INFO  [org.apache.coyote.http11.Http11Protocol] (main) Initializing Coyote HTTP/1.1 on http-127.0.0.1-8080
2011-08-23 09:31:41,499 INFO  [org.apache.coyote.ajp.AjpProtocol] (main) Initializing Coyote AJP/1.3 on ajp-127.0.0.1-8009
2011-08-23 09:31:41,530 INFO  [org.apache.catalina.core.StandardService] (main) Starting service jboss.web
2011-08-23 09:31:41,546 INFO  [org.apache.catalina.core.StandardEngine] (main) Starting Servlet Engine: JBoss Web/2.1.3
Avatar of lrygiel

ASKER


Yan,

I set claspath C:\Program Files\Java\jdk1.6.0_14.

But no difference, getting same issue.

Thanks
Avatar of lrygiel

ASKER

I am sorry, i did not see ur comment.

Ignore the previous message.
Do you know why you have catalina, tomcat there?
Avatar of lrygiel

ASKER

Yes Yan. I am sorry. You are rite.

But i am not explicitly configured  any related to tomcat or catalina.

Avatar of lrygiel

ASKER


I am sorry yan, i have no idea about those.

I compare these postings of yours:

>I tested with war file which is created by relese guys. That war is generated with same source and build using Hudson. I took that war file deployed in my local JBOSS server and >passed messages to Queues In WL in my local. Wonder it was working fine, i did not see any issues, able to process Queue message and processed and stored data in the database.

and


>So i took source from the subversion  and created WAR in my local with MAVEN build tool. No issues to create war. Then i am deploying in My local JBOSS server

So when you take their WAR and deploy, everything runs smoothly
and when you compile yourself and create your WAR and deploy it in the same server - it fails - correct?

If so, can't you extract both wars in two separate places and  compare and try to see what is the difference?

Avatar of lrygiel

ASKER

Hi Yan,

Idid the same, no difference between those two wars. same jar files are having both WAR files.

Thanks
But is it true that with one WAR it is working and with another one it is not working?
Is there some other difference?
Avatar of lrygiel

ASKER

i only compare list of jars in both war files and both are same, i did not compare in side jars.
i have to do that and i will try

thanks
well compare and if you don't see anything special "cross-breed" or better to say "chimerize" them - take you jaxb jars form the good one and put them into
the bad one instead of those you have there (of course keep a copy of everything).
Avatar of lrygiel

ASKER

Yan,

I did compare, i found size of few jars are loacl is different than production jars.
One more thing, ojdbc size also huge difference is there.

all prject jars are little diffrence is there.
ojdbc6-0.0.1-SNAPSHOT.jar - local size 1988,051 and prod 3217,836

Could you guess both should be the same size, because prod and local using same source.

Thanks
ojdbc is not something which you compile I guess - it is some different version
of jdbc driver form oracle - ?

Are those controversioal jars - jaxb related different?
Avatar of lrygiel

ASKER

No,

i am not importing any JAXB related Jars explicitly, just using JBOSS inbuilt jars like jaxb-impl.jar and jaxb-api.jar, etc.. and JDK 1.6. Which i am using JaxbContext is from JDK api.

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
JAXBContext jc = JAXBContext.newInstance("com.dnb.bopeep.gen");
That nmeans that in both cases you are usinf the same jaxb but in one case it works and in anothr throws this classCast exception ?
Avatar of lrygiel

ASKER

Yes, you r rite.
That's strange - maybe there are still somewhere in the classpath other versions of these classes of which we don't suspect.

Maybe you can use stuff from this page (read also reamark at the bottom - maybe it will work)
http://snippets.dzone.com/posts/show/3472

and you can put it in your code and try to printout the location of jar file
from which both of these guys (JAXBConrtext and JAXBContextImpl) are coming?

Avatar of lrygiel

ASKER

i checked classpath in JBOSS run.bat file. Compared with prod JBOSS image, Both are having same files. I checked System Environment variables. JBOSS_HOME, JAVA_HOME and M_HOME are added.
Avatar of lrygiel

ASKER


JAXBConrtext is comming from JAVA api and JAXBContextImpl (com.sun.xml.bind.v2.runtime.JAXBContextImpl) comming from JAXB-impl.jar
What that means?
JAXBConrtext is comming from JAVA api
Is it rt.jar?
Avatar of lrygiel

ASKER

yes
And how do you know from where each comes ?
Avatar of lrygiel

ASKER

According to exception i searched in google with com.sun.xml.bind.v2.runtime.JAXBContextImpl class, this class is there in jaxb-impl.jar.

And JAXBContext class is from rt.jar, this class belongs to this jar only, because if i delete import it is showing class not found exception.

C:\Program Files\Java\jdk1.6.0_26\jre\lib>rt.jar

When i start run.bat from the JBOSS, its calling  JBOSS_HOME and CLASSPATH

from the command promt:

Calling C:\jboss-eap-5.0\jboss-as\bin\run.conf.bat
===============================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: C:\jboss-eap-5.0\jboss-as

  JAVA: C:\Program Files\Java\jdk1.6.0_26\bin\java

  JAVA_OPTS: -Dprogram.name=run.bat -Xms128M -Xmx512M -XX:MaxPermSize=256M -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dorg.jboss.resolver.warning=true -server

  CLASSPATH: C:\Program Files\Java\jdk1.6.0_26\lib\tools.jar;C:\jboss-eap-5.0\jboss-as\bin\run.jar
ASKER CERTIFIED SOLUTION
Avatar of for_yan
for_yan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lrygiel

ASKER


If i remove jaxb-impl.jar from the jboss , if you try to start this server will throw an exception.
Meens will not be start the server.

I am implementing code to print thaose jar clasees path.
It is strange that this lib/endorsed mechanism which should override
the stuff from rt.jar does not seem to work for you.

Anyway if we could print from where it comes it will allow us to undersatnd better
Avatar of lrygiel

ASKER


Example code(http://snippets.dzone.com/posts/show/3472)
 implemented in my calss, but that is giving location name where we are using JAXBContext class

C:/jboss-eap-5.0/jboss-as/server/default/deploy/bopeep-billing-war.war/WEB-INF/classes/com/dnb/bopeep/jms/listener/CobsBillingQ$1.class

I am trying to print zar file name. if you any idea or example code just forward it to me.
Avatar of lrygiel

ASKER

Yan,

I found from where JAXBContext is calling. this is not calling form rt.jar, caling from the different place.

that is from :

JAXBContext JAR************************************************jar:file:/C:/jboss-eap-5.0/jboss-as/server/default/deploy/bopeep-billing-war.war!/WEB-INF/lib/wlfullclient-no-javax-10.3.jar

I did unzar war file: C:\Users\parisac\Desktop\Docs\WAR\Local War\WEB-INF\lib > in this we have list of jar files. one is wlfullclient-no-javax-10.3.jar  (this is added in buildpath for the project)

I unzar wlfullclient-no-javax-10.3.jar , that i pound that call in below location.
C:\Users\parisac\Desktop\Docs\WAR\Local War\New folder\javax\xml\bind>JAXBContext.class is there.




So we somehow need to have both of them should come form the same origin say both from JBoss or both from JDK.
It looks like both coming form JBoss but not from complemnantry jaxb-impl.jar and jaxb-api.jar which were created together - perhaps that is the problem?
Avatar of lrygiel

ASKER

Hi Yan,

Good News after long time.

Finally able to process the message and store the data in the database.

Thank you so much,  You are really GENIUS, Your help is very appriciated.

I am explaining the problem and solution in next message.

Thank You.
Great news!
Sure, please, explain, when you have  a moment.
Avatar of lrygiel

ASKER

Hi Yan,

You know i took source from the subversion. In local i am using Eclipse IDE. Imported list of dependency projects into the eclipse. I set the required build path for few projects. I am using MAVEN build tool to build the project. In war project pom file set the list of dependencies. One of those is
       <dependency>
          <groupId>weblogic.wlfullclient</groupId>
          <artifactId>wlfullclient-no-javax</artifactId>
          <version>10.3</version>
     </dependency>

And remaining are related to Spring, Ojdbc, Log4j, etc...

when i build initiallly it shows missing dependencies. those are Ojdbc and  weblogic.wlfullclient. So i spoke to my Admin guys, they told need to download manually. So i did that and installed using explicit commands like :
-> mvn install:install-file -DgroupId=weblogic.wlfullclient -DartifactId=wlfullclient-no-javax -Dversion=10.3 -Dpackaging=jar -Dfile=C:\Libs\weblogic\wlfullclient.jar

So dependency problem is solved. Then i set build path based on the exceptions.
When romoved all exceptions and able to build the war file. Here is the problem. When i deployed war file in JBOSS server and trying to start the server thrown exception like
      -> java.lang.ClassCastException: com.sun.xml.bind.v2.runtime.JAXBContextImpl cannot be cast to     javax.xml.bind.JAXBContext.

Then i spoke to release guys to get the solution, and i got the production war file and deployed in local JBOSS server its wonder , it works fine. So i thought issue with the source and jars. But not able to figure it out.

Then started chating with you to get the help. Then you know what we did.
Finally i came to know few jars size is diffenrent than production jars. You gave on link to get the code to find JAXBContext class is calling from  which jar.

Code and  New link:
http://www.jugpadova.it/articles/2005/11/13/from-which-jar-a-class-was-loaded

      Class cls = JAXBContext.class;
      ProtectionDomain pDomain = cls.getProtectionDomain();
      CodeSource cSource = pDomain.getCodeSource();
      URL loc = cSource.getLocation();
      System.out.println("JAXBContext JAR************************************************"+loc);

Identified jar and unzip that jars (local and production)
Local : C:\Users\parisac\Desktop\Docs\WAR\Local War\New folder\javax
Production : C:\Users\parisac\Desktop\Docs\WAR\production War \New folder -  NO JAVAX folder in this .
This is the root cause to the problem. I thought getting exception with this. Then i replaced my local wlfullclient-no-javax-10.3.jar with production jar.  

Problem is solved.

Thank You Yan. You spent valuable time.
Avatar of lrygiel

ASKER


Missing output in previous message:

Code and  New link:
http://www.jugpadova.it/articles/2005/11/13/from-which-jar-a-class-was-loaded

      Class cls = JAXBContext.class;
      ProtectionDomain pDomain = cls.getProtectionDomain();
      CodeSource cSource = pDomain.getCodeSource();
      URL loc = cSource.getLocation();
      System.out.println("JAXBContext JAR************************************************"+loc);

Output :

JAXBContext JAR************************************************jar:file:/C:/jboss-eap-5.0/jboss-as/server/default/deploy/bopeep-billing-war.war!/WEB-INF/lib/wlfullclient-no-javax-10.3.jar
Great!
Thanks a lot for summarizing all this. This would be useful, especially this thing where we printed locations of the jars. Folks often have clashes of the classes coming froim different sources and this seems to be a good way to find a resolution of some of such issues.
Best of luck!
Avatar of lrygiel

ASKER

Probably the longest thread I have ever seen on EE, thanks to YAN's persistance was able to work through the probelm to the solutions. A+++ and 5000 point if I could give them.
Thanks for the kind words.

EE should make an amendment in their rules and allow the Asker for the long threads to add 100 points, say,  per each 25 Asker's posts.