[JBoss XML Binding Development] - Re: JBossEntityResolver cannot resolve...
by klowtherjr
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....]
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/...]
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....]
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"/>
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4262815#4262815
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4262815
14 years, 6 months
[JBoss XML Binding Development] - Re: JBossEntityResolver cannot resolve...
by klowtherjr
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.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4262769#4262769
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4262769
14 years, 6 months
[JBoss Microcontainer Development] - Re: Optimizing ControllerState
by kabir.khan@jboss.com
I have been playing a bit with an alternative implementation of ControllerStateModel, and am getting some good numbers. Here's my benchmark
| public void benchmarkControllerStateModel(ControllerStateModelFactory factory) throws Throwable
| {
| int counter = 0;
|
| ControllerStateModelAdapter model = factory.createControllerStateModel();
|
| ControllerState[] states = new ControllerState[NUM_STATES];
| for (int i = 0 ; i < NUM_STATES ; i++)
| {
| states = new ControllerState("State" + i);
| model.addState(states, null);
| }
|
| //Just make sure things were added
| assertEquals(new ControllerState("State" + (NUM_STATES - 2)), model.getPreviousState(new ControllerState("State" + (NUM_STATES -1))));
|
| ControllerState[] input = new ControllerState[ITERATIONS];
| for (int i = 0 ; i < ITERATIONS ; i++)
| {
| int stateIndex = (int)Math.round(Math.random() * (NUM_STATES - 1));
| input = STATE_FACTORY.getState(states[stateIndex].getStateString());
| }
|
| System.out.println("========= Starting benchmark =========================");
| System.out.println("Iterations: " + ITERATIONS);
| System.out.println("States: " + NUM_STATES);
| System.out.println("State Model Factory: " + factory);
| System.out.println("State Factory: " + STATE_FACTORY);
| System.out.println("=====================================================");
|
| long start = System.currentTimeMillis();
|
| for (int i = 1 ; i < ITERATIONS - 2 ; i++)
| {
| ControllerState state1 = model.isAfterState(input, input[i-1]) ? input : input[i-1];
| ControllerState state2 = model.isBeforeState(input, input[i+1]) ? input : input[i+1];
| state1 = model.getNextState(state1);
| state2 = model.getPreviousState(state2);
| if (state1 != null && state2 != null)
| counter++;
| else
| counter--;
| }
| System.out.println("========= Test took " + (System.currentTimeMillis() - start) + " ms");
| System.out.println(counter);
| }
|
Here is the alternative implementation I hacked together. I also have a test that ensures that this behaves the same way as the existing one in AbstractController (apart from the listIterator, which I did not bother to implement yet):
| private static class MapControllerStateModel extends ControllerStateModelAdapter
| {
| ControllerStateWrapper first;
| ControllerStateWrapper last;
| private Map<ControllerState, ControllerStateWrapper> states = new HashMap<ControllerState, ControllerStateWrapper>();
|
| public void addState(ControllerState state, ControllerState before)
| {
| if (states.containsKey(state))
| return;
|
| if (before == null)
| {
| ControllerStateWrapper newState = new ControllerStateWrapper(state);
| ControllerStateWrapper previous = last;
| if (previous != null)
| {
| newState.setIndex(previous.getIndex() + 1);
| previous.setAfter(newState);
| newState.setBefore(previous);
| }
| else
| {
| newState.setIndex(0);
| }
| last = newState;
| states.put(state, newState);
| }
| else
| {
| ControllerStateWrapper next = getState(before);
| if (next == null)
| throw new IllegalArgumentException("No such state " + state + " in states " + states);
|
| ControllerStateWrapper newState = new ControllerStateWrapper(state);
| newState.setIndex(next.getIndex());
| newState.setAfter(next);
| newState.setBefore(next.getBefore());
| next.setBefore(newState);
| if (newState.getBefore() == null)
| first = newState;
|
| while (next != null)
| {
| next.incrementIndex();
| next = next.getAfter();
| }
|
| states.put(state, newState);
| }
| }
|
|
| protected ControllerStateWrapper getState(ControllerState state)
| {
| return getState(state, false);
| }
|
| protected ControllerStateWrapper getState(ControllerState state, boolean allowNotFound)
| {
| if (state == null)
| throw new IllegalArgumentException("Null state");
|
| ControllerStateWrapper found = states.get(state);
| if (found == null && !allowNotFound)
| throw new IllegalArgumentException("No such state " + state + " in states " + states);
|
| return found;
| }
|
| protected int getStateIndex(ControllerState state)
| {
| return getStateIndex(state, false);
| }
|
| protected int getStateIndex(ControllerState state, boolean allowNotFound)
| {
| ControllerStateWrapper stateWrapper = getState(state, allowNotFound);
| return stateWrapper == null ? -1 : stateWrapper.getIndex();
| }
|
| public ControllerState getPreviousState(ControllerState state)
| {
| ControllerStateWrapper previous = getState(state).getBefore();
| return previous == null ? null : previous.getState();
| }
|
| public ControllerState getNextState(ControllerState state)
| {
| ControllerStateWrapper next = getState(state).getAfter();
| return next == null ? null : next.getState();
| }
|
| public boolean isBeforeState(ControllerState state, ControllerState reference)
| {
| int stateIndex = getStateIndex(state, true);
| int referenceIndex = getStateIndex(reference, true);
| return stateIndex < referenceIndex;
| }
|
| public boolean isAfterState(ControllerState state, ControllerState reference)
| {
| int stateIndex = getStateIndex(state, true);
| int referenceIndex = getStateIndex(reference, true);
| return stateIndex > referenceIndex;
| }
|
| public Iterator<ControllerState> iterator()
| {
| return new StateIterator(first);
| }
|
| public ListIterator<ControllerState> listIteraror()
| {
| return null;//states.listIterator(states.size() - 1);
| }
|
| private static class StateIterator implements Iterator<ControllerState>
| {
| ControllerStateWrapper current;
|
| public StateIterator(ControllerStateWrapper current)
| {
| this.current = current;
| }
|
| public void remove()
| {
| throw new UnsupportedOperationException("Remove not allowed on ControllerStateModel");
| }
|
| public ControllerState next()
| {
| if (current == null)
| throw new NoSuchElementException();
| ControllerState state = current.getState();
| current = current.getAfter();
| return state;
| }
|
| public boolean hasNext()
| {
| return current != null;
| }
| }
|
| private static class ControllerStateWrapper
| {
| final ControllerState state;
| int index;
| ControllerStateWrapper before;
| ControllerStateWrapper after;
|
| public ControllerStateWrapper(ControllerState state)
| {
| this.state = state;
| }
|
| public int getIndex()
| {
| return index;
| }
|
| public void setIndex(int index)
| {
| this.index = index;
| }
|
| public void incrementIndex()
| {
| this.index++;
| }
|
| public ControllerStateWrapper getBefore()
| {
| return before;
| }
|
| public void setBefore(ControllerStateWrapper before)
| {
| this.before = before;
| }
|
| public ControllerStateWrapper getAfter()
| {
| return after;
| }
|
| public void setAfter(ControllerStateWrapper after)
| {
| this.after = after;
| }
|
| public ControllerState getState()
| {
| return state;
| }
| }
| }
|
The old implementation's time increases with the number of states:
| ========= Starting benchmark =========================
| Iterations: 1000000
| States: 5
| State Model Factory: Abstract Controller (List)
| State Factory: Cached states
| =====================================================
| ========= Test took 765 ms
|
| ========= Starting benchmark =========================
| Iterations: 1000000
| States: 10
| State Model Factory: Abstract Controller (List)
| State Factory: Cached states
| =====================================================
| ========= Test took 1373 ms
|
| ========= Starting benchmark =========================
| Iterations: 1000000
| States: 15
| State Model Factory: Abstract Controller (List)
| State Factory: Cached states
| =====================================================
| ========= Test took 1623 ms
|
| ========= Starting benchmark =========================
| Iterations: 1000000
| States: 20
| State Model Factory: Abstract Controller (List)
| State Factory: Cached states
| =====================================================
| ========= Test took 1933 ms
|
| ========= Starting benchmark =========================
| Iterations: 1000000
| States: 30
| State Model Factory: Abstract Controller (List)
| State Factory: Cached states
| =====================================================
| ========= Test took 2892 ms
|
| ========= Starting benchmark =========================
| Iterations: 1000000
| States: 40
| State Model Factory: Abstract Controller (List)
| State Factory: Cached states
| =====================================================
| ========= Test took 3902 ms
|
|
The alternative implementation stays pretty constant, at less time than 5 entries in the existing implementation :-)
|
| ========= Starting benchmark =========================
| Iterations: 1000000
| States: 5
| State Model Factory: Map ControllerStateModel
| State Factory: Cached states
| =====================================================
| ========= Test took 342 ms
|
| ========= Starting benchmark =========================
| Iterations: 1000000
| States: 10
| State Model Factory: Map ControllerStateModel
| State Factory: Cached states
| =====================================================
| ========= Test took 329 ms
|
| ========= Starting benchmark =========================
| Iterations: 1000000
| States: 15
| State Model Factory: Map ControllerStateModel
| State Factory: Cached states
| =====================================================
| ========= Test took 338 ms
|
| ========= Starting benchmark =========================
| Iterations: 1000000
| States: 20
| State Model Factory: Map ControllerStateModel
| State Factory: Cached states
| =====================================================
| ========= Test took 340 ms
|
| ========= Starting benchmark =========================
| Iterations: 1000000
| States: 30
| State Model Factory: Map ControllerStateModel
| State Factory: Cached states
| =====================================================
| ========= Test took 375 ms
|
| ========= Starting benchmark =========================
| Iterations: 1000000
| States: 40
| State Model Factory: Map ControllerStateModel
| State Factory: Cached states
| =====================================================
| ========= Test took 342 ms
|
For fun I put in 5000 states in the new model, it is still faster than the existing one with 5 states ;-)
| ========= Starting benchmark =========================
| Iterations: 1000000
| States: 5000
| State Model Factory: Map ControllerStateModel
| State Factory: Cached states
| =====================================================
| ========= Test took 379 ms
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4262763#4262763
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4262763
14 years, 6 months