[SWS-749] org.springframework.xml.sax.SaxUtils swallows exceptions Created: 18/Jan/12  Updated: 04/May/12  Resolved: 24/Jan/12

Status: Closed
Project: Spring Web Services
Component/s: Core
Affects Version/s: 2.0.2
Fix Version/s: 2.0.4

Type: Improvement Priority: Minor
Reporter: David Nee Assignee: Arjen Poutsma
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: 0.05h
Original Estimate: Not Specified

Windows/Spring 3.0.6.RELEASE/Websphere Application Server


While starting a spring-ws application on Websphere, CommonsXsdSchemaCollection makes a call to SaxUtils in order to resolve the location of XSDs defined in the collection. I hit a problem whereby the SaxUtils.getSystemId() swallows an exception (see below) because there is a space in the URL of the XSD. This was a serious pain to track down because the code went on to create a different exception that lead me on a wild goose chase. Would be good if the exception was logged.

====================== Note: I've X'd out some of the file names
[1/18/12 13:47:15:228 CST] 00000017 SystemOut     O 2012-01-18 13:47:15,228 INFO    SaxUtils - resource -class path resource [xsd/XXXXXXXXXXXService_V_1_0.xsd]
[1/18/12 13:47:15:228 CST] 00000017 SystemOut     O 2012-01-18 13:47:15,228 INFO    SaxUtils - resource URL -wsjar:file:/D:/opt/sw/IBM/SDP/runtimes/base_v7/profiles/was70profile1/installedApps/wn-ila3bga9y136Node01Cell/XXX XXXXXXXX API.ear/xxxx-xx-api-12.1.war/WEB-INF/lib/xxxx-core-api-12.1.jar!/xsd/XXXXXXXXXXXService_V_1_0.xsd
[1/18/12 13:47:15:228 CST] 00000017 SystemOut     O 2012-01-18 13:47:15,228 INFO    SaxUtils - resource URL external form-wsjar:file:/D:/opt/sw/IBM/SDP/runtimes/base_v7/profiles/was70profile1/installedApps/wn-ila3bga9y136Node01Cell/XXX XXXXXXXX API.ear/xxx-ws-api-12.1.war/WEB-INF/lib/xxxx-core-api-12.1.jar!/xsd/XXXXXXXXXXXService_V_1_0.xsd
[1/18/12 13:47:15:228 CST] 00000017 SystemOut     O 2012-01-18 13:47:15,228 INFO    SaxUtils - URISyntaxException -
java.net.URISyntaxException: Illegal character in opaque part at index 113: wsjar:file:/D:/opt/sw/IBM/SDP/runtimes/base_v7/profiles/was70profile1/installedApps/wn-ila3bga9y136Node01Cell/XXX XXXXXXXX API.ear/xxxx-ws-api-12.1.war/WEB-INF/lib/xxxx-core-api-12.1.jar!/xsd/XXXXXXXXXXXService_V_1_0.xsd
	at java.net.URI$Parser.fail(URI.java:2820)
	at java.net.URI$Parser.checkChars(URI.java:2993)
	at java.net.URI$Parser.parse(URI.java:3030)
	at java.net.URI.<init>(URI.java:589)
	at org.springframework.xml.sax.SaxUtils.getSystemId(SaxUtils.java:61)

I modified SaxUtils to produce the logging info above (this is not a suggested solution, just some verbose logging I added to try find out what was happening). Below is the modified code that produced the log output above...

    /** Retrieves the URL from the given resource as System ID. Returns <code>null</code> if it cannot be opened. */
    public static String getSystemId(Resource resource) {
        try {
        	logger.info("resource URL -" + resource.getURL());
        	logger.info("resource URL external form-" + resource.getURL().toExternalForm());
            return new URI(resource.getURL().toExternalForm()).toString();
        catch (IOException e) {
        	logger.info("IOException -",e);
            return null;
        catch (URISyntaxException e) {
        	logger.info("URISyntaxException -",e);
            return null;

Comment by David Nee [ 18/Jan/12 ]

Apologies for the bad formatting...I will read the JIRA Help before I submit again.

Comment by Arjen Poutsma [ 19/Jan/12 ]

Added formatting.

Comment by Arjen Poutsma [ 24/Jan/12 ]


Comment by Arjen Poutsma [ 04/May/12 ]

Closing old issues

Generated at Sat Oct 19 12:46:03 UTC 2019 using Jira 7.13.8#713008-sha1:1606a5c1e7006e1ab135aac81f7a9566b2dbc3a6.