Tuesday, 16 June 2009

WLS 10.3 WSDL external policy attachment error

We recently encountered an issue with deploying JAX-WS web services to Oracle WebLogic Server 10.3 where the web service WSDL included a <wsp:policyReference> external policy attachment.

The error:

javax.xml.ws.WebServiceException: weblogic.wsee.ws.init.WsDeploymentException: Unable to to retrieve policy from URI 'externalpolicy.xml'
at weblogic.wsee.jaxws.framework.jaxrpc.TubelineDeploymentListener.createServer(TubelineDeploymentListener.java:85)
at weblogic.wsee.jaxws.WLSTubelineAssemblerFactory$TubelineAssemblerImpl.createServer(WLSTubelineAssemblerFactory.java:74)
at com.sun.xml.ws.server.WSEndpointImpl.(WSEndpointImpl.java:152)
at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:217)
at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:467)
Truncated. see log file for complete stacktrace
Note the name of the policy file in the error: externalpolicy.xml

Our WSDL included the following binding options referring to the external policy file:














Note the use of the <wsp:PolicyReference> tag with the URI attribute referring to the externalpolicy.xml file located in the same src directory as the WSDL.

The externalpolicy.xml included an MTOM policy, ultimately nothing special:


xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:wsoma="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization"
xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200512">




The deployment problem is caused because by default WLS isn't configured to search for external policy files on the CLASSPATH of the application.

The fix is however simple (and somewhat obscurely documented here)

Locate your WLS %domain_home%/bin/startWebLogic.cmd file and replace the following line:

set JAVA_OPTIONS=%SAVE_JAVA_OPTIONS%

..to..

set JAVA_OPTIONS=-Dweblogic.wsee.policy.LoadFromClassPathEnabled=true %SAVE_JAVA_OPTIONS%

1 comment:

Gerard Davison said...

Chris,

It is worth also placing custom external policies under META-INF/policies, just make sure you use the policy: url prefix.

That way you can do without the LoadFromClassPathEnabled hack'et.

Gerard