CFX SOAP enpoint fails when using Camunda

SO I have an existing SOAP service. I want to add some BPM to it. I deployed the demo tomcat and got everything to work fine. I deployed my .war and my CFX (3.17) SOAP services work fine. I then write a test service and add this to my context:

<jaxws:endpoint
id="bpmTest"
implementor="com.me.bpm.services.endpoint.CamundaTesterImpl"
address="/TestWorkflow" />

When I deploy this, I can call the endpoint just fine it throws an error, because I did not add the required camunda beans. So I do this and add this to my context:

  <bean name="processEngineService" class="org.camunda.bpm.BpmPlatform" factory-method="getProcessEngineService" />
  <bean name="processEngine" factory-bean="processEngineService" factory-method="getDefaultProcessEngine" />
  <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService"/>
  <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService"/>
  <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService"/>
  <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService"/>
  <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService"/>

But when I deploy, my endpoint now throws a 404. I comment those beans out, and my endpoint returns.

How do I get CFX and Camunda to play nice with each other?

Hi @mmaceachran,

are you getting any extra exceptions when both cxf and engine are declared as dependencies in the project? Can you provide a stack trace or may be a link to your project on github?

Cheers,
Askar

Ahh. So sorry, glaring error, it was in another logfile. Here is the problem:

19-Feb-2017 21:09:18.405 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStart  Exception sending context initialized event to listener instance of class  org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'repositoryService' defined in class path resource [beans.xml]: factory-bean 'processEngine' (or a BeanPostProcessor involved) returned null
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:374)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1134)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1028)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4729)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1768)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Still don’t know what I am doing wrong.

@mmaceachran, do I understand correctly that this is an embedded engine setup? If so you are missing engine beans declarations. You cant take a look here how to do it.

Cheers,
Askar

Not sure if it is relevant or if it will solve your problem, but we experienced problems when we had the CXF servlet at the root of the context. We solved it by changing the mapping in web.xml:

<servlet-mapping>
    <servlet-name>CXFServlet</servlet-name>
    <url-pattern>/services/*</url-pattern>
</servlet-mapping>

Actually the problem seemed to be Spring autowire in the SOAP Impl. You have to declare the impl as a regular bean, and then use that as your endpoint. (2 different declarations) Like this:

<bean id="bpmTestImpl" class="com.me.bpm.services.endpoint.CamundaTesterImpl" />
<jaxws:endpoint	id="bpmTestEndpoint" implementor="#bpmTestImpl"	address="/TestWorkflow" />