UnsupportedClassVersionError in Webphere 8.5 due to classpath - java

2 jars in WEB-INF/lib of Websphere 8.5.5.5 are having same directory structure
org.json.* .
json.jar Compiled withJDK 1.6
commonlib.jar compiled with JDK 1.7
Iam receiving below exception during the JVM startup in one environment while another environment has same jars and same classpath but there its working properly. WAS is running Java 1.6 due to which getting UnsupportedClassVersionError
6/23/16 15:59:32:091 CDT] 0000005e InjectionProc W CWNEN0047W: Resource annotations on the fields of the jmaki.xhp.XmlHttpProxyServlet class will be ignored. The annotations could not be obtained because of the exception : java.lang.UnsupportedClassVersionError: JVMCFRE003 bad major version; class=org/json/JSONObject, offset=6
When i specifically add the second jar to the class path of the second environment it gives the above error, otherwise it works properly Is it due to the classpath order?
class load: org.json.JSONException from: file:/hosting/configs/WebSphereD24/AppServer/installedApps/nodea/sear/swar/WEB-INF/lib/json.jar
class load: org.json.JSONObject$Null from: file:/hosting/configs/WebSphereD24/AppServer/installedApps/nodea/sear/swar/WEB-INF/lib/json.jar
How does WebSphere decide the jar to load the class=org/json/JSONException from . This class is present in both the jars... How come its loading from json.jar in one and common.jar in another.

The order of WEB-INF/lib JARs is unspecified, so the order will typically be defined by the file system. You should remove duplicate classes rather than trying to rely on any particular order.

Related

An SPI class of type org.apache.lucene.codecs.DocValuesFormat with name 'Memory' does not exist

Getting error:
Diag message: User class threw exception: java.lang.IllegalArgumentException: An SPI class of type org.apache.lucene.codecs.DocValuesFormat with name 'Memory' does not exist.
You need to add the corresponding JAR file supporting this SPI to your classpath.
The current classpath supports the following names: [Lucene54]
at org.apache.lucene.util.NamedSPILoader.lookup(NamedSPILoader.java:116)
at org.apache.lucene.codecs.DocValuesFormat.forName(DocValuesFormat.java:108)
I have tried running the jar with various newer versions of lucene-core (along with backward-compatibility jar) but no success. Currently, we are using 6.5.0 version.
The Lucene-index we are trying to read contains files like - _4o08_Memory_0.mdvd & _4o08_Memory_0.mdvm which are the real issue.
Solution - add maven dependency https://mvnrepository.com/artifact/org.apache.lucene/lucene-codecs/6.5.0 & make sure its a runtime dependency & not limited to test scope.

How do I use DataNucleus's java agent when deploying a servlet to tomcat?

DataNucleus has a Java agent that performs bytecode enhancement of classes. I added -javaagent:datanucleus-core-5.1.0-m3.jar=-api=JDO (Using the actual jar name and path) to the JVM options used by my IDE to start Tomcat. The agent threw org.datanucleus.exceptions.NucleusUserException: Error : Could not find API definition for name "JDO". Perhaps you dont have the requisite datanucleus-api-XXX jar in the CLASSPATH?, at which point I added -cp datanucleus-api-jdo-5.1.0-m3.jar:. (again using the actual jar name and path), which did not resolve the error. I understand that Tomcat has quirky classpath handling, but the Java agent should be running before Tomcat's main method, meaning none of this trickery should have happened yet. How do I perform runtime bytecode enhancement with DataNucleus on Tomcat?

Remove xercesImpl-2.8.1.jar from the application

Per the recommendation from here: WAS 8.5: java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl incompatible with javax.xml.parsers.SAXParserFactory, I've looked through all the jars and cannot find xercesImpl-2.8.1.jar. I did remove crimson_1.1.1.jar from my project but that did not alter the error (java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl incompatible with javax.xml.parsers.SAXParserFactory). I looked for the method in question (SAXParserFactoryImpl) and found it here: C:\Program Files\IBM\IBMIMShared\plugins\org.apache.xerces_2.9.0.v200805270400.jar. Since this jar is part of the Websphere installation, how can I remove it? Or does it need to be updated with a newer version that resolves this incompatibility?
Ok, I found the solution. With the goal of replacing crimson_1.1.1.jar, I looked for other jars (on my machine) having the class SAXParserFactoryimpl. I found it in several jars, two in particular: xercesimpl-2.8.0 and xercesimpl-2.9.1. I ultimately picked xercesimpl-2.8.0.jar because I needed to include another jar in my app, commons-fileupload-1.2.jar. When I downloaded this commons package to include it into my app, it came with xercesimpl-2.8.0.jar. So with that as the connection, I removed all references to crimson_1.1.1.jar and replaced it with xercesimpl-2.8.0.jar in my application. I also had to set my EAR's deployment descriptor (EAR > deployment descriptor > Deployment tab > Application section) to PARENT_FIRST for Classloader mode and APPLICATION for WAR classloader policy. So with the jars swapped and the deployment descriptor modified, the server started up w/o error and no longer got this incompatibility error and my application was finally working!

java.lang.NoSuchMethodError: org/springframework/util/ReflectionUtils.isPublicStaticFinal(Ljava/lang/reflect/Field;)Z

After application deployment in websphere application server v8,I'm getting the above error on JVM startup.MANIFEST.MF file contains two jars spring-2.5.5.jar & spring-sandbox.jar (version 1.2) and the said method "isPublicStaticFinal" is not present in spring-sandbox.jar but it's present in spring-2.5.5.jar (both having same package with same class i.e.org/springframework/util/ReflectionUtils) I guess there's something with version mismatch or conflict between two classes in the jars.I'm not able to get the latest version of sandbox jar.Also, I can't remove that jar as application is using some functions in that jar.Does entries/order of jars in classpath of MANAIFEST.MF matters? Any solution for this please?
Thanks Angelo.It is working fine now.
I have re-ordered the classpath enteries in Manifest.mf so that it loads first jar where the class and method is available.So, this is my conclusion now..order of jars matters in Manifest specially when two jars contains same class with same method and same package indeed.

NoClassDefFoundError: Could not initialize class org.apache.axis2.description.AxisService

While running the application I was getting the following errors.
java.lang.NoClassDefFoundError: Could not initialize class org.apache.axis2.description.AxisService
AxisService class is in axis2-kernel-1.6.2.jar file. Some of the classes from this jar are working fine without any issues, but some classes are throwing NoClassDefFoundError from this jar file at runtime. AxisService class is present in axis2-kernel-1.6.2.jar, even it throws error.
This is working fine in local machine. But error getting in Oracle r12 server.I have already set the class path for the jar file.
I am Using Java version is 1.6 and Apache axis2.1.6.2.
Had the same issue. I had included only jars that I needed to compile the application.
When I included everything from \axis2-1.6.2\lib\ folder, this exception were gone.
I had a similar problem using Tomcat and Axis2 and after a week finding out the error I realized there was a axis configuration problem. especifically my aplication can't instantiate the class which accedded to persistence layer. I include this parameter line:
<parameter name="ServiceTCCL">composite</parameter>
in services.xml file which is used by axis2 to work.
For more information see the comments in http://wso2.com/node/1131

Categories