That is because rampart-policy and rampart-core both contain a META-INF/services/org.apache.neethi.builders.AssertionBuilder resource. If you want to produce a single JAR file including the Rampart classes, then you need to merge the contents of these files into a single file.
Andreas On Fri, Apr 19, 2013 at 1:14 AM, Rostom A <rosto...@yahoo.com> wrote: > I have a strange problem, which I'm hoping someone can help me with... > > I am using axis2 ADB bindings and Rampart to make a call to a web service as > a client. Everything works fine when I am in Eclipse (using Maven). > However, when I expand all the dependent JAR files and build a single JAR > file of my code (using Maven) and its dependencies, then run the same main > class/method, it fails with the following error: > > java.lang.RuntimeException: Undefined 'Security policy namespace cannot be > null.' resource property > > After some analysis, I seem to have found the root cause, but just don't > know how to fix it. The problem seems to be that when the Policy object is > built, it isn't associating the correct Assertion classes within it. Here > is the code that I used to discover this: > > StAXOMBuilder builder = new StAXOMBuilder(policyXmlPath); //policyXmlPath > is the full path to my policy.xml file > Policy servicePolicy = PolicyEngine.getPolicy(builder.getDocumentElement()); > List it = (List)servicePolicy.getAlternatives().next(); > for (int i=0; i<it.size(); i++) { > Assertion assertion = (Assertion)it.get(i); > logger.debug("i: %s | type: %s | name: %s | namespace uri: > %s", i, assertion.getClass().getName(), assertion.getName(), > assertion.getName().getNamespaceURI()); > } > > The printout I get from Eclipse is: > > i: 0 | type: org.apache.ws.secpolicy.model.AsymmetricBinding | name: > {http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}AsymmetricBinding | > namespace uri: http://schemas.xmlsoap.org/ws/2005/07/securitypolicy > i: 1 | type: org.apache.ws.secpolicy.model.Wss10 | name: > {http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}Wss10 | namespace > uri: http://schemas.xmlsoap.org/ws/2005/07/securitypolicy > i: 2 | type: org.apache.ws.secpolicy.model.SignedEncryptedParts | > name: {http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}SignedParts | > namespace uri: http://schemas.xmlsoap.org/ws/2005/07/securitypolicy > i: 3 | type: org.apache.rampart.policy.model.RampartConfig | name: > {http://ws.apache.org/rampart/policy}RampartConfig | namespace uri: > http://ws.apache.org/rampart/policy > > Whereas the printout I get from running the main class via the JAR file is: > > i: 0 | type: > org.apache.neethi.builders.PolicyContainingPrimitiveAssertion | name: > {http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}AsymmetricBinding | > namespace uri: http://schemas.xmlsoap.org/ws/2005/07/securitypolicy > i: 1 | type: > org.apache.neethi.builders.PolicyContainingPrimitiveAssertion | name: > {http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}Wss10 | namespace > uri: http://schemas.xmlsoap.org/ws/2005/07/securitypolicy > i: 2 | type: org.apache.neethi.builders.xml.XmlPrimitiveAssertion | > name: {http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}SignedParts | > namespace uri: http://schemas.xmlsoap.org/ws/2005/07/securitypolicy > i: 3 | type: org.apache.rampart.policy.model.RampartConfig | name: > {http://ws.apache.org/rampart/policy}RampartConfig | namespace uri: > http://ws.apache.org/rampart/policy > > Notice that in the latter case, the first two are the generic > PolicyContainingPrimitiveAssertion rather than the more specific > AsymmetricBinding and Wss10 classes, respectively. I do in fact have all > the files from rampart-policy and rampart-trust (which originally > encapsulated these two classes) in my JAR file. So why then is it not > binding them to what it finds from the policy.xml file? > > Any help would be greatly appreciated. > > --rostom --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@axis.apache.org For additional commands, e-mail: java-user-h...@axis.apache.org