File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Axis 2 tutorial - client class compliation error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Axis 2 tutorial - client class compliation error" Watch "Axis 2 tutorial - client class compliation error" New topic
Author

Axis 2 tutorial - client class compliation error

Ben Linus
Greenhorn

Joined: Mar 02, 2010
Posts: 15

Hi All,

I'm new to web services so I've been trying out the following APACHE AXIS 2 tutorial:

http://www.roseindia.net/webservices/axis2/apache-axis2-hello-world.shtml

I have managed to setup the environment (Axis 2 is running via Tomcat servlet container), create and deploy the web service etc.

However, when it came to testing the web service using a simple client class (the last stage)...

(instructions from tutorial..)
/**
*Now go to E:\Axis2Tutorial\Examples\HelloWorld\client\client\src directory and with the help of javac command compile the code.
*E:\Axis2Tutorial\Examples\HelloWorld\client\client\src>javac net/roseindia/*.java
**/

I get the following compliation errors:

package javax.xml.stream does not exist
package org.apache.axis2.client does not exist
package org.apache.axis2.addressing does not exist
package org.apache.axiom.soap does not exist
package org.apache.axis2.context does not exist
package org.apache.axis2.client does not exist
package org.apache.axis2.description does not exist


I'm assuming I have missing libraries, if so what can I do? and where can I get them?

I have checked that the environment variables are set up correctly for AXIS2_HOME and JAVA_HOME

I'm using JDK1.6 and axis2-1.5.1


Thanks,

Ben
Shinelin Samuel
Ranch Hand

Joined: Mar 01, 2010
Posts: 55
Hi,

double check if you have configured the build path to the 'axis2-1.5.1' library.

- Shinelin
Ben Linus
Greenhorn

Joined: Mar 02, 2010
Posts: 15
Shinelin,

Thanks for replying,

This is the Auto generated ant build file.

I have set AXIS2_HOME env variable to C:\axis2-1.5.1-bin\axis2-1.5.1 (this folder contains the lib folder)

Kevin Eddy
Ranch Hand

Joined: Feb 24, 2010
Posts: 74
Add "%AXIS2_HOME%\bin" to the PATH environment variable
for windows.
Kevin Eddy
Ranch Hand

Joined: Feb 24, 2010
Posts: 74
That is to say, You've made a system variable called AXIS2_HOME , now add it to the PATH. The PATH is a system variable that should exist in the same area as where you added AXIS2_HOME.

hope that helps
Ben Linus
Greenhorn

Joined: Mar 02, 2010
Posts: 15
Hi Kevin,

I have already added "%AXIS2_HOME%\bin" in PATH system variable.

This was part 1 of the tutorial.

I'm thinking, maybe the variables are set correctly but i'm missing certain libraries?

For example from two of the errors...,

package javax.xml.stream does not exist - is this a missing java lib??
package org.apache.axis2.client does not exist - is this a missing axis2 lib??

Kevin Eddy
Ranch Hand

Joined: Feb 24, 2010
Posts: 74
Maybe try redownloading the axis2 stuff from here http://ws.apache.org/axis2/download/1_5_1/download.cgi
Kevin Eddy
Ranch Hand

Joined: Feb 24, 2010
Posts: 74
I'm probably annoying you at this point, but is the axis2.war file in Tomcat\webapps directory?
Kevin Eddy
Ranch Hand

Joined: Feb 24, 2010
Posts: 74
Ben Linus wrote:Hi Kevin,

I have already added "%AXIS2_HOME%\bin" in PATH system variable.

This was part 1 of the tutorial.

I'm thinking, maybe the variables are set correctly but i'm missing certain libraries?

For example from two of the errors...,

package javax.xml.stream does not exist - is this a missing java lib??
package org.apache.axis2.client does not exist - is this a missing axis2 lib??



Okay, the javax.xml.stream seems to be in jsr173_1.0_api.jar
org.apache.axis2.client seems to exist in axis2-kernel-1.5.jar

you should have those jar files in your axis2-1.5\lib directory
Ben Linus
Greenhorn

Joined: Mar 02, 2010
Posts: 15
1) I just downloaded the file again, it contains the same libs etc etc.

2) yes the .war is in the Tomcat\webapps directory and it works because the web service is running fine, i'm having problems with compiling the client class

3)you're NOT annoying!! you're really helping...alot!!!
Shinelin Samuel
Ranch Hand

Joined: Mar 01, 2010
Posts: 55
Did you restart your PC after setting the environment variable? I had a problem with this once.
Ben Linus
Greenhorn

Joined: Mar 02, 2010
Posts: 15
Kevin,

I just checked the .jars in axis2\lib

i have axis2-kernel-1.5.jar - (so, now i'm really confused to why its not reading that package!)

but i dont have jsr173_1.0_api.jar - (this isn't in the axis\lib directory)

Shinelin,

yes i have tried that
Ben Linus
Greenhorn

Joined: Mar 02, 2010
Posts: 15
I know this is a lot to ask, but can someone try the tutorial?

there are only two parts and the first part is setting up tomcat, axis and the env variables (which you have probably already done)
Ben Linus
Greenhorn

Joined: Mar 02, 2010
Posts: 15
Kevin,

just curious, but how did you work out where to find the libraries?

Kevin Eddy
Ranch Hand

Joined: Feb 24, 2010
Posts: 74
Ben Linus wrote:Kevin,

just curious, but how did you work out where to find the libraries?



I browsed around in the axis2 folder found the lib directory, saw the jar's and it was a combination of googling the packages you were missing and trial and error on opening up the jars with 7zip and browsing through the directories (packages) until I found where they were.

Sadly, I haven't had a lot of luck going through online java tutorials regarding web services of any kind, be it axis2 or jaxws. I'm currently going through the axis tutorial and am having problems making it through that. Axis seems to be completely different than Axis2. I know what a pain the tutorials can be.
Kevin Eddy
Ranch Hand

Joined: Feb 24, 2010
Posts: 74
Ben Linus wrote:Kevin,

I just checked the .jars in axis2\lib

i have axis2-kernel-1.5.jar - (so, now i'm really confused to why its not reading that package!)

but i dont have jsr173_1.0_api.jar - (this isn't in the axis\lib directory)

Shinelin,

yes i have tried that


try getting the jsr173_1.0_api.jar from here: http://www.findjar.com/jar/xmlbeans/jars/jsr173_1.0_api.jar.html
OR
It's part of the xmlBeans download which you can find here http://apache.mirrors.timporter.net/xmlbeans/binaries/
in that page is xmlbeans-2.5.0.zip
that's what I downloaded.
I used 7zip to open up the zip file and found it in the lib directory.
Ben Linus
Greenhorn

Joined: Mar 02, 2010
Posts: 15
Thanks for your help so far

I've added those jars, but hasn't helped.

I thought maybe i've missed a step in the tutorial, so I started again from scratch, but its the same!

I might have to find a different Axis2 tutorial.

Ben
Ben Linus
Greenhorn

Joined: Mar 02, 2010
Posts: 15
Does anyone know of an Axis 2 tutorial that they have actually used (one that works) ??
Kevin Eddy
Ranch Hand

Joined: Feb 24, 2010
Posts: 74
What IDE are you using?
Ben Linus
Greenhorn

Joined: Mar 02, 2010
Posts: 15
I'm not using one, the point of the tutorial is to understand the workings and deployment of services and client.
compiling classes using javac cmd
yann bajard
Greenhorn

Joined: Mar 17, 2010
Posts: 2
hi,

I was stuck on the same problem, and i fix it !
The classs org.apache.axis2.client is under axis2-1.5.1/bin/lib/axis2-kernel-1.5.1.jar.

The problem is you have to specify the classpath during the compilation and the execution (even if you set environment variables):
javac -extdirs ~/axis2-1.5.1-bin/lib/ net/roseindia/*.java
and
java -classpath axis2-1.5.1/bin/lib/axis2-kernel-1.5.1.jar [and all your jars] net/roseindia/Test

Hope that helps !
Ben Linus
Greenhorn

Joined: Mar 02, 2010
Posts: 15
Hi Yann,

With your help, I used javac -extdirs and my cilent classes have now complied! thanks

but when i execute the Test.java i get the following error...

D:\Axis 2 Tutorial\Examples\HelloWorld\client\client\src>java -classpath D:\Axis 2
Tutorial/axis2-1.5.1-bin/axis2-1.5.1/lib net/roseindia/Test

Exception in thread "main" java.lang.NoClassDefFoundError: 2
Caused by: java.lang.ClassNotFoundException: 2
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)
Could not find the main class: 2. Program will exit.


Any Ideas where i have made a mistake?


yann bajard
Greenhorn

Joined: Mar 17, 2010
Posts: 2
hi ben linus,

You have to specify the jars files in the -classpath option (all the jars located in Axis2-1.5.1-bin directory) and not the directory.

java -classpath D:\Axis 2Tutorial/axis2-1.5.1-bin/axis2-1.5.1/lib/axis2-adb-1.5.1.jar:\Axis 2Tutorial/axis2-1.5.1-bin/axis2-1.5.1/lib/axis2-adb-codegen-1.5.1.jar.... net/roseindia/Test

(i don't remember if the seperator between jar files is ':' or something else ! )


I guess, with -classpath option, if you specify a directory, the jvm is looking for .class files and not jars ???

flamingo dcdt
Greenhorn

Joined: Sep 23, 2010
Posts: 2
yann bajard wrote:hi ben linus,

You have to specify the jars files in the -classpath option (all the jars located in Axis2-1.5.1-bin directory) and not the directory.

java -classpath D:\Axis 2Tutorial/axis2-1.5.1-bin/axis2-1.5.1/lib/axis2-adb-1.5.1.jar:\Axis 2Tutorial/axis2-1.5.1-bin/axis2-1.5.1/lib/axis2-adb-codegen-1.5.1.jar.... net/roseindia/Test

(i don't remember if the seperator between jar files is ':' or something else ! )


I guess, with -classpath option, if you specify a directory, the jvm is looking for .class files and not jars ???




hi Yann,

i have also faced the same issue. I resolved the compilation error as given above.

But now am unable to run the Test client. Tried incluing jars as well. but still the same error.


D:\Axis2Tutorial\Examples\HelloWorld\client\client\src>java net\roseindia\Test
Exception in thread "main" java.lang.NoClassDefFoundError: net\roseindia\Test
Caused by: java.lang.ClassNotFoundException: net\roseindia\Test
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 java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: net\roseindia\Test. Program will exit.

Can you please help me in this.
Ravinderjit Singh
Ranch Hand

Joined: Jan 13, 2010
Posts: 78
Hi Flamingo,

Can you try this way?

java -Djava.ext.dirs=..\path_to_axis2_lib -cp ..build\classes net.roseindia.Test
flamingo dcdt
Greenhorn

Joined: Sep 23, 2010
Posts: 2
Ravinderjit Singh wrote:Hi Flamingo,

Can you try this way?

java -Djava.ext.dirs=..\path_to_axis2_lib -cp ..build\classes net.roseindia.Test


Hi,

I have tried using alone

java -Djava.ext.dirs=..\path_to_axis2_lib net.roseindia.Test

The above didnt work.

Which path i have to take for

-cp ..build\classes
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 577

Hi Flamingo,

Hope you have set your classpath to your current directory before running your compiled java class.

SET CLASSPATH=%CLASSPATH%;.

I think we have not been too much dragged out of Web Services to Java . Like Ivan said, atleast I mentioned the name .


Cheers,
Naren
(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 577

Hi Flamingo,

Hope you have set your classpath to your current directory before running your compiled java class.

SET CLASSPATH=%CLASSPATH%;.

I think we have not been too much dragged out of Web Services to Java . Like Ivan said, atleast I mentioned the name .
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Axis 2 tutorial - client class compliation error