Author: dkulp Date: Thu Oct 25 14:55:26 2012 New Revision: 1402176 URL: http://svn.apache.org/viewvc?rev=1402176&view=rev Log: Merged revisions 1401439 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes
........ r1401439 | dkulp | 2012-10-23 16:19:25 -0400 (Tue, 23 Oct 2012) | 10 lines Merged revisions 1401419 via git cherry-pick from https://svn.apache.org/repos/asf/cxf/trunk ........ r1401419 | dkulp | 2012-10-23 15:50:50 -0400 (Tue, 23 Oct 2012) | 2 lines [CXF-4564] Try to work around a bug in JAXB 2.2 that causes problems if the initial source location is a jar: URL but imports/includes are then absolute URL's. Not a complete workaround, but at least helps SOME cases. ........ ........ Modified: cxf/branches/2.5.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java Modified: cxf/branches/2.5.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java?rev=1402176&r1=1402175&r2=1402176&view=diff ============================================================================== --- cxf/branches/2.5.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java (original) +++ cxf/branches/2.5.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java Thu Oct 25 14:55:26 2012 @@ -65,6 +65,7 @@ import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.Locator; import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; import org.xml.sax.helpers.XMLFilterImpl; import com.sun.codemodel.ClassType; @@ -79,6 +80,7 @@ import com.sun.tools.xjc.Driver; import com.sun.tools.xjc.ErrorReceiver; import com.sun.tools.xjc.Options; import com.sun.tools.xjc.Plugin; +import com.sun.tools.xjc.XJCListener; import com.sun.tools.xjc.api.Mapping; import com.sun.tools.xjc.api.Property; import com.sun.tools.xjc.api.S2JJAXBModel; @@ -123,9 +125,47 @@ import org.apache.ws.commons.schema.XmlS import org.apache.ws.commons.schema.XmlSchemaSerializer.XmlSchemaSerializerException; public class JAXBDataBinding implements DataBindingProfile { + static final String XJCVERSION; + static { + + VersionDetectListener listener = new VersionDetectListener(); + try { + Driver.run(new String[] {"-version"}, listener); + } catch (BadCommandLineException e) { + // + } + XJCVERSION = listener.getVersion(); + } + + static final class VersionDetectListener extends XJCListener { + private String s = "2.1"; + VersionDetectListener() { + } + public String getVersion() { + return s; + } + public void error(SAXParseException exception) { + } + + public void fatalError(SAXParseException exception) { + } + public void warning(SAXParseException exception) { + } - public class LocationFilterReader extends StreamReaderDelegate implements XMLStreamReader { + public void info(SAXParseException exception) { + } + + public void message(String msg) { + if (msg.contains(" ")) { + msg = msg.substring(msg.indexOf(' ')).trim(); + } + if (!StringUtils.isEmpty(msg)) { + s = msg; + } + } + } + public class LocationFilterReader extends StreamReaderDelegate { boolean isImport; boolean isInclude; int locIdx = -1; @@ -196,6 +236,11 @@ public class JAXBDataBinding implements } private String mapSchemaLocation(String target) { + //See http://java.net/jira/browse/JAXB-925 + if (this.getLocation().getSystemId().startsWith("jar:") + && XJCVERSION.startsWith("2.2")) { + return target; + } return JAXBDataBinding.mapSchemaLocation(target, this.getLocation().getSystemId(), catalog); } @@ -460,6 +505,11 @@ public class JAXBDataBinding implements || "include".equals(localName))) { String s = atts.getValue("schemaLocation"); if (!StringUtils.isEmpty(s)) { + //See http://java.net/jira/browse/JAXB-925 + if (locator.getSystemId().startsWith("jar:") + && XJCVERSION.startsWith("2.2")) { + return s; + } s = JAXBDataBinding.mapSchemaLocation(s, locator.getSystemId(), catalog); } return s;
