Skip to main content

@SchemaValidation NullPointerException

3 replies [Last post]
pavol_v
Offline
Joined: 2008-02-20
Points: 0

Hello,
I have problem with my web service. When I use @SchemaValidation and specify wsdlLocation in @WebService anotation, exeption (see below) is thrown when I try to start it. In my own wsdl I import external xsd schema.
wsdl part:
<?xml version="1.0" encoding="utf-8"?>

....
xsd file start:
<?xml version="1.0" encoding="UTF-8"?>

...

Seems like naming of xsd and wsdl file is issue or something platform specific. For certain names it was ok (e.g. mosolf.wsdl and atnInterface.xsd) but for some (with same content) it failed (e.g. mosolf_gen.wsdl and atnInterface_gen.xsd) . On another machine it failed also for the first pair of names. When I copied schema content into wsdl it was also OK.
I tried to debug it little, and problem seemed to be order of loading schema documents inside xerxes (there was 2, from wsdl:types and external xsd file).

Is there any way to ensure correct behavior while using schema import in wsdl?

java version: 1.6.0_04-b12, metro version: 1.1
thrown exeption:
java.lang.NullPointerException
at com.sun.xml.ws.server.ServerSchemaValidationTube$MetadataResolverImpl$1.getByteStream(ServerSchemaValidationTube.java:156)
at com.sun.org.apache.xerces.internal.util.DOMEntityResolverWrapper.resolveEntity(DOMEntityResolverWrapper.java:124)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.resolveEntity(XMLEntityManager.java:1100)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.resolveDocument(XMLSchemaLoader.java:595)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.resolveSchema(XSDHandler.java:1671)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.constructTrees(XSDHandler.java:909)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:569)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:552)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:519)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:485)
at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema(XMLSchemaFactory.java:210)
at com.sun.xml.ws.server.ServerSchemaValidationTube.(ServerSchemaValidationTube.java:67)
at com.sun.xml.ws.api.pipe.ServerTubeAssemblerContext.createValidationTube(ServerTubeAssemblerContext.java:212)
at com.sun.xml.ws.api.pipe.ServerPipeAssemblerContext.createValidationPipe(ServerPipeAssemblerContext.java:96)
at com.sun.xml.ws.assembler.PipelineAssemblerFactoryImpl$WsitPipelineAssembler.createServer(PipelineAssemblerFactoryImpl.java:305)
at com.sun.xml.ws.api.pipe.TubelineAssemblerFactory$TubelineAssemblerAdapter.createServer(TubelineAssemblerFactory.java:140)
at com.sun.xml.ws.server.WSEndpointImpl.(WSEndpointImpl.java:152)
at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:217)
at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:467)
at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:486)
at com.sun.xml.ws.transport.http.server.EndpointImpl.createEndpoint(EndpointImpl.java:222)
at com.sun.xml.ws.transport.http.server.EndpointImpl.publish(EndpointImpl.java:152)
at com.sun.xml.ws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:113)
at javax.xml.ws.Endpoint.publish(Endpoint.java:170)
... myApp stack...

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Jitendra Kotamraju

Can you file a bug with a sample test case(reproducible will be better).
Since you are using Endpoint.publish(), I would like to how you are
passing WSDL, and Schema metadata. You should be using
Endpoint.setMetadata(...) to pass the schema documents.

Jitu

metro@javadesktop.org wrote:
> Hello,
> I have problem with my web service. When I use @SchemaValidation and specify wsdlLocation in @WebService anotation, exeption (see below) is thrown when I try to start it. In my own wsdl I import external xsd schema.
> wsdl part:
>
> > xmlns:tns="http://ws.myApp/"
> xmlns:mod="http://model.myApp/"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> name="MosolfCommunicationService"
> targetNamespace="http://ws.myApp/">
>
>
>
> > schemaLocation="atnInterface.xsd">
>

>

>

> ....
> xsd file start:
>
> > xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified" version="1.0"
> targetNamespace="http://model.myApp/">
> ...
>
> Seems like naming of xsd and wsdl file is issue or something platform specific. For certain names it was ok (e.g. mosolf.wsdl and atnInterface.xsd) but for some (with same content) it failed (e.g. mosolf_gen.wsdl and atnInterface_gen.xsd) . On another machine it failed also for the first pair of names. When I copied schema content into wsdl it was also OK.
> I tried to debug it little, and problem seemed to be order of loading schema documents inside xerxes (there was 2, from wsdl:types and external xsd file).
>
> Is there any way to ensure correct behavior while using schema import in wsdl?
>
> java version: 1.6.0_04-b12, metro version: 1.1
> thrown exeption:
> java.lang.NullPointerException
> at com.sun.xml.ws.server.ServerSchemaValidationTube$MetadataResolverImpl$1.getByteStream(ServerSchemaValidationTube.java:156)
> at com.sun.org.apache.xerces.internal.util.DOMEntityResolverWrapper.resolveEntity(DOMEntityResolverWrapper.java:124)
> at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.resolveEntity(XMLEntityManager.java:1100)
> at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.resolveDocument(XMLSchemaLoader.java:595)
> at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.resolveSchema(XSDHandler.java:1671)
> at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.constructTrees(XSDHandler.java:909)
> at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:569)
> at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:552)
> at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:519)
> at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:485)
> at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema(XMLSchemaFactory.java:210)
> at com.sun.xml.ws.server.ServerSchemaValidationTube.(ServerSchemaValidationTube.java:67)
> at com.sun.xml.ws.api.pipe.ServerTubeAssemblerContext.createValidationTube(ServerTubeAssemblerContext.java:212)
> at com.sun.xml.ws.api.pipe.ServerPipeAssemblerContext.createValidationPipe(ServerPipeAssemblerContext.java:96)
> at com.sun.xml.ws.assembler.PipelineAssemblerFactoryImpl$WsitPipelineAssembler.createServer(PipelineAssemblerFactoryImpl.java:305)
> at com.sun.xml.ws.api.pipe.TubelineAssemblerFactory$TubelineAssemblerAdapter.createServer(TubelineAssemblerFactory.java:140)
> at com.sun.xml.ws.server.WSEndpointImpl.(WSEndpointImpl.java:152)
> at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:217)
> at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:467)
> at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:486)
> at com.sun.xml.ws.transport.http.server.EndpointImpl.createEndpoint(EndpointImpl.java:222)
> at com.sun.xml.ws.transport.http.server.EndpointImpl.publish(EndpointImpl.java:152)
> at com.sun.xml.ws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:113)
> at javax.xml.ws.Endpoint.publish(Endpoint.java:170)
> ... myApp stack...
> [Message sent by forum member 'pavol_v' (pavol_v)]
>
> http://forums.java.net/jive/thread.jspa?messageID=259993
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
> For additional commands, e-mail: users-help@metro.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
For additional commands, e-mail: users-help@metro.dev.java.net

Jitendra Kotamraju

* You can set the metadata as follows(You need to create list of Source
with proper systemIds):
for e.g:

Endpoint endpoint = Endpoint.create(..);
List metadata = new ArrayList();
ClassLoader cl = Thread.currentThread().getContextClassLoader();
String[] docs = {
"WEB-INF/wsdl/RpcLitEndpoint.wsdl",
"WEB-INF/wsdl/RpcLitAbstract.wsdl",
"WEB-INF/wsdl/RpcLitEndpoint.xsd"
};
for (String doc : docs) {
URL url = cl.getResource(doc);
metadata.add(new StreamSource(url.openStream(),
url.toExternalForm()));
}
endpoint.setMetadata(metadata);
endpoint.publish(address);

If you have annotated the service using @WebService(wsdlLocation="..."),
then that needs to removed in the above "docs"

* I am fixing the NPE in the next release 2.1.4

Jitu

Jitendra Kotamraju wrote:
> Can you file a bug with a sample test case(reproducible will be
> better). Since you are using Endpoint.publish(), I would like to how
> you are passing WSDL, and Schema metadata. You should be using
> Endpoint.setMetadata(...) to pass the schema documents.
>
> Jitu
>
> metro@javadesktop.org wrote:
>> Hello,
>> I have problem with my web service. When I use @SchemaValidation and
>> specify wsdlLocation in @WebService anotation, exeption (see below)
>> is thrown when I try to start it. In my own wsdl I import external
>> xsd schema. wsdl part:
>>
>> >> xmlns:tns="http://ws.myApp/"
>> xmlns:mod="http://model.myApp/"
>> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
>> xmlns:xs="http://www.w3.org/2001/XMLSchema"
>> name="MosolfCommunicationService"
>> targetNamespace="http://ws.myApp/">
>>
>>
>>
>> >> schemaLocation="atnInterface.xsd">
>>

>>

>>

>> ....
>> xsd file start:
>>
>> >> xmlns:xs="http://www.w3.org/2001/XMLSchema"
>> elementFormDefault="qualified" version="1.0"
>> targetNamespace="http://model.myApp/">
>> ...
>>
>> Seems like naming of xsd and wsdl file is issue or something platform
>> specific. For certain names it was ok (e.g. mosolf.wsdl and
>> atnInterface.xsd) but for some (with same content) it failed (e.g.
>> mosolf_gen.wsdl and atnInterface_gen.xsd) . On another machine it
>> failed also for the first pair of names. When I copied schema content
>> into wsdl it was also OK.
>> I tried to debug it little, and problem seemed to be order of loading
>> schema documents inside xerxes (there was 2, from wsdl:types and
>> external xsd file).
>> Is there any way to ensure correct behavior while using schema import
>> in wsdl?
>>
>> java version: 1.6.0_04-b12, metro version: 1.1
>> thrown exeption:
>> java.lang.NullPointerException
>> at
>> com.sun.xml.ws.server.ServerSchemaValidationTube$MetadataResolverImpl$1.getByteStream(ServerSchemaValidationTube.java:156)
>>
>> at
>> com.sun.org.apache.xerces.internal.util.DOMEntityResolverWrapper.resolveEntity(DOMEntityResolverWrapper.java:124)
>>
>> at
>> com.sun.org.apache.xerces.internal.impl.XMLEntityManager.resolveEntity(XMLEntityManager.java:1100)
>>
>> at
>> com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.resolveDocument(XMLSchemaLoader.java:595)
>>
>> at
>> com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.resolveSchema(XSDHandler.java:1671)
>>
>> at
>> com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.constructTrees(XSDHandler.java:909)
>>
>> at
>> com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:569)
>>
>> at
>> com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:552)
>>
>> at
>> com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:519)
>>
>> at
>> com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:485)
>>
>> at
>> com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema(XMLSchemaFactory.java:210)
>>
>> at
>> com.sun.xml.ws.server.ServerSchemaValidationTube.(ServerSchemaValidationTube.java:67)
>>
>> at
>> com.sun.xml.ws.api.pipe.ServerTubeAssemblerContext.createValidationTube(ServerTubeAssemblerContext.java:212)
>>
>> at
>> com.sun.xml.ws.api.pipe.ServerPipeAssemblerContext.createValidationPipe(ServerPipeAssemblerContext.java:96)
>>
>> at
>> com.sun.xml.ws.assembler.PipelineAssemblerFactoryImpl$WsitPipelineAssembler.createServer(PipelineAssemblerFactoryImpl.java:305)
>>
>> at
>> com.sun.xml.ws.api.pipe.TubelineAssemblerFactory$TubelineAssemblerAdapter.createServer(TubelineAssemblerFactory.java:140)
>>
>> at
>> com.sun.xml.ws.server.WSEndpointImpl.(WSEndpointImpl.java:152)
>> at
>> com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:217)
>>
>> at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:467)
>> at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:486)
>> at
>> com.sun.xml.ws.transport.http.server.EndpointImpl.createEndpoint(EndpointImpl.java:222)
>>
>> at
>> com.sun.xml.ws.transport.http.server.EndpointImpl.publish(EndpointImpl.java:152)
>>
>> at
>> com.sun.xml.ws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:113)
>>
>> at javax.xml.ws.Endpoint.publish(Endpoint.java:170)
>> ... myApp stack...
>> [Message sent by forum member 'pavol_v' (pavol_v)]
>>
>> http://forums.java.net/jive/thread.jspa?messageID=259993
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
>> For additional commands, e-mail: users-help@metro.dev.java.net
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
> For additional commands, e-mail: users-help@metro.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
For additional commands, e-mail: users-help@metro.dev.java.net

pavol_v
Offline
Joined: 2008-02-20
Points: 0

Thank you for answer, I used your solution with setting metadata and it works fine for me.

Palo