I'm iterating on a small app using CXF/JAX-RS running on TomEE. I had the REST
service almost working, except for a problem with the controller instance being
created on each request (which I asked on a separate note).
I decided that I wanted to rename the project in Eclipse. It wouldn't let me
rename it so I just clone the app to a new name and removed the old app from
the server. I changed the package paths and also the "id" value for the jax-rs
server in the spring context.
After doing all that, the app is now failing to start with some weird errors.
I'm seeing the following stacktrace:
--------------------
2016-08-04 15:58:52,403 WARN [localhost-startStop-1]
support.AbstractApplicationContext (AbstractApplicationContext.java:549) -
Exception encountered during context initialization - cancelling refresh
attempt: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'OrdersServer': Invocation of init method failed;
nested exception is org.apache.cxf.service.factory.ServiceConstructionException
2016-08-04 15:58:52,407 ERROR [localhost-startStop-1] context.ContextLoader
(ContextLoader.java:351) - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'OrdersServer': Invocation of init method failed; nested exception is
org.apache.cxf.service.factory.ServiceConstructionException
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
...
Caused by: org.apache.cxf.service.factory.ServiceConstructionException
at
org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:219)
...
Caused by: java.lang.ClassCastException: Cannot cast
org.apache.cxf.management.jmx.InstrumentationManagerImpl to
org.apache.cxf.management.InstrumentationManager
at java.lang.Class.cast(Unknown Source)
at
org.apache.cxf.bus.extension.ExtensionManagerImpl.getBeanOfType(ExtensionManagerImpl.java:322)
at
org.apache.cxf.bus.spring.SpringBeanLocator.getBeanOfType(SpringBeanLocator.java:128)
...
-----------------
This is the body of my Spring context:
---------
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<context:property-placeholder location="classpath:env-${env}.properties" />
<context:component-scan base-package="com.att.ordersservice.service"/>
<jaxrs:server id="OrdersServer" address="/">
<jaxrs:serviceBeans>
<ref bean="ordersController"/>
</jaxrs:serviceBeans>
<jaxrs:extensionMappings>
<entry key="json" value="application/json" />
<entry key="xml" value="application/xml" />
</jaxrs:extensionMappings>
</jaxrs:server>
<bean id="ordersController"
class="com.att.ordersservice.controller.OrdersController"></bean>
<jee:jndi-lookup jndi-name="${jndiPrefix}/sus2" id="sus2ds"/>
<bean class="com.att.ordersservice.dao.OrdersDAO" p:name="ordersDAO"
p:dataSource-ref="sus2ds"/>
--------------
Note that despite the end of the stacktrace, I'm not attempting to configure
JMX here.