11 Replies Latest reply: Oct 30, 2009 10:03 AM by klowtherjr RSS

JBossEntityResolver cannot resolve...

klowtherjr Newbie

Hi all,

I'm using JBoss 4.2.3 GA for my application. When I submit my first request to the web service that has been generated using WsdlToJava (and JAXB), JBoss appears to have an issue. The JBossEntityResolver (and JBossWSEntityResolver) appears to be trying to resolve mappings of classes to namespaces. This goes along fine at first, but then at a certain point it cannot resolve them anywmore and takes a long time to complete the resolution process. Things work fine after that, but the first submission is taking forever and is unacceptable. Here's a sample of when the resolution is working:

2009-10-26 12:38:29,153 DEBUG [org.jboss.ws.core.utils.JBossWSEntityResolver] resolveEntity: [pub=jar:file:/C:/Programs/JBoss/4.2.3.GA/server/myapp/deploy/myapp.ear/lib/myapp-eai.jar!/myapp/OGC/int/eurocontrol/wx/1.1.0/wxBase.xsd,sysid=jar:file:/C:/Programs/JBoss/4.2.3.GA/server/myapp/deploy/myapp.ear/lib/myapp-eai.jar!/myapp/OGC/int/eurocontrol/wx/1.1.0/wxBase.xsd]

2009-10-26 12:38:29,153 DEBUG [org.jboss.ws.core.utils.JBossWSEntityResolver] resolveEntity: [pub=jar:file:/C:/Programs/JBoss/4.2.3.GA/server/myapp/deploy/myapp.ear/lib/myapp-eai.jar!/myapp/OGC/net/opengis/gml/3.2.1/gml.xsd,sysid=jar:file:/C:/Programs/JBoss/4.2.3.GA/server/myapp/deploy/myapp.ear/lib/myapp-eai.jar!/myapp/OGC/net/opengis/gml/3.2.1/gml.xsd]


and then half a second later it isn't for even the same files on the same request:

2009-10-26 12:38:29,622 DEBUG [org.jboss.wsf.framework.DefaultSPIProvider] provide SPI 'class org.jboss.wsf.spi.management.ServerConfigFactory'

2009-10-26 12:38:29,653 DEBUG [org.jboss.wsf.framework.DefaultSPIProvider] class org.jboss.wsf.spi.management.ServerConfigFactory Implementation: org.jboss.wsf.framework.management.ServerConfigFactoryImpl@9d28a0

2009-10-26 12:38:29,685 DEBUG [org.jboss.wsf.framework.DefaultSPIProvider] provide SPI 'class org.jboss.wsf.spi.management.ServerConfigFactory'

2009-10-26 12:38:29,685 DEBUG [org.jboss.wsf.framework.DefaultSPIProvider] class org.jboss.wsf.spi.management.ServerConfigFactory Implementation: org.jboss.wsf.framework.management.ServerConfigFactoryImpl@f47afb

2009-10-26 12:38:29,716 DEBUG [org.jboss.ws.tools.JavaToXSD] Load schema: http://www.eurocontrol.int/wx/1.1=jar:file:/C:/Programs/JBoss/4.2.3.GA/server/myapp/deploy/myapp.ear/lib/myapp-eai.jar!/myapp/OGC/int/eurocontrol/wx/1.1.0/wx.xsd

2009-10-26 12:38:29,716 DEBUG [org.jboss.ws.core.utils.JBossWSEntityResolver] resolveEntity: [pub=null,sysid=jar:file:/C:/Programs/JBoss/4.2.3.GA/server/myapp/deploy/myapp.ear/lib/myapp-eai.jar!/myapp/OGC/int/eurocontrol/wx/1.1.0/wx.xsd]

2009-10-26 12:38:29,716 DEBUG [org.jboss.ws.core.utils.JBossWSEntityResolver] resolveEntity: [pub=http://www.eurocontrol.int/wx/1.1,sysid=wxBase.xsd]

2009-10-26 12:38:29,716 DEBUG [org.jboss.util.xml.JBossEntityResolver] Cannot resolve [publicID=http://www.eurocontrol.int/wx/1.1,systemID=wxBase.xsd]

2009-10-26 12:38:29,716 DEBUG [org.jboss.ws.core.utils.JBossWSEntityResolver] Cannot resolve entity: [pub=http://www.eurocontrol.int/wx/1.1,sysid=wxBase.xsd]

2009-10-26 12:38:29,825 DEBUG [org.jboss.ws.core.utils.JBossWSEntityResolver] resolveEntity: [pub=http://www.opengis.net/gml/3.2,sysid=../../../../net/opengis/gml/3.2.1/gml.xsd]

2009-10-26 12:38:29,825 DEBUG [org.jboss.util.xml.JBossEntityResolver] Cannot resolve [publicID=http://www.opengis.net/gml/3.2,systemID=../../../../net/opengis/gml/3.2.1/gml.xsd]

2009-10-26 12:38:29,825 DEBUG [org.jboss.ws.core.utils.JBossWSEntityResolver] Cannot resolve entity: [pub=http://www.opengis.net/gml/3.2,sysid=../../../../net/opengis/gml/3.2.1/gml.xsd]

I can see that the publicId and the systemId values are different for the ones that aren't resolving, but I don't know why that is. Any help would be appreciated. Is this an issue with the JavaToXSD? I see that in the log entry above where the resolution problems start.

Thanks,

Ken




  • 1. Re: JBossEntityResolver cannot resolve...
    Alexey Loubyansky Master

    Looks like it's an issue of the calling code, not in JBossEntityResolver itself.
    I think if the namespace/publicId for the not resolved schemas was mapped to the schemaLocation/systemId of the resovled schemas it would be able to resolve it. If that's true then it's a configuration issue and should be fixed in the calling code (JBossWSEntityResolver, JBossWS code or something on top).
    I'd suggest posting this on the WS user forums as well to get the WS team look into this.

  • 2. Re: JBossEntityResolver cannot resolve...
    klowtherjr Newbie

    Hi Alex and thanks for the response.

    This is an issue with a number of XSD files that are present in my jar. I can see that the XSDs whose imports resolve correctly have a relative URL for the schemaLocation. Here's a "friendly" URL example:

    <xsd:import namespace="http://www.opengis.net/gml/3.2" schemaLocation="OGC/net/opengis/gml/3.2.1/gml.xsd"/>

    The ones that don't resolve correctly are from a different namespace that is dependent on the namespace listed above. The difference is they are also using relative URLs from that other namespace. I think these dependent relative URLs are causing the issue in that they're not resolving correctly (or at least timely). Here's one that I know logs the error I posted previously:

    <xsd:import namespace="http://www.opengis.net/gml/3.2" schemaLocation="../../../../net/opengis/gml/3.2.1/gml.xsd"/>

    This URL should resolve as the XSD is valid and everything generates to code and runs (just very slowly at first because of this). Perhaps, as you suggest, there is also a solution to be addressed in the calling code to get this URL to resolve. I'll cross-post to the WS user forums as well.

  • 3. Re: JBossEntityResolver cannot resolve...
    Alexey Loubyansky Master

    Could you post the whole log for one of the failed resolutions? Also enable TRACE for org.jboss.util.xml.JBossEntityResolver.

    Here is the code of the resolver
    https://svn.jboss.org/repos/common/common-old/tags/JBossCommon_1_2_1_GA/src/main/org/jboss/util/xml/JBossEntityResolver.java

    As you can see, if the schema mapping is not provided it is trying to resolve the location as URL and load it from the classpath.

  • 4. Re: JBossEntityResolver cannot resolve...
    klowtherjr Newbie

    Alex,

    Maybe that's the key, that I'm not providing the schema mapping Let me check that first. I'm using WsdlToJava/JAXB to generate the classes. I thought the schema mapping was generated automatically, but maybe I'm mistaken about that.

  • 5. Re: JBossEntityResolver cannot resolve...
    klowtherjr Newbie

    Alex,

    Here are two examples. I would expect loadClasspathResource to find this first one using the sysid. However, it isn't in the jar as just wxBase.xsd. It is in myAppPrefix/OGC/int/eurocontrol/wx/1.1.0. I noticed there's an extra .0 there that isn't in the pub. I put a version of the file with a path of myAppPrefix/OGC/int/eurocontrol/wx/1.1 as well, but that doesn't help either.

    2009-10-28 15:17:51,156 DEBUG [org.jboss.ws.core.utils.JBossWSEntityResolver] resolveEntity: [pub=http://www.eurocontrol.int/wx/1.1,sysid=wxBase.xsd]

    2009-10-28 15:17:51,156 TRACE [org.jboss.util.xml.JBossEntityResolver] resolvePublicID, publicId=http://www.eurocontrol.int/wx/1.1

    2009-10-28 15:17:51,156 TRACE [org.jboss.util.xml.JBossEntityResolver] resolveSystemID, systemId=wxBase.xsd

    2009-10-28 15:17:51,156 TRACE [org.jboss.util.xml.JBossEntityResolver] resolveClasspathName, systemId=wxBase.xsd

    2009-10-28 15:17:51,156 TRACE [org.jboss.util.xml.JBossEntityResolver] Mapped systemId to filename: wxBase.xsd

    2009-10-28 15:17:51,156 TRACE [org.jboss.util.xml.JBossEntityResolver] resolveSystemIDasURL, systemId=wxBase.xsd

    2009-10-28 15:17:51,156 TRACE [org.jboss.util.xml.JBossEntityResolver] Trying to resolve systemId as a URL

    2009-10-28 15:17:51,156 TRACE [org.jboss.util.xml.JBossEntityResolver] SystemId is not a url: wxBase.xsd

    java.net.MalformedURLException: no protocol: wxBase.xsd

    at java.net.URL.(URL.java:567)

    at java.net.URL.(URL.java:464)

    at java.net.URL.(URL.java:413)

    at org.jboss.util.xml.JBossEntityResolver.resolveSystemIDasURL(JBossEntityResolver.java:403)

    at org.jboss.util.xml.JBossEntityResolver.resolveEntity(JBossEntityResolver.java:266)

    at org.jboss.ws.core.utils.JBossWSEntityResolver.resolveEntity(JBossWSEntityResolver.java:65)

    at org.jboss.ws.metadata.wsdl.xmlschema.JBossXSEntityResolver.resolveEntity(JBossXSEntityResolver.java:79)

    at org.apache.xerces.impl.XMLEntityManager.resolveEntity(Unknown Source)

    at org.apache.xerces.impl.xs.XMLSchemaLoader.resolveDocument(Unknown Source)

    at org.apache.xerces.impl.xs.traversers.XSDHandler.resolveSchema(Unknown Source)

    at org.apache.xerces.impl.xs.traversers.XSDHandler.constructTrees(Unknown Source)

    at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)

    at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)

    at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)

    at org.jboss.ws.tools.JavaToXSD.parseSchema(JavaToXSD.java:182)

    at org.jboss.ws.tools.wsdl.WSDL11Reader.processTypes(WSDL11Reader.java:401)

    at org.jboss.ws.tools.wsdl.WSDL11Reader.processDefinition(WSDL11Reader.java:178)

    at org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory.parse(WSDLDefinitionsFactory.java:128)

    at org.jboss.ws.metadata.umdm.ServiceMetaData.getWsdlDefinitions(ServiceMetaData.java:295)

    at org.jboss.ws.metadata.builder.jaxws.JAXWSClientMetaDataBuilder.buildMetaData(JAXWSClientMetaDataBuilder.java:86)

    at org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.(ServiceDelegateImpl.java:140)

    at org.jboss.ws.core.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:64)

    at javax.xml.ws.Service.(Service.java:81)
    ...

    2009-10-28 15:17:51,156 DEBUG [org.jboss.util.xml.JBossEntityResolver] Cannot resolve [publicID=http://www.eurocontrol.int/wx/1.1,systemID=wxBase.xsd]

    2009-10-28 15:17:51,156 DEBUG [org.jboss.ws.core.utils.JBossWSEntityResolver] Cannot resolve entity: [pub=http://www.eurocontrol.int/wx/1.1,sysid=wxBase.xsd]

    For completeness, I'm posting the xsd file that is causing the above:

    <schema targetNamespace="http://www.eurocontrol.int/wx/1.1" xmlns:wx="http://www.eurocontrol.int/wx/1.1"
    xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
    attributeFormDefault="unqualified" version="1.0">


    ...


    I noticed in the jar that there's an extra .1 here that isn't in the pub (gml/3.2.1). I removed it in the jar just to see, but it didn't seem to make a difference.

    2009-10-28 15:17:51,250 DEBUG [org.jboss.ws.core.utils.JBossWSEntityResolver] resolveEntity: [pub=http://www.opengis.net/gml/3.2,sysid=../../../../net/opengis/gml/3.2.1/gml.xsd]

    2009-10-28 15:17:51,250 TRACE [org.jboss.util.xml.JBossEntityResolver] resolvePublicID, publicId=http://www.opengis.net/gml/3.2

    2009-10-28 15:17:51,250 TRACE [org.jboss.util.xml.JBossEntityResolver] resolveSystemID, systemId=../../../../net/opengis/gml/3.2.1/gml.xsd

    2009-10-28 15:17:51,250 TRACE [org.jboss.util.xml.JBossEntityResolver] resolveClasspathName, systemId=../../../../net/opengis/gml/3.2.1/gml.xsd

    2009-10-28 15:17:51,250 TRACE [org.jboss.util.xml.JBossEntityResolver] Mapped systemId to filename: gml.xsd

    2009-10-28 15:17:51,250 TRACE [org.jboss.util.xml.JBossEntityResolver] resolveSystemIDasURL, systemId=../../../../net/opengis/gml/3.2.1/gml.xsd

    2009-10-28 15:17:51,250 TRACE [org.jboss.util.xml.JBossEntityResolver] Trying to resolve systemId as a URL

    2009-10-28 15:17:51,250 TRACE [org.jboss.util.xml.JBossEntityResolver] SystemId is not a url: ../../../../net/opengis/gml/3.2.1/gml.xsd

    java.net.MalformedURLException: no protocol: ../../../../net/opengis/gml/3.2.1/gml.xsd

    at java.net.URL.(URL.java:567)

    at java.net.URL.(URL.java:464)

    at java.net.URL.(URL.java:413)

    at org.jboss.util.xml.JBossEntityResolver.resolveSystemIDasURL(JBossEntityResolver.java:403)

    at org.jboss.util.xml.JBossEntityResolver.resolveEntity(JBossEntityResolver.java:266)

    at org.jboss.ws.core.utils.JBossWSEntityResolver.resolveEntity(JBossWSEntityResolver.java:65)

    at org.jboss.ws.metadata.wsdl.xmlschema.JBossXSEntityResolver.resolveEntity(JBossXSEntityResolver.java:79)

    at org.apache.xerces.impl.XMLEntityManager.resolveEntity(Unknown Source)

    at org.apache.xerces.impl.xs.XMLSchemaLoader.resolveDocument(Unknown Source)

    at org.apache.xerces.impl.xs.traversers.XSDHandler.resolveSchema(Unknown Source)

    at org.apache.xerces.impl.xs.traversers.XSDHandler.constructTrees(Unknown Source)

    at org.apache.xerces.impl.xs.traversers.XSDHandler.constructTrees(Unknown Source)

    at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)

    at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)

    at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)

    at org.jboss.ws.tools.JavaToXSD.parseSchema(JavaToXSD.java:182)

    at org.jboss.ws.tools.wsdl.WSDL11Reader.processTypes(WSDL11Reader.java:401)

    at org.jboss.ws.tools.wsdl.WSDL11Reader.processDefinition(WSDL11Reader.java:178)

    at org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory.parse(WSDLDefinitionsFactory.java:128)

    at org.jboss.ws.metadata.umdm.ServiceMetaData.getWsdlDefinitions(ServiceMetaData.java:295)

    at org.jboss.ws.metadata.builder.jaxws.JAXWSClientMetaDataBuilder.buildMetaData(JAXWSClientMetaDataBuilder.java:86)

    at org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.(ServiceDelegateImpl.java:140)

    at org.jboss.ws.core.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:64)

    at javax.xml.ws.Service.(Service.java:81)
    ...

    2009-10-28 15:17:51,250 DEBUG [org.jboss.util.xml.JBossEntityResolver] Cannot resolve [publicID=http://www.opengis.net/gml/3.2,systemID=../../../../net/opengis/gml/3.2.1/gml.xsd]

    2009-10-28 15:17:51,250 DEBUG [org.jboss.ws.core.utils.JBossWSEntityResolver] Cannot resolve entity: [pub=http://www.opengis.net/gml/3.2,sysid=../../../../net/opengis/gml/3.2.1/gml.xsd]

    Here is the offending XSD file snippet that caused this:

    <xsd:import namespace="http://www.opengis.net/gml/3.2"
    schemaLocation="../../../../net/opengis/gml/3.2.1/gml.xsd"/>

  • 6. Re: JBossEntityResolver cannot resolve...
    Alexey Loubyansky Master

    I don't see it as an issue with JBossEntityResolver. As you can see it is trying to use publicId/systemId as URL, find in the classpath and you can help by mapping the location explicitly. This is the contract that it implements. If you have a use-case which shows a bug in the impl of the contract then it's an issue otherwise it's a misuse.

    If you want to rely on resolution based on the classpath then you have to specify the correct relative path. Like you had posted previously.

    <xsd:import namespace="http://www.opengis.net/gml/3.2" schemaLocation="OGC/net/opengis/gml/3.2.1/gml.xsd"/>


    Alternatively, perhaps you can provide your own EntityResolver impl, but I am not sure about that.

  • 7. Re: JBossEntityResolver cannot resolve...
    klowtherjr Newbie

    Thanks again Alex,

    If I understand what you're saying correctly, I must code the mappings in my application using the registerEntity method calls so that JBoss can resolve them. I think I can do this, but I also don't know if this isn't a shortcoming of the contract. I'm open to the possibility that the package mappings in my binding.xml are causing the issue, but I'm not seeing it after rechecking.

    If I'm not mistaken, using the same /OGC/net/opengis/gml prefix as the relative path in the failing instance is not the correct relative path from where that XSD file exists in terms of specifying the schemaLocation property. The one with the ../../../../ is actually correct in terms of a relative path.

    OGC\int\eurocontrol\wx\1.1.0\wxBase.xsd is referring to
    OGC\net\opengis\gml\3.2.1\gml.xsd using
    <xsd:import namespace="http://www.opengis.net/gml/3.2"
    schemaLocation="../../../../net/opengis/gml/3.2.1/gml.xsd"/>

    Based on the JBossEntityResolver code, I'm not seeing where a relative path should be used at all for the sysId (schemaLocation). Is that correct according to the contract? Perhaps seeing the contract would help me understand better.

    Also, I can see in the code where the sysId is checked as a URL, but not the publicId + "/" + sysId. I don't know if that makes the XSD bad or not, but that is what I've been given (I don't control the contents of the schema) and the schema validates. Here's what I mean:

    wx.xsd refers to wxBase.xsd, which is located in the same directory, by using the following:

    <xsd:include schemaLocation="wxBase.xsd"/>

    Does this make any sense?

  • 8. Re: JBossEntityResolver cannot resolve...
    klowtherjr Newbie

    Hi Alex,

    I got this part to work for the following example:

    JBossEntityResolver.registerEntity( "../../../../net/opengis/gml/3.2.1/gml.xsd",
     "gov/faa/wmscr/OGC/net/opengis/gml/3.2.1/gml.xsd");


    This resolves a few of the issues. However, the remainder of them come from something that I don't think I can resolve in this manner.

    <xsd:include schemaLocation="wxBase.xsd"/>

    In this case the caller sets the publicId to the targetNamespace, which in this case is "http://www.eurocontrol.int/wx/1.1" and the sysId to "wxBase.xsd".

    The problem as I see it is that there are many .xsd files that are in the "http://www.eurocontrol.int/wx/1.1" namespace. If JBossEntityResolver uses the publicId and sysId separately and never together, these schema references cannot be resolved down to one .xsd file no matter what registry entries I add. This seems like a problem to me, unless I'm just missing the obvious. Perhaps it lies with the caller, perhaps with the resolver. I'm guessing given that the contract doesn't put them together that it lies with the caller.

  • 9. Re: JBossEntityResolver cannot resolve...
    klowtherjr Newbie

    Alex,

    Is what I've described not this issue? It seems the same at least.

    https://jira.jboss.org/jira/browse/JBXB-59

  • 10. Re: JBossEntityResolver cannot resolve...
    Alexey Loubyansky Master

    I think JBXB-59 should be out of date now.
    The version of jboss-common you are using is affected by this, yes. But then I fixed it https://jira.jboss.org/jira/browse/JBCOMMON-43
    So, in your case you shouldn't use mapping but the schemaLocations that are correctly pointing to the XSDs relative to the module's top level directory.

  • 11. Re: JBossEntityResolver cannot resolve...
    klowtherjr Newbie

    Thanks Alex,

    I was able to get everything to resolve last night as you said, by using the schemaLocation as the key for the registerEntity call. It was a bit of a pain given that there are 100+ schemas and some of them are referenced more than once, but it worked.

    Unfortunately the slowness I was seeing is still there. Looking at the log, it seems to be due to the consumption of the WSDL, which is fodder for a different forum (and/or my own thoughts). Thanks for your help with this issue.

    Ken