2

I already have a C++ server containing a service that inserts an user to the DB, the service work's great when I test it on console.

But the fact is that I'm developing a Java client application that consumes the service with Apache Axis, unfortunately it doesn't works. I have been searching for information that could help me with this trouble but I don't see any similar implementation.

My Apache Axis files are in /usr/share/java, which is the value of my AXIS2_HOME variable, this, in order to execute:

java -cp $AXIS2_HOME org.apache.axis.wsdl.WSDL2Java -p CrearAlumno http://localhost/CrearAlumno.wsdl

to generate the files, later I execute:

javac -cp $AXIS2_HOME *.java

to compile my files Including the Client Class

//CrearAlumnoClient.java 

package CrearAlumno;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;

public class CrearAlumnoClient{

  public static void main(String[] args)
  {

    Input in = new Input("asdf", "adgfsdf", "asdg", 453, "asdf", "asdfasdf", "pasdfsd", "asdfsd");

    try{
    CrearAlumno_Service service = new CrearAlumno_ServiceLocator();
    CrearAlumnoPortType port = service.getCrearAlumno();
    String response = port.getInfo(in);
    }catch(RemoteException e){
      e.printStackTrace();
    }catch(ServiceException e){
    e.printStackTrace();
    }

  }
}

but when I excecute:

java CrearAlumno.CrearAlumnoClient

My application throws this errors:

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/rpc/ServiceException
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
    at java.lang.Class.getMethod0(Class.java:3018)
    at java.lang.Class.getMethod(Class.java:1784)
    at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: javax.xml.rpc.ServiceException
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 7 more

I have no idea how to solve this errors, I have been searching for an implementation but at this moment, I dont have it.

I will also be pleased if anyone can show me a simply implementation of Axis and gsoap.

Thank you for your attention :).

ALREy Max
  • 21
  • 1

1 Answers1

0

This looks like a simple case of your classpath not being set up correctly.

There's information on that specific topic here: http://axis.apache.org/axis/java/install.html#Classpath_setup

You need to ensure that the jar file containing javax.xml.rpc.ServiceException is present.

I see you are setting up your classpath using -cp $AXIS2_HOME which won't work. At best if your jars are in $AXIS2_HOME then you will need to do $AXIS2_HOME/*.jar but it all liklihood you'll need to have something more like:

set AXIS_HOME=/usr/axis
set AXIS_LIB=$AXIS_HOME/lib
set AXISCLASSPATH=$AXIS_LIB/axis.jar:$AXIS_LIB/commons-discovery.jar:
$AXIS_LIB/commons-logging.jar:$AXIS_LIB/jaxrpc.jar:$AXIS_LIB/saaj.jar:
$AXIS_LIB/log4j-1.2.8.jar:$AXIS_LIB/xml-apis.jar:$AXIS_LIB/xercesImpl.jar:
$AXIS_LIB/wsdl4j.jar
export AXIS_HOME; export AXIS_LIB; export AXISCLASSPATH

Then invoke your application with:

java -cp $AXISCLASSPATH

With regards to integration between Axis and Gsoap it really should be quite straightforward. There shouldn't really be any special interventions required because you're crossing between java and c world - at least for simple use-cases.

robert
  • 4,612
  • 2
  • 29
  • 39