ClassNotFoundException axiom-api-1.2.7.jar

2019-07-15 19:42发布

问题:

I am getting this exception in my java project

Caused by: java.lang.ClassNotFoundException: org.apache.axiom.om.OMDataSource
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)

My classpath is

C:\axiom-impl-1.2.7.jar;C:\axiom-api-1.2.7.jar;C:\axiom-dom-1.2.7.jar;.;

Can you please help me out ?

回答1:

Set the environment variable CLASSPATH to include the path's to the jar. or use java -classpath <...>



回答2:

Finally managed to resolve this issue. The problem was that the jar had a manifest.mf file inside it which defined the classpath. I guess this takes priority over any env variable of the -classpath option in the java command in command prompt.

This is my manifest.mf file after changes Manifest-Version: 1.0 Ant-Version: Apache Ant 1.8.1 Created-By: 1.6.0_20-b02 (Sun Microsystems Inc.) Built-By: Arcot Main-Class: com.arcot.csso.credchangereportsvc.CredChangeReportSVC Version: 1.0 Class-Path: lib/classes lib/TPFService-XBeans-packaged.jar lib/TPFServ ice-client.jar lib/aspectjrt.jar lib/axis2-kernel-1.4.1.jar lib/commo ns-lang-2.5.jar lib/log4j-1.2.16.jar lib/ojdbc14-10.2.0.1.0.jar lib/x mlbeans-2.4.0.jar ./conf/ lib/axiom-api-1.2.7.jar lib/wsdl4j-1.6.2.jar lib/XmlSchema-1.4.2.jar lib/commons-logging-1.1.1.jar lib/commons-httpclient-3.1.jar lib/axiom-impl-1.2.7.jar lib/backport-util-concurrent-3.1.jar lib/neethi-2.0.4.jar lib/commons-codec-1.3.jar