axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rob Jellinghaus" <r...@nimblefish.com>
Subject java2wsdl ant task ignores its <classpath> tag
Date Wed, 14 Apr 2004 22:16:22 GMT
I am trying to get started with java2wsdl.  I am working with the EJB
sample in the latest Axis nightly CVS (the first 20040414 one).

As delivered, ws-axis/java/samples/ejb/ant-build.xml cannot actually run
the java2wsdl targets.  The README in that directory says to specify a
classpath which includes the compiled bean files.  I don’t understand
why the build.xml shouldn’t just build the bean files and then create a
classpath which references them.  So I have altered it as follows (look
for "ROBJ ADDITIONS"):

<?xml version="1.0" encoding="UTF-8"?>
<project name="Session Beans as Web Services" default="deployejb"
basedir=".">

<!-- ROBJ ADDITIONS -->
<path id="axis.classpath">
  <fileset dir="../../build/lib">
    <include name="*jar"/>
  </fileset>
  <pathelement location="${build.dir}"/>
</path>
<!-- ROBJ ADDITIONS -->

    <property environment="env"/>
    <property name="deploy.dir" value="${env.JBOSS_DEPLOY}"/>
    <property name="app.name" value="wsejbsample"/>
    <property name="build.dir" value="build"/>
    <property name="src.dir" value="src"/>
    <property name="metainf.dir" value="META-INF"/>

<!-- ROBJ ADDITIONS -->
<path id="axis.classpath">
  <fileset dir="../../build/lib">
    <include name="*jar"/>
  </fileset>
  <pathelement location="${build.dir}"/>
</path>
<!-- ROBJ ADDITIONS -->


<!-- ROBJ ADDITIONS: added classpathref here -->
    <taskdef resource="axis-tasks.properties"
classpathref="axis.classpath"/>
<!-- ROBJ ADDITIONS: added classpathref here -->

    <target name="prepare">
        <delete>
            <fileset dir="${basedir}" includes="*jar"/>
        </delete>
        <mkdir dir="${build.dir}"/>
    </target>

    <target name="compile" depends="prepare">
         <javac srcdir="${src.dir}" destdir="${build.dir}" debug="on"
nowarn="${nowarn}" 
                                    optimize="off" deprecation="off"/>
    </target>
    
    <target name="jar" depends="compile">
        <jar destfile="${app.name}.jar">
            <fileset dir="${build.dir}">
                <include name="**/*.class" />
            </fileset>
            <metainf dir="${metainf.dir}"/>
        </jar>	
    </target>
    
    <target name="deployejb" depends="jar">
        <copy file="${app.name}.jar" todir="${deploy.dir}"/>
    </target>
    
    <target name="deployws">
        <axis-admin xmlfile="deploy.wsdd"/>
    </target>
    
    <target name="undeployws">
        <axis-admin xmlfile="undeploy.wsdd"/>
    </target>
    
<!-- ROBJ ADDITIONS: added dependency here -->
    <target name="simplebean" depends="compile">
<!-- ROBJ ADDITIONS: added dependency here -->

        <axis-java2wsdl	classname="samples.ejb.SimpleBean"
			methods="sayHello"
                        output="simplebean.wsdl"
 
location="http://localhost:8080/axis/services/SimpleBean"
 
namespace="http://localhost:8080/axis/services/SimpleBean"
 
namespaceImpl="http://localhost:8080/axis/services/SimpleBean"> 

<!-- ROBJ ADDITIONS: added classpath here -->
		<classpath refid="axis.classpath"/>
<!-- ROBJ ADDITIONS: added classpath here -->

	  </axis-java2wsdl>

    </target>
    
<!-- ROBJ ADDITIONS: added dependency here -->
    <target name="nicethingsbean" depends="compile">
<!-- ROBJ ADDITIONS: added dependency here -->

        <axis-java2wsdl	classname="samples.ejb.NiceThingsBean"
	
methods="sayHello,findNiceThingsFor,updateNiceThingsFor"
                        output="nicethings.wsdl"
 
location="http://localhost:8080/axis/services/NiceThingsBean"
 
namespace="http://localhost:8080/axis/services/NiceThingsBean"
                        namespaceImpl=
 
"http://localhost:8080/axis/services/NiceThingsBean">

<!-- ROBJ ADDITIONS: added classpath here -->
            <classpath refid="axis.classpath"/>
<!-- ROBJ ADDITIONS: added classpath here -->

            <complextype classname="samples.ejb.NiceThings"
                         namespace="urn:NiceThingsBean"/>

<!-- You can also pass in another serializer/deserializer if you don't
want to use the default 
        BeanSerializerFactory for a particular complextype
 
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
 
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"  -->

        </axis-java2wsdl>  

    </target>        

</project>

However, this still fails.  When I run this (with -debug), it complains
as follows:

C:\download\ws-axis\java\samples\ejb>ant -debug -f ant-build.xml
nicethingsbean
...
[axis-java2wsdl]
:classpathC:\download\ws-axis\java\build\lib\axis-ant.jar;C:\download\ws
-axis\java\build\lib\axis.jar;C:\download\ws-axis\java\build\lib\commons
-discovery.jar;C:\download\ws-axis\java\build\lib\commons-logging.jar;C:
\download\ws-axis\java\build\lib\jaxrpc.jar;C:\download\ws-axis\java\bui
ld\lib\log4j-1.2.8.jar;C:\download\ws-axis\java\build\lib\saaj.jar;C:\do
wnload\ws-axis\java\build\lib\wsdl4j.jar;C:\download\ws-axis\java\sample
s\ejb\build
[axis-java2wsdl] Java2WSDL samples.ejb.NiceThingsBean
Finding class samples.ejb.NiceThingsBean
Loaded from C:\download\ws-axis\java\samples\ejb\build
samples/ejb/NiceThingsBean.class
Class java.lang.Object loaded from parent loader (parentFirst)
Class javax.ejb.EJBLocalObject loaded from parent loader (parentFirst)
Class samples.ejb.NiceThingsBean loaded from ant loader
[axis-java2wsdl] java.lang.ClassNotFoundException:
samples.ejb.NiceThings
[axis-java2wsdl]        at
java.net.URLClassLoader$1.run(URLClassLoader.java:199)
[axis-java2wsdl]        at
java.security.AccessController.doPrivileged(Native Method)
[axis-java2wsdl]        at
java.net.URLClassLoader.findClass(URLClassLoader.java:187)
[axis-java2wsdl]        at
java.lang.ClassLoader.loadClass(ClassLoader.java:289)
[axis-java2wsdl]        at
java.lang.ClassLoader.loadClass(ClassLoader.java:235)
[axis-java2wsdl]        at
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
[axis-java2wsdl]        at java.lang.Class.forName0(Native Method)
[axis-java2wsdl]        at java.lang.Class.forName(Class.java:141)
[axis-java2wsdl]        at
org.apache.axis.tools.ant.wsdl.ComplexType.register(ComplexType.java:52)
[axis-java2wsdl]        at
org.apache.axis.tools.ant.wsdl.Java2WsdlAntTask.execute(Java2WsdlAntTask
.java:206)

Note that ejb\build *is on* the classpath for the task.  But it still
fails to actually find the class, despite saying that it has
successfully loaded it!

The ONLY WAY to make this actually work is to do the following:

------------------------------------------
C:\download\ws-axis\java\samples\ejb>set CLASSPATH=build

C:\download\ws-axis\java\samples\ejb>ant -debug -f ant-build.xml
nicethingsbean
nicethingsbean:
... FAILS EXACTLY AS ABOVE ...

C:\download\ws-axis\java\samples\ejb>ant -debug -f ant-build.xml
nicethingsbean
nicethingsbean:fileset: Setup scanner in dir
C:\download\ws-axis\java\build\lib with patternSet{ includes: [*jar] e
xcludes: [] }
...
Finding class samples.ejb.NiceThings_Helper

BUILD SUCCESSFUL
Total time: 3 seconds
------------------------------------------

In other words, you have to run the target TWICE, *AFTER* you set the
environment CLASSPATH to the build directory.  The first time it builds
into the build directory, but then FAILS TO FIND THE CLASSES when it
runs the java2wsdl task.  The SECOND time, once the classes are *already
present*, it successfully finds the classes in the build directory.

In all cases, it never finds the classes from the <classpath> tag in the
build file itself.

I see no JIRA issue for this specific problem, so I will be posting one
imminently.  Please update me if there is something I am missing.

Cheers,
Rob







Mime
View raw message