By default, wsdl2java hardcoded wsdl location based on the local location
(e.g. c:\java\myproject\wsdl\SessionCreate.wsdl)
This does't work during runtime, therefore I packaged all wsdl and xsd file
in the jar file and change the wsdl location of generated code to current
thread like this:
url =
((java.net.URLClassLoader)Thread.currentThread().getContextClassLoader()).findResource("com/sabre/webservices/wsdl/SessionCreateRQ.wsdl");
However, cxf complains that it cannot find the other files referenced by
wsdl file even though the file is in the jar
java.lang.RuntimeException: java.lang.RuntimeException:
org.apache.ws.commons.schema.XmlSchemaException: Unable to locate imported
document at 'http://schemas.xmlsoap.org/soap/envelope/', relative to
'jar:file:/c:/java/myproject/web/WEB-INF/lib/myjar.jar!/com/sabre/webservices/wsdl/envelope.xsd'.
The only solution is to put those xsd files in the classpath (e.g
c:/java/myproject/web/WEB-INF/classes/) instead of jar file in
'c:/java/myproject/web/WEB-INF/lib'.
Obviously this is inconvenience. How could I solve this problem?