Webb, Thanks for the tip. Your suggestion prompted me to write a quick test case to print out the ClassLoader hierarchy for the pertinent classes. The output is created by calling ClassLoader.getParent() in a loop. Here is the output:
Thread Classloader1: [EMAIL PROTECTED] Thread Classloader2: [EMAIL PROTECTED] Thread Classloader3: [EMAIL PROTECTED] Boot Classloader1: [EMAIL PROTECTED] Javac Classloader1: [ForeheadClassLoader: name="root"] Javac Classloader2: [ForeheadClassLoader: name="$forehead-root$"] Javac Classloader3: [EMAIL PROTECTED] Javac Classloader4: [EMAIL PROTECTED] Compiler Helper Classloader1: [EMAIL PROTECTED] Compiler Helper Classloader2: [EMAIL PROTECTED] Compiler Helper Classloader3: [EMAIL PROTECTED] In the JWSDP, there is a class called JavaCompilerHelper that uses the thread context ClassLoader to load "com.sun.tools.javac.Main". As you can see from the output above, "...javac.Main" is in a sibling ClassLoader of the AntClassLoader which is the thread context ClassLoader. Thus, I think the JWSDP ant tasks just can't see tools.jar because they are in a sibling ClassLoader, not a child one. So... 0. Am I missing something??? 1. Why is the AntClassLoader a sibling of the ForeheadClassLoader and not a child? Is there a way to change that? 2. How do I get tools.jar into the AntClassLoader? Thanks! John -----Original Message----- From: Webb Morris [mailto:[EMAIL PROTECTED] Sent: Monday, March 01, 2004 1:31 PM To: Maven Users List Subject: RE: NullPointerException Running JAX-RPC wscompile/wsdeploy AntTa s ks Have you tried stating the JWSDP jars as dependencies in your project.xml and specifing the classloader as root? I had to do this with some weblogic tasks (servicegen, in particular) in order to get ant to recognize them at runtime. WM --- "Shields, John (HQP)" <[EMAIL PROTECTED]> wrote: > Apparently the attachments didn't work. Here is the strange *.h file: > > /* DO NOT EDIT THIS FILE - it is machine generated */ > #include <jni.h> > /* Header for class com_sun_tools_javac_Main */ > > #ifndef _Included_com_sun_tools_javac_Main > #define _Included_com_sun_tools_javac_Main > #ifdef __cplusplus > extern "C" { > #endif > /* Inaccessible static: > class_00024com_00024sun_00024tools_00024javac_00024Main */ > #ifdef __cplusplus > } > #endif > #endif > > And maven.xml: > > > <project xmlns:j="jelly:core" xmlns:maven="jelly:maven" > xmlns:deploy="deploy" xmlns:ant="jelly:ant"> > > <!-- > This goal creates the JAX-RPC model and WSDL files and places them in > the expanded > build webapp directory. It runs after the war:webapp goal from the Maven > war plugin. > --> > <postGoal name="war:webapp"> > > <!-- define JAX-RPC ant task --> > <ant:taskdef name="wscompile" > classname="com.sun.xml.rpc.tools.ant.Wscompile"> > <ant:classpath> > <ant:path refid="maven.dependency.classpath"/> > </ant:classpath> > </ant:taskdef> > > <!-- loop through the resources in project.xml --> > <ant:echo message="resources=${pom.build.resources}"/> > <j:forEach var="resource" items="${pom.build.resources}"> > <j:set var="directory" value="${resource.directory}"/> > <ant:echo message="directory=${directory}"/> > > <!-- put XML files from the resource in the 'files' variable --> > <ant:fileScanner var="files"> > <ant:fileset dir="${directory}"> > <ant:patternset> > <ant:include name="*.xml"/> > </ant:patternset> > </ant:fileset> > </ant:fileScanner> > > <!-- loop the files from the resource --> > <j:forEach var="file" items="${files.iterator()}"> > <ant:echo message="file=${file}"/> > > <!-- parse out the model name from the config file name --> > <j:set var="model" > value="${file.name.substring(0,file.name.indexOf('.xml'))}-model.gz"/> > <ant:echo message="model=${model}"/> > <ant:mkdir dir="${maven.build.dir}/gen-model"/> > > <!-- generate the model and wsdl files for this config file --> > <ant:wscompile base="${maven.war.webapp.dir}/WEB-INF" define="true" > verbose="true" classpath="${maven.build.dest}" > model="${maven.war.webapp.dir}/WEB-INF/${model}" config="${file}"> > <ant:classpath> > <ant:pathelement path="${tools.jar}"/> > <ant:path refid="maven.dependency.classpath"/> > </ant:classpath> > </ant:wscompile> > </j:forEach> > > </j:forEach> > > </postGoal> > > <!-- > This goal creates the JAX-RPC implementation files. > It runs after the war:war goal from the Maven war plugin. > --> > <postGoal name="war:war"> > <!-- define JAX-RPC ant task --> > <ant:taskdef name="wsdeploy" > classname="com.sun.xml.rpc.tools.ant.Wsdeploy"> > <ant:classpath> > <ant:pathelement path="${tools.jar}"/> > <ant:path refid="maven.dependency.classpath"/> > </ant:classpath> > </ant:taskdef> > > <ant:mkdir dir="${maven.war.build.dir}/wsdeploy-generated"/> > <ant:move file="${maven.war.build.dir}/${pom.artifactId}.war" > tofile="${maven.war.build.dir}/${pom.artifactId}-portable.war"/> > > <ant:wsdeploy > inWarFile="${maven.war.build.dir}/${pom.artifactId}-portable.war" > outWarFile="${maven.war.build.dir}/${pom.artifactId}.war" > tmpDir="${maven.war.build.dir}/wsdeploy-generated" keep="true" > verbose="true"> > <ant:classpath> > <ant:pathelement path="${tools.jar}"/> > <ant:path refid="maven.dependency.classpath"/> > </ant:classpath> > </ant:wsdeploy> > <!-- this works!!! but it depends on installing the pack. grrr... > <ant:exec executable="c:/jwsdp-1.3/jaxrpc/bin/wsdeploy.bat"> > <arg line="-classpath 'C:\j2sdk1.4.2_03\lib\tools.jar;C:\Documents and > Settings\johshi01\.maven\repository\jaxrpc\jars\jaxrpc-api-1.1.jar;C:\Docume > nts and > Settings\johshi01\.maven\repository\jaxrpc\jars\jaxrpc-impl-1.1.jar;C:\Docum > ents and > Settings\johshi01\.maven\repository\jaxrpc\jars\jaxrpc-spi-1.1.jar;C:\Docume > nts and > Settings\johshi01\.maven\repository\jaxrpc\jars\jax-qname-1.1.jar;C:\Documen > ts and > Settings\johshi01\.maven\repository\saaj\jars\saaj-api-1.2.jar;C:\Documents > and > Settings\johshi01\.maven\repository\saaj\jars\saaj-impl-1.2.jar;C:\Documents > and > Settings\johshi01\.maven\repository\jaf\jars\activation-1.0.2.jar;C:\Documen > ts and > Settings\johshi01\.maven\repository\javamail\jars\mail-1.2.jar;C:\Documents > and > Settings\johshi01\.maven\repository\jaxrpc\jars\relaxngDatatype-1.1.jar;C:\D > ocuments and > Settings\johshi01\.maven\repository\jaxrpc\jars\xsdlib-1.1.jar;C:\Documents > and > Settings\johshi01\.maven\repository\xerces\jars\xmlParserAPIs-2.2.1.jar;C:\D > ocuments and > Settings\johshi01\.maven\repository\xerces\jars\xercesImpl-2.4.0.jar;C:\Docu > ments and Settings\johshi01\.maven\repository\xalan\jars\xalan-2.5.1.jar' > -keep -tmpdir C:\cvsroot\pmi\server\target\wsdeploy-generated -o > C:\cvsroot\pmi\server\target\pmi-server.war -verbose > C:\cvsroot\pmi\server\target\pmi-server-portable.war"/> > </ant:exec> > --> > </postGoal> > > </project> > > > > -----Original Message----- > From: Shields, John (HQP) [mailto:[EMAIL PROTECTED] > Sent: Friday, February 27, 2004 4:51 PM > To: '[EMAIL PROTECTED]' > Subject: NullPointerException Running JAX-RPC wscompile/wsdeploy AntTasks > > Hello, > > I keep receiving the following error when trying to run the JAX-RPC ant > tasks from within Maven. I just cannot seem to find the problem. I have a > suspicion that I'm in ClassLoader hell, but I'm not sure. I'm using JDK > 1.4.2_03, Maven-1.0-rc1, and JWSDP-1.3. > > The strangest thing is that if I change my maven.xml file to execute the > JWSDP-1.3 command line tools directly then everything works. However, I > would like to not have a dependency on the JWSDP tools if at all possible > (jar files are OK, of course). Another project at my company is using the > ant tasks successfully from ant, but they haven't tried it from Maven. > > Here is the pertinent part of the output from Maven with the "--debug > --exception" flags set: > > [wsdeploy] [DEBUG] Finding class com.sun.xml.rpc.util.JavaCompilerHelper > [wsdeploy] [DEBUG] Class com.sun.xml.rpc.util.JavaCompilerHelper loaded > from ant loader > [wsdeploy] [DEBUG] Class java.lang.NoSuchMethodException loaded from > parent loader > [wsdeploy] [DEBUG] Class java.lang.reflect.InvocationTargetException > loaded from parent loader > [wsdeploy] [DEBUG] Class java.io.PrintWriter loaded from parent loader > [wsdeploy] [DEBUG] Class java.lang.Thread loaded from parent loader > [wsdeploy] error: java.lang.NullPointerException > [wsdeploy] java.lang.NullPointerException > [wsdeploy] at > com.sun.xml.rpc.util.JavaCompilerHelper.internalCompile(JavaCompilerHelper.j > ava:45) > [wsdeploy] at > com.sun.xml.rpc.util.JavaCompilerHelper.compile(JavaCompilerHelper.java:32) > [wsdeploy] at > com.sun.xml.rpc.tools.wscompile.CompileTool.compileGeneratedClasses(CompileT > ool.java:876) > [wsdeploy] at > com.sun.xml.rpc.tools.wscompile.CompileTool.run(CompileTool.java:578) > [wsdeploy] at > com.sun.xml.rpc.tools.wsdeploy.DeployTool.process(DeployTool.java:303) > [wsdeploy] at > com.sun.xml.rpc.tools.wsdeploy.DeployTool.run(DeployTool.java:213) > [wsdeploy] at com.sun.xml.rpc.util.ToolBase.run(ToolBase.java:40) > [wsdeploy] at > com.sun.xml.rpc.tools.ant.Wsdeploy.execute(Wsdeploy.java:351) > [wsdeploy] at org.apache.tools.ant.Task.perform(Task.java:341) > [wsdeploy] at > org.apache.commons.jelly.tags.ant.AntTag.doTag(AntTag.java:232) > > From the source code provided for the JWSDP on http://www.java.net/ I > === message truncated === __________________________________ Do you Yahoo!? Get better spam protection with Yahoo! Mail. http://antispam.yahoo.com/tools --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
