Jersey WadlGeneratorTask error

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Jersey WadlGeneratorTask error

jason
Hi everyone,
I am trying to make an Ant task build a WADL file and apply xsl to it, but the WadlGeneratorTask is failing.
The error seems to stem from a null pointer exception in the JAXB ContextFinder.find method.
After spending several hours looking over everything, I cannot find the cause of this.
 
Below is my ant task and the error I receive.  Could anybody take a stab at what is going wrong?
Thanks.
Jason

    <target name="-post-compile">
        <echo message="JDO Enhancement"/>
        <path id="enhancer.classpath">
            <pathelement path="${javac.classpath}"/>
            <pathelement location="${build.classes.dir}"/>
        </path>
        <taskdef name="datanucleusenhancer" classpathref="enhancer.classpath" classname="org.datanucleus.enhancer.tools.EnhancerTask" />
        <datanucleusenhancer classpathref="enhancer.classpath" />
        <echo message="WADL Generation"/>
        <path id="wadl.classpath">
            <pathelement path="${javac.classpath}"/>
            <pathelement location="${build.classes.dir}"/>
        </path>
        <taskdef name="generatewadl" classpathref="wadl.classpath" classname="com.sun.jersey.api.wadl.WadlGeneratorTask" />
        <generatewadl classpathref="wadl.classpath" destfile="${webinf.dir}/wadl.xml" baseUri="http://www.whatever.com" />
        <echo message="WADL XSL Transformation"/>
        <xslt in="${webinf.dir}/wadl.xml"  style="${webinf.dir}/wadl.xsl" out="${webinf.dir}/doc.html">
            <outputproperty name="method" value="xml"/>
            <outputproperty name="standalone" value="yes"/>
            <outputproperty name="encoding" value="iso8859_1"/>
            <outputproperty name="indent" value="yes"/>
        </xslt>
    </target>
 
 
 
 
WADL Generation
build.xml:41:
java.lang.NullPointerException
        at javax.xml.bind.ContextFinder.find(ContextFinder.java:275)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:337)
        at com.sun.jersey.api.wadl.WadlGeneratorTask.execute(WadlGeneratorTask.java:142)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.GeneratedMethodAccessor52.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:390)
        at org.apache.tools.ant.Target.performTasks(Target.java:411)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1397)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1366)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1249)
        at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:281)
        at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:539)
        at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:154)
BUILD FAILED (total time: 7 seconds)

Reply | Threaded
Open this post in threaded view
|

Re: Jersey WadlGeneratorTask error

Pavel Bucek-2
Hello Jason,

can you print out $wadl.classpath? You need to be sure that jersey-server module is no classpath and I suspect it isn't..

Pavel

On 4/18/11 8:52 AM, jason calton wrote:
Hi everyone,
I am trying to make an Ant task build a WADL file and apply xsl to it, but the WadlGeneratorTask is failing.
The error seems to stem from a null pointer exception in the JAXB ContextFinder.find method.
After spending several hours looking over everything, I cannot find the cause of this.
 
Below is my ant task and the error I receive.  Could anybody take a stab at what is going wrong?
Thanks.
Jason

    <target name="-post-compile">
        <echo message="JDO Enhancement"/>
        <path id="enhancer.classpath">
            <pathelement path="${javac.classpath}"/>
            <pathelement location="${build.classes.dir}"/>
        </path>
        <taskdef name="datanucleusenhancer" classpathref="enhancer.classpath" classname="org.datanucleus.enhancer.tools.EnhancerTask" />
        <datanucleusenhancer classpathref="enhancer.classpath" />
        <echo message="WADL Generation"/>
        <path id="wadl.classpath">
            <pathelement path="${javac.classpath}"/>
            <pathelement location="${build.classes.dir}"/>
        </path>
        <taskdef name="generatewadl" classpathref="wadl.classpath" classname="com.sun.jersey.api.wadl.WadlGeneratorTask" />
        <generatewadl classpathref="wadl.classpath" destfile="${webinf.dir}/wadl.xml" baseUri="http://www.whatever.com" />
        <echo message="WADL XSL Transformation"/>
        <xslt in="${webinf.dir}/wadl.xml"  style="${webinf.dir}/wadl.xsl" out="${webinf.dir}/doc.html">
            <outputproperty name="method" value="xml"/>
            <outputproperty name="standalone" value="yes"/>
            <outputproperty name="encoding" value="iso8859_1"/>
            <outputproperty name="indent" value="yes"/>
        </xslt>
    </target>
 
 
 
 
WADL Generation
build.xml:41:
java.lang.NullPointerException
        at javax.xml.bind.ContextFinder.find(ContextFinder.java:275)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:337)
        at com.sun.jersey.api.wadl.WadlGeneratorTask.execute(WadlGeneratorTask.java:142)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.GeneratedMethodAccessor52.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:390)
        at org.apache.tools.ant.Target.performTasks(Target.java:411)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1397)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1366)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1249)
        at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:281)
        at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:539)
        at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:154)
BUILD FAILED (total time: 7 seconds)


Reply | Threaded
Open this post in threaded view
|

Re: Jersey WadlGeneratorTask error

jason
Pavel,
Thanks for your response.  Printing my wadl classpath returns this:

Classpath = C:\Users\Jason\Documents\NetBeansProjects\inni-api\lib\asm-3.3.1.jar;C:\Users\Jason\Documents\NetBeansProjects\inni-api\lib\datanucleus-core-2.2.2.jar;C:\Users\Jason\Documents\NetBeansProjects\inni-api\lib\datanucleus-enhancer-2.1.3.jar;C:\Users\Jason\Documents\NetBeansProjects\inni-api\lib\datanucleus-rdbms-2.2.2.jar;C:\Users\Jason\Documents\NetBeansProjects\inni-api\lib\hibernate-validator-4.1.0.Final.jar;C:\Users\Jason\Documents\NetBeansProjects\inni-api\lib\jdo-api-3.0.jar;C:\Users\Jason\Documents\NetBeansProjects\inni-api\lib\jersey-client-1.6.jar;C:\Users\Jason\Documents\NetBeansProjects\inni-api\lib\jersey-core-1.6.jar;C:\Users\Jason\Documents\NetBeansProjects\inni-api\lib\jersey-json-1.6.jar;C:\Users\Jason\Documents\NetBeansProjects\inni-api\lib\jersey-server-1.6.jar;C:\Users\Jason\Documents\NetBeansProjects\inni-api\lib\jsr311-api-1.1.1.jar;C:\Users\Jason\Documents\NetBeansProjects\inni-api\lib\log4j-1.2.14.jar;C:\Users\Jason\Documents\NetBeansProjects\inni-api\lib\mysql-connector-java-5.1.15-bin.jar;C:\Users\Jason\Documents\NetBeansProjects\inni-api\lib\slf4j-api-1.5.6.jar;C:\Users\Jason\Documents\NetBeansProjects\inni-api\lib\slf4j-log4j12-1.5.6.jar;C:\Users\Jason\Documents\NetBeansProjects\inni-api\lib\validation-api-1.0.0.GA.jar;C:\Users\Jason\Documents\NetBeansProjects\inni-api\src\java


I am not sure what you meant about the jersey-server module, should it be in the classpath or not?

Thanks.
Jason
Reply | Threaded
Open this post in threaded view
|

Re: Jersey WadlGeneratorTask error

jason
Pavel,
Not sure if it matters but I also do not currently have application-doc.xml or application-grammars.xml files and my web.xml includes this:

    <servlet>
        <servlet-name>jersey</servlet-name>
        <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>
                com.inni.rest,
                com.inni.rest.natural.physical.temporal,
                com.inni.rest.social.anthropological,
                com.inni.rest.social.communicative,
                com.inni.rest.social.economic,
                com.inni.rest.social.political
            </param-value>
        </init-param>
        <init-param>
            <param-name>com.sun.jersey.config.feature.DisableWADL</param-name>
            <param-value>false</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>jersey</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>



I am using netbeans and it provides a rest-build.xml file that appears to generate a class that extends the jsx-rs application class.

Again, just thought I'd include these points in case it mattered.

Thanks.
Jason
Reply | Threaded
Open this post in threaded view
|

Re: Jersey WadlGeneratorTask error

Pavel Bucek-2
Hello,

Neither Application class nor web.xml should be important for ant task,
WADL is generated from classpath (using ClasspathResourceConfig). So
please make sure it is on classpath (it looks like it is not, I can see
only "C:\Users\Jason\Documents\NetBeansProjects\inni-api\src\java" but
nothing like "C:\Users\Jason\Documents\NetBeansProjects\inni-api\build\".

Please let me know whether adding built classes solved your issue. If
not, can you please share your project (or extract reproducible
testcase)? You can send it to me privately if you don't want to share
your code with mailing list.

Pavel

On 4/19/11 12:03 AM, jason wrote:

> Pavel,
> Not sure if it matters but I also do not currently have application-doc.xml
> or application-grammars.xml files and my web.xml includes this:
>
>      <servlet>
>          <servlet-name>jersey</servlet-name>
>
> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
>          <init-param>
>              <param-name>com.sun.jersey.config.property.packages</param-name>
>              <param-value>
>                  com.inni.rest,
>                  com.inni.rest.natural.physical.temporal,
>                  com.inni.rest.social.anthropological,
>                  com.inni.rest.social.communicative,
>                  com.inni.rest.social.economic,
>                  com.inni.rest.social.political
>              </param-value>
>          </init-param>
>          <init-param>
>
> <param-name>com.sun.jersey.config.feature.DisableWADL</param-name>
>              <param-value>false</param-value>
>          </init-param>
>          <load-on-startup>1</load-on-startup>
>      </servlet>
>      <servlet-mapping>
>          <servlet-name>jersey</servlet-name>
>          <url-pattern>/*</url-pattern>
>      </servlet-mapping>
>
>
>
> I am using netbeans and it provides a rest-build.xml file that appears to
> generate a class that extends the jsx-rs application class.
>
> Again, just thought I'd include these points in case it mattered.
>
> Thanks.
> Jason
>
> --
> View this message in context: http://jersey.576304.n2.nabble.com/Jersey-WadlGeneratorTask-error-tp6282612p6285337.html
> Sent from the Jersey mailing list archive at Nabble.com.
>

Reply | Threaded
Open this post in threaded view
|

Re: Jersey WadlGeneratorTask error

jason
Thanks Pavel,
I sent you a PM with my code.  I appreciate your help.

Jason



Pavel Bucek-2 wrote
Hello,

Neither Application class nor web.xml should be important for ant task,
WADL is generated from classpath (using ClasspathResourceConfig). So
please make sure it is on classpath (it looks like it is not, I can see
only "C:\Users\Jason\Documents\NetBeansProjects\inni-api\src\java" but
nothing like "C:\Users\Jason\Documents\NetBeansProjects\inni-api\build\".

Please let me know whether adding built classes solved your issue. If
not, can you please share your project (or extract reproducible
testcase)? You can send it to me privately if you don't want to share
your code with mailing list.

Pavel

On 4/19/11 12:03 AM, jason wrote:
> Pavel,
> Not sure if it matters but I also do not currently have application-doc.xml
> or application-grammars.xml files and my web.xml includes this:
>
>      <servlet>
>          <servlet-name>jersey</servlet-name>
>
> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
>          <init-param>
>              <param-name>com.sun.jersey.config.property.packages</param-name>
>              <param-value>
>                  com.inni.rest,
>                  com.inni.rest.natural.physical.temporal,
>                  com.inni.rest.social.anthropological,
>                  com.inni.rest.social.communicative,
>                  com.inni.rest.social.economic,
>                  com.inni.rest.social.political
>              </param-value>
>          </init-param>
>          <init-param>
>
> <param-name>com.sun.jersey.config.feature.DisableWADL</param-name>
>              <param-value>false</param-value>
>          </init-param>
>          <load-on-startup>1</load-on-startup>
>      </servlet>
>      <servlet-mapping>
>          <servlet-name>jersey</servlet-name>
>          <url-pattern>/*</url-pattern>
>      </servlet-mapping>
>
>
>
> I am using netbeans and it provides a rest-build.xml file that appears to
> generate a class that extends the jsx-rs application class.
>
> Again, just thought I'd include these points in case it mattered.
>
> Thanks.
> Jason
>
> --
> View this message in context: http://jersey.576304.n2.nabble.com/Jersey-WadlGeneratorTask-error-tp6282612p6285337.html
> Sent from the Jersey mailing list archive at Nabble.com.
>