简体   繁体   中英

Java2WSDL java.lang.ClassNotFoundException

I try to make WSDL with Axis Java2WSDL class, and get an error that my target class not found.

Here are the steps that I did:

I started with a tutorial from here: http://axis.apache.org/axis/java/user-guide.html#Step_2:_Create_WSDL_using_Java2WSDL

A. I added the path to the files

在此输入图像描述

to AXISCLASSPATH, and as well I added the path to the directory containing the files to the CLASSPATH var, so they look like

AXISCLASSPATH='C:\\Program Files\\Java\\axis'\\axis.jar;'C:\\Program Files\\Java\\axis'\\commons-discovery-0.2.jar;'C:\\Program Files\\Java\\axis'\\commons-loggin g.jar;'C:\\Program Files\\Java\\axis'\\jaxrpc.jar;'C:\\Program Files\\Java\\axis'\\saaj.jar;'C:\\Program Files\\Java\\axis'\\log4j-1.2.17.jar;'C:\\Program Files\\Java\\axis'\\xml-apis.jar;'C:\\Program Files\\Java\\axis'\\xercesImpl.jar;'C:\\Program Files\\Java\\axis'\\wsdl4j.jar

CLASSPATH=C:\\Program Files\\Java\\axis\\*;C:\\Dev\\webworkspace\\WSDLGENTEST\\src\\test\\*

  • i tried the path with no quotes, single and double quotes, to no effect.
  • C:\\Dev\\webworkspace\\WSDLGENTEST\\src\\test\\* - path to the working dir.

B. I created a sample interface I1

 package test; public interface I1 { public void f1(); } 

C. I built the interface and seen the I1.class file in

C:\\Dev\\webworkspace\\WSDLGENTEST\\src\\test\\

DI ran a command

 java org.apache.axis.wsdl.Java2WSDL -o wp.wsdl
 -l"http://localhost:8080/WSDLGENTEST/services/Greeting" 
 -n"urn:test" -p"test" "urn:test" test.I1

and got an error of

java.lang.ClassNotFoundException: test.I1 at java.net.URLClassLoader$1.run(Unknown Source) 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) at org.apache.axis.utils.ClassUtils$2.run(ClassUtils.java:187) at java.security.AccessController.doPrivileged(Native Method) at org.apache.axis.utils.ClassUtils.loadClass(ClassUtils.java:160) at org.apache.axis.utils.ClassUtils.forName(ClassUtils.java:100) at org.apache.axis.wsdl.fromJava.Emitter.setCls(Emitter.java:2079) at org.apache.axis.wsdl.Java2WSDL.run(Java2WSDL.java:584) at org.apache.axis.wsdl.Java2WSDL.main(Java2WSDL.java:682)

  • I tried to run it from the

C:\\Dev\\workworkspace\\test1\\bin\\test\\

and also from

C:\\Dev\\workworkspace\\test1\\bin\\

  • I tried to run with
 I1, test.I1, test/I1, ./test.I1, C:\\Dev\\workworkspace\\test1\\bin\\test\\test\\I1, C:\\Dev\\workworkspace\\test1\\bin\\test\\test.I1, 

params, always getting the same error. He just seems to be not able to locate the file.

  • I updated the classpath with all conceivable permutations of the path and *:

CLASSPATH=C:\\Program Files\\Java\\axis\\*;C:\\Dev\\webworkspace\\WSDLGENTEST\\src;C:\\Dev\\webworkspace\\WSDLGENTEST\\src\\*;C:\\Dev\\webworkspace\\WSDLGENTEST\\src\\test\\;C:\\Dev\\webworkspace\\WSDLGENTEST\\src\\test\\*;C:\\Dev\\webworkspace\\WSDLGENTEST\\src\\test\\I1.class

still thesame error.

E. I compiled and ran a sample java hello world class just to check the java and paths work - the helloworld class printed what it needed, but the Java2WSDL does not work.

C:\Dev\workworkspace\test1\bin>java -cp . test/c1 Picked up
_JAVA_OPTIONS: -Xmx512M 
ohoho

What can be done to overcome it?

Thanks.

Had the same issue then I appended my CLASSPATH (my classpath also target all the axis jars) with '.' the current directory.

CLASSPATH=.

Then this worked out:

"%javabin%\\java.exe" -cp %CLASSPATH% org.apache.axis.wsdl.Java2WSDL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM