RSS feed for blog Linkin Skype Mail Me Twitter

Stickfight

CXF webservices on Domino

Since Domino 6 I have only seen people use Apache Axis (up to 1.4) as a web service framework and quite frankly it’s a bit long in the tooth; we want to use a newer framework and if we are sticking with the popular frameworks (i.e. native support in Eclipse), that leaves us with Axis 2 and CXF (yes yes! I know that X or Y is the latest and greatest but given the sedentary nature of large corporations I’ll settle for a functionally rich, well-rounded standard that works and in 2 years time can still be supported).

Anyhow, all my clients seem to have plumped for CXF, so this blog is to show you how to get a CXF client working on Domino 8+ (CXF needs Java 5 or greater).

I am assuming that you have already generated your class files (either via Eclipse wizards or via wsdl2J). If you have not, this is a good Link:


Normally when you are writing / testing a Java agent you just bung the supporting jar files in the agent itself, and give it a run. Unfortunately even if you get all the right jar files, you will get this error:

java.lang.NullPointerException
at org.apache.cxf.wsdl11.WSDLServiceFactory.< init> (WSDLServiceFactory.java:91)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:207)
at org.apache.cxf.jaxws.ServiceImpl.< init> (ServiceImpl.java:150)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:63)
at javax.xml.ws.Service.< init> (Service.java:67)


This means that CXF can’t verify your WSDL (yes it’s a naff error) due to security reasons, so you’re going to have to put the jar files in the ext directory on the server.

CXF uses more jar files than Axis. When you download the binary from http://cxf.apache.org you will find a “WHICH_JAR” text file in the lib directory that tells you which files you will need to include for which function. As my client is using quite a few of the extra functions (such as WS security), I ended up putting the following files in a directory called “CXF” inside the \Domino\jvm\lib\ext\ directory (the extra sub-directory is just so I don’t get the files mixed up):

- cxf.jar
- commons-logging.jar
- geronimo-activation.jar
- geronimo-annotation.jar
- geronimo-stax-api.jar
- neethi.jar
- jaxb-api.jar
- jaxb-impl.jar
- XmlSchema.jar
- wstx-asl.jar
- wsdl4j.jar
- geronimo-ws-metadata.jar
- geronimo-jaxws_2.1_spec-1.0.jar
- saaj-api.jar
- saaj-impl.jar
- asm.jar
- geronimo-servlet.jar
- jetty.jar
- jetty-util.jar
- sl4j.jar & sl4j-jdk14.jar (optional - but improves logging)
- bcprov-jdk15.jar
- xalan.jar
- serializer.jar
- wss4j.jar
- xmlsec.jar

(NOTE: If you are already using Java heavily in domino you may already some of these in your ext directory, so be careful to not double-up or give yourself conflicts).

The next bubble of joy will be the following error message (or something very similar):

java.security.AccessControlException: Access denied
(java.lang.RuntimePermission setContextClassLoader)
at java.security.AccessControlException.<init> (AccessControlException.java:62)
at java.security.AccessController.checkPermission(AccessController.java:68)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.Thread.setContextClassLoader(Thread.java:752)
at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:545)
at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:537)
at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:434)
at com.sun.xml.internal.ws.client.Stub.process(Stub.java:247)
at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(SEIStub.java:132)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:242)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:222)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:115)
at $Proxy27.getAdjustedLocationValues(Unknown Source)


This is a security message, and means you will have to edit the domino\jvm\lib\security\java.policy file. The exact entry will depend on the error you are getting, but this one:

java.security.AccessControlException: Access denied
(java.lang.RuntimePermission setContextClassLoader)


… meant I put the following lines in:

grant {
permission java.lang.RuntimePermission setContextClassLoader;
}


Restart your server and that should be it, your CXF calls should work fine.

PS. I have included full error messages to help future lost souls find this post.

PPS. This posts was corrected and sanitised by Mr Poole to make it readable (thank you)

Old Comments

Olle Thalen(05/01/2011 14:11:04 GMT)

I get the following exception all the time when I try to run a web service consumer using cxf in domino environment:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 24 in XML document from class path resource [META-INF/cxf/cxf.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element ‘beans’.
at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:97)
at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:87)
at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:65)
at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:54)
at org.apache.cxf.BusFactory.getDefaultBus(BusFactory.java:70)
at org.apache.cxf.BusFactory.getThreadDefaultBus(BusFactory.java:107)
at org.apache.cxf.BusFactory.getThreadDefaultBus(BusFactory.java:98)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:64)

Got any ideas?

Leave Your Comments

blog comments powered by Disqus

Related Entries

CXF webservices on Domino

Latest Blogs