NoClassDefFoundError while using docx4j in IBM message broker v8 - java

I have a requirement to create a word document. So I am trying to use docx4j. I get a runtime error.
java.lang.NoClassDefFoundError: org.docx4j.openpackaging.packages.WordprocessingMLPackage
I am sure I have docx4j3.0.1 and all the dependencies added to my build path.
Is there an issue with the class initialization mechanism?
Any ideas?

Had to add all the jars to the MQSI/shared-classes folder. That worked.

For future reference a good way to resolve these problems on IBM JRE platforms is to set the environment variable IBM_JAVA_OPTIONS=-Dibm.cl.verbose=* and restart the Broker.
This will cause classloading trace to be written to Broker's standard output (located in $MQSI_WORKPATH/components//
This shows you what jars are available in each classloader and which classloaders are being searched whenever a class is loaded.

Related

Tomcat 6 Classloader : Which Jar is it reading?

I have a huge web application that I have to support. Recently when I downloaded the latest source from SVN and try to run it locally on Tomcat 6, I get the following error from one of the background batch jobs that the application runs...
2014-12-23 18:08:27 [taskScheduler-4] TaskUtils$LoggingErrorHandler [ERROR] Unexpected error occurred in scheduled task.
java.lang.NoSuchMethodError: javax.xml.stream.XMLEventFactory.newFactory()Ljavax/xml/stream/XMLEventFactory;
at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor$HeadersProcessor.<clinit>(ReadHeadersInterceptor.java:275)
So I believe the problem is the Apache class ReadHeadersInterceptor which my application's code calls is trying to call the newFactory() method from XMLEventFactory but is not finding that method, probably because it is reading an older version of XMLEventFactory.
I think this is happening because there are some JARs in my lib folder I need to remove or add. Problem is I don't know which one. I see there are several JARs which have XMLEventFactory including..
woodstox-core-asl-4.2.0
stax2-api-3.1.1
And it is also part of Java 6 in the rt.jar.
So out of all these Jars which one is it trying to read and not find that method it needs?
Thanks.
This is a problem with specific version of JDK/JRE 1.6 (I mean the update). It may looks weird but the JDK API change for specific major version.
Please take a loot at the following link. You can see there that with change from version 1.6.0.17 to 1.6.0.18 the new methods have been added on the XMLEventFactory class.
Probably you have the JRE version less thank 1.6.0.18. I've had the same problem with Apache CXF and dynamic proxies. The update of JRE 1.6.0.14 to 1.6.0.19 fixed the issue.
I hope it helps.

ClassCastExceptions due to upgrade to hibernate 4.2.8 in WebSphere 8.5.5 application container

We recently upgraded hibernate from 4.0.1 to 4.2.8.Final.
Hibernate.4.2.8.Final is depending on javassist-3.18.1-GA. Unfortunately websphere is 8.5.5 is not shipped with latest javassist but it is not my issue. I tried to force websphere to take my javassist jar but I FAILED ( for some reason it is always loading from ${WAS_INSTALL_ROOT}/plugins).
What I tried?
Classes loaded with local class loader first (parent last) in websphere console and WEB-INF/lib contains latest javassist jar. But application is not working
Put latest javassit jar in ${WAS_INSTALL_ROOT}/lib/ext but no use
Added shared library and referenced in application but no luck.
If I replace javassist.jar in ${WAS_INSTALL_ROOT}/plugins then application started working but this is not good solution because other web applications might depend on old javassist
My question
How can I use (or inject or refer) latest javassist jar in Websphere 8.5.5?
This #blog helped me to figure our the problem little quickly.
Where did you put parent last, in which window of the console?
Because there are two places in the console where to put parent last, one at the application level, and the other at the WAR level and that is the one that you want to choose.
Put 'Class loader for each WAR file in application' and I believe from inside the screen where you chose that option, click the WAR and set the classloader policy at the WAR level to parent last:
I think the path is this (don't have a console now):
Application -- > Enterprise Application --> application_instance --> Web Module --> Web Module_instance
Have a look at this to see that are two places to set classloader policies, and let me know if you found the setting and if it worked, or a new error is thrown.
Sometimes when we switch the setting we find new errors because other jars where being read from the server and not the WAR, such as bean validation errors etc. If you get a different error non javassist related, it might be caused by that and you can always post it in a new question.
This can be solved by adding the new version of javaassist as a shared library . The details are described here
[http://www-01.ibm.com/support/docview.wss?uid=swg27006159#usingserver][1].
The shared library should be assigned against the a new class loader defined at the server configuration. The class loading policy should be PARENT_LAST for this class loader
Change the WAR class loader policy to module.
Solution to the problem is PARENT_LAST but I have changed in application settings page (Applications -> Application Types -> WebSphere enterprise applications -> *application_name* -> Class loading and update detection).
Unfortunately this is not correct place to put PARENT_LAST option. Because my application is web module (to be precise war file ;)) I would have put PARENT_LAST option in (Applications -> Application Types -> WebSphere enterprise applications -> *Application_Name*-> Manage Modules -> Module Name -> Class loader order). I don't know this option until I have seen jhadesdev comment and especially the link.
#jhadesdev Thanks once again. I have summarized everything HERE
when your app structure is fairly simple I think the experiment with the war (isolated / parent last classloader) might do the trick.In my case we package in full ear form snd we use skinny wars -meaning that the actually module that contains the jpa/ hibernate entities is a full blown ejb-jar and is packaged at the ear top level. I am not sure I can easily play around with the classloader if this module (not an websphere expert though)
My second problem is tha ideally I want all these exotic classloader policy setting to be performed during packaging with no after deploy admin action (meaning an admin to do some clickd in Websphere's panel). This file based way exist but its too complex and ugly iMho, i blame Websphere for that.
Here a little guide on how to update javassist in WAS. This was tested with WAS 8.0.0.1.
The javassist.jar in WAS_HOME/plugins has to be replaced by the jar from: http://search.maven.org/remotecontent?filepath=org/javassist/javassist/3.18.1-GA/javassist-3.18.1-GA.jar
Keep the old one as backup.
Invoke WAS_HOME/profiles/PROFILE_NAME/bin/osgiCfgInit.sh and then WAS_HOME/profiles/PROFILE_NAME/bin/clearClassCache.sh or the *.bat files on windows machines.
Thanks to this post I found out how to do it: http://ramirezag.wordpress.com/2014/02/27/hibernate-4-2-8-and-websphere-8-5-5-1-issues/
We are using WAS 8.5.5 and Hibernate 4.3.5, and have faced the same issue.
Adding Java Assist as shared library did work for us.
Note that the shared library has to be created with an isolated class loader

java.lang.IncompatibleClassChangeError while running POI 3.8 on Websphere

I’m having java.lang.IncompatibleClassChangeError error when I try to load jars in JVM on websphere and run my application. I’m using the following jars
• poi-3.8.jar
• poi-ooxml-3.8.jar
I have also checked manually for any different version used in lib folder but I couldn’t see any.
Can anyone please help me to solve this error?
Ensure you don't have multiple jars with the same "package.Class" in different versions. The jars must not have 'same' name but different version. This exception rises, if the classloader loads the wrong class, that don't have an expected method par ex.
Probably this search helps you to find other jars that contain the same class. http://search.maven.org/#advancedsearch%7Cgav
An other option could be, you set the classloader to PARENT_LAST. http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=%2Frzamy%2F50%2Fprogram%2Fclsadmcns.htm

How can i solve a NoClassDefFoundError?

I have installed Oracle Weblogic 11g on Oracle Linux and I tried to complete one of Oracle's ADF tutorials using jdeveloper 11g. When I run my project it compiles successfully with no errors. It starts deploying the application to the weblogic server and my default internet browser opens. But then an Error "500 Internal server error" appears.
I'm getting the following error:
java.lang.NoClassDefFoundError: Could not initialize class org.apache.myfaces.trinidadinternal.convert.ColorConverter at....
I researched the internet for this problem and I also asked around and the common answer was that there is a problem with the classpath. Probably the libraries that are used in jdeveloper are not the same in weblogic then the project gets deployed.
Can anyone tell if definitely the problem is the classpath??
And how can I setup jdeveloper to deploy the same classpath it used to the weblogic server?
java.lang.NoClassDefFoundError means the runtime version of the class in the classpath is not the same as that at compile time.
Your problem could be multiple versions of the class being found when the server is deploying. I notice the class org.apache.myfaces.trinidadinternal.convert.ColorConverter is found in trinidad-impl.jar
Can you search for how many such jars are found in the run time server environment plus your own webapp libraries?
On windows, the Jdev inbuilt server runs in this folder
C:\Users\<...>\AppData\Roaming\JDeveloper\system11.1.1.4.37.59.23 or something similar
you need this in your webapp/WEB-INF/lib and not in the other areas.
On my local I find the Jar under C:\Users\<...>\AppData\Roaming\JDeveloper\system11.1.1.4.37.59.23\o.j2ee.wlLibs\jsp\Trinidad-Components1.2.war
I think you could use the weblogic.xml setting to force the WEB-INF/lib class to get loaded in preference to that in server/lib with
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
This happens when you try to load a class that is trying to load another class which is not on the classpath. Find out which classes are needed by ColorConverter and make sure you have them in your classpath.
First of all: What are you deploying to the server? An ADF jar or a WAR file. In your case - given that you don't have any dependent jars installed on the application server. You should deploy a WAR file.
On your view project - right click and select Project Properties. Then go to Deployment and edit the deployment profile (if none are there create one). Make sure that the checkbox "Include Libraries from other projects" is checked. (IT's in the Library Dependencies tab).
Also: you might find some useful information in here.
Hope this helps.
Michael
Using StackTrace you can find out classes those are missing .I think you are missing some jar and that should be in your classpath.

Java xerces DocumentBuilderFactoryimpl not found - What to do?

I get this message :
javax.xml.parsers.FactoryConfigurationError:
Provider
org.apache.xerces.jaxp.DocumentBuilderFactoryImp
but i can't seem to solve the problem. I have googled, but can't find any good solutions.
Does anyone have an idea of what could be wrong?
And maybe how to solve it :)
The org.apache.xerces is from the Apache Xerces package, and something in your application has a dependency on it. Try downloading it (latest version is 2.9.0) and adding it to your application's classpath.
DocumentBuilderFactory has a multi-step process for finding the actual parser implementation, as described in the linked JavaDoc. Your error message is almost certainly coming from there.
I suspect that your JBoss startup script is setting the javax.xml.parsers.DocumentBuilderFactory system property incorrectly (I've seen this happen before, used to avoid a bug in the released library). I would start by grepping the JBoss configuration directory for that property, followed by explicitly setting the jaxp.debug property (also described in the link). Assuming that your startup script is indeed explicitly setting the property, find out who made that change and ask him/her if you can delete it (or to provide you with the correct JARs if not).
As you've tagged your question JBoss, I'll assume your code is running in the JBoss container.
JBoss may have already loaded a version of Xerces for it's own use and you're trying to load a different version in your code (either explicitly or through some dependency) and the configuration for your version is not compatible with the version that's already loaded.
This JIRA Ticket on JBoss.org suggests deleting the xercesimpl.jar in jasperserver/WEB-INF/lib folder to allow your version to be used.

Categories

Resources