Skip to main content

Maven fails when JAX-B annotated class in a different OSGi bundle

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
2 replies [Last post]
Ryuleonheart
Offline
Joined: 2011-08-12

Hi,

We develope a bottom-up JAX-WS web service. If it use JAX-B annotated class in the same bundle, then everything's fine as normal using jaxws-maven-plugin

If we put the JAX-B annotated class in different bundle and import them to the webservice bundle, then the webservice cannot be built anymore. Anyone experience with this before?

Error:

Problem encountered during annotation processing; 
see stacktrace below for more information.
java.lang.NullPointerException
<span class="Apple-tab-span" style="white-space:pre"> </span>at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.isLegalType(WebServiceVisitor.java:781)
<span class="Apple-tab-span" style="white-space:pre"> </span>at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.isLegalMethod(WebServiceVisitor.java:629)
<span class="Apple-tab-span" style="white-space:pre"> </span>at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.methodsAreLegal(WebServiceVisitor.java:586)
<span class="Apple-tab-span" style="white-space:pre"> </span>at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.isLegalSEI(WebServiceVisitor.java:578)
<span class="Apple-tab-span" style="white-space:pre"> </span>at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.shouldProcessWebService(WebServiceVisitor.java:311)
<span class="Apple-tab-span" style="white-space:pre"> </span>at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.visitInterfaceDeclaration(WebServiceVisitor.java:105)
<span class="Apple-tab-span" style="white-space:pre"> </span>at com.sun.tools.apt.mirror.declaration.InterfaceDeclarationImpl.accept(InterfaceDeclarationImpl.java:32)
<span class="Apple-tab-span" style="white-space:pre"> </span>at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.inspectEndpointInterface(WebServiceVisitor.java:406)
<span class="Apple-tab-span" style="white-space:pre"> </span>at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.visitClassDeclaration(WebServiceVisitor.java:139)
<span class="Apple-tab-span" style="white-space:pre"> </span>at com.sun.tools.apt.mirror.declaration.ClassDeclarationImpl.accept(ClassDeclarationImpl.java:95)
<span class="Apple-tab-span" style="white-space:pre"> </span>at com.sun.tools.ws.processor.modeler.annotation.WebServiceAP.buildModel(WebServiceAP.java:326)
<span class="Apple-tab-span" style="white-space:pre"> </span>at com.sun.tools.ws.processor.modeler.annotation.WebServiceAP.process(WebServiceAP.java:267)
<span class="Apple-tab-span" style="white-space:pre"> </span>at com.sun.mirror.apt.AnnotationProcessors$CompositeAnnotationProcessor.process(AnnotationProcessors.java:60)
<span class="Apple-tab-span" style="white-space:pre"> </span>at com.sun.tools.apt.comp.Apt.main(Apt.java:454)
<span class="Apple-tab-span" style="white-space:pre"> </span>at com.sun.tools.apt.main.JavaCompiler.compile(JavaCompiler.java:258)
<span class="Apple-tab-span" style="white-space:pre"> </span>at com.sun.tools.apt.main.Main.compile(Main.java:1102)
<span class="Apple-tab-span" style="white-space:pre"> </span>at com.sun.tools.apt.main.Main.compile(Main.java:964)
<span class="Apple-tab-span" style="white-space:pre"> </span>at com.sun.tools.apt.Main.processing(Main.java:95)
<span class="Apple-tab-span" style="white-space:pre"> </span>at com.sun.tools.apt.Main.process(Main.java:85)
<span class="Apple-tab-span" style="white-space:pre"> </span>at com.sun.tools.apt.Main.process(Main.java:67)
<span class="Apple-tab-span" style="white-space:pre"> </span>at com.sun.tools.ws.wscompile.WsgenTool.buildModel(WsgenTool.java:215)
<span class="Apple-tab-span" style="white-space:pre"> </span>at com.sun.tools.ws.wscompile.WsgenTool.run(WsgenTool.java:123)
<span class="Apple-tab-span" style="white-space:pre"> </span>at com.sun.tools.ws.WsGen.doMain(WsGen.java:69)
<span class="Apple-tab-span" style="white-space:pre"> </span>at org.codehaus.mojo.jaxws.AbstractWsGenMojo.execute(AbstractWsGenMojo.java:97)
<span class="Apple-tab-span" style="white-space:pre"> </span>at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
<span class="Apple-tab-span" style="white-space:pre"> </span>at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
<span class="Apple-tab-span" style="white-space:pre"> </span>at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
<span class="Apple-tab-span" style="white-space:pre"> </span>at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
<span class="Apple-tab-span" style="white-space:pre"> </span>at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
<span class="Apple-tab-span" style="white-space:pre"> </span>at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
<span class="Apple-tab-span" style="white-space:pre"> </span>at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
<span class="Apple-tab-span" style="white-space:pre"> </span>at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
<span class="Apple-tab-span" style="white-space:pre"> </span>at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
<span class="Apple-tab-span" style="white-space:pre"> </span>at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
<span class="Apple-tab-span" style="white-space:pre"> </span>at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
<span class="Apple-tab-span" style="white-space:pre"> </span>at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
<span class="Apple-tab-span" style="white-space:pre"> </span>at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
<span class="Apple-tab-span" style="white-space:pre"> </span>at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<span class="Apple-tab-span" style="white-space:pre"> </span>        at java.lang.reflect.Method.invoke(Method.java:597)
<span class="Apple-tab-span" style="white-space:pre"> </span>at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
<span class="Apple-tab-span" style="white-space:pre"> </span>at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
<span class="Apple-tab-span" style="white-space:pre"> </span>at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
<span class="Apple-tab-span" style="white-space:pre"> </span>at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
snajper
Offline
Joined: 2004-10-01

Hi,
jaxb uses different classloading mechanisms to find the classes, which
in general doesn't work under OSGi - the jaxb-api jar is not OSGi
friendly. You might be able to workaround this by providing your own
classloader to the jaxb calls (which would also have to make sure the
jdk internal classes are masked).
MartiNG

On 08/12/2011 12:04 PM, forums@java.net wrote:
> Hi,
>
> We develope a webservice. If it use JAX-B annotated class in the same
> bundle,
> then everything's fine as normal.
>
> If we put the JAX-B annotated class in different bundle and import
> them to
> the webservice bundle, then the webservice cannot be built anymore.
> Anyone
> experience with this before?
>
> *Maven dependency:*
>
> com.sun.xml.bind
> jaxb-impl 2.1.8
>
>
> *Error:*
>
> Problem encountered during annotation processing; see stacktrace below
> for
> more information. java.lang.NullPointerException at
> com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.isLegalType(WebServiceVisitor.java:781)
>
> at
> com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.isLegalMethod(WebServiceVisitor.java:629)
>
> at
> com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.methodsAreLegal(WebServiceVisitor.java:586)
>
> at
> com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.isLegalSEI(WebServiceVisitor.java:578)
>
> at
> com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.shouldProcessWebService(WebServiceVisitor.java:311)
>
> at
> com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.visitInterfaceDeclaration(WebServiceVisitor.java:105)
>
> at
> com.sun.tools.apt.mirror.declaration.InterfaceDeclarationImpl.accept(InterfaceDeclarationImpl.java:32)
>
> at
> com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.inspectEndpointInterface(WebServiceVisitor.java:406)
>
> at
> com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.visitClassDeclaration(WebServiceVisitor.java:139)
>
> at
> com.sun.tools.apt.mirror.declaration.ClassDeclarationImpl.accept(ClassDeclarationImpl.java:95)
>
> at
> com.sun.tools.ws.processor.modeler.annotation.WebServiceAP.buildModel(WebServiceAP.java:326)
>
> at
> com.sun.tools.ws.processor.modeler.annotation.WebServiceAP.process(WebServiceAP.java:267)
>
> at
> com.sun.mirror.apt.AnnotationProcessors$CompositeAnnotationProcessor.process(AnnotationProcessors.java:60)
>
> at com.sun.tools.apt.comp.Apt.main(Apt.java:454) at
> com.sun.tools.apt.main.JavaCompiler.compile(JavaCompiler.java:258) at
> com.sun.tools.apt.main.Main.compile(Main.java:1102) at
> com.sun.tools.apt.main.Main.compile(Main.java:964) at
> com.sun.tools.apt.Main.processing(Main.java:95) at
> com.sun.tools.apt.Main.process(Main.java:85) at
> com.sun.tools.apt.Main.process(Main.java:67) at
> com.sun.tools.ws.wscompile.WsgenTool.buildModel(WsgenTool.java:215) at
> com.sun.tools.ws.wscompile.WsgenTool.run(WsgenTool.java:123) at
> com.sun.tools.ws.WsGen.doMain(WsGen.java:69) at
> org.codehaus.mojo.jaxws.AbstractWsGenMojo.execute(AbstractWsGenMojo.java:97)
>
> at
> org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
>
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
>
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
>
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
>
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
>
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
>
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
>
> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328) at
> org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138) at
> org.apache.maven.cli.MavenCli.main(MavenCli.java:362) at
> org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60) at
>
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:597) at
> org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) at
> org.codehaus.classworlds.Launcher.launch(Launcher.java:255) at
> org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) at
> org.codehaus.classworlds.Launcher.main(Launcher.java:375)
>

Ryuleonheart
Offline
Joined: 2011-08-12

thank you snajper for your help,

I don't know how to build my own classloader..

this is an error at built time.. since we use the jaxws-maven-plugin to build the web service bundle automatically. The only way is to use Data transfer object, to get and set data. But it is dirty and inconvenient.

I wonder if Glassfish has another solution somewhere...