Hi, one needs to switch to javax.ws.rs-api-m10 dependency, when
migrating RS endpoints to CXF 2.7.x
Sergey
On 10/06/13 15:56, allam wrote:
Hello,
I used before cxf 2.5.10 and 2.4 and I would like to switch now on the
latest version, cxf 2.7.5.
However, I had a restful example which turn successfully in the old
version
but not in the new one.
My example is configured using spring library and Java SE 6.0.
Here is the configuration of my beans.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<jaxrs:server id="test" address="/">
<jaxrs:serviceBeans>
<ref bean="myWebService" />
</jaxrs:serviceBeans>
</jaxrs:server>
<bean id="myWebService" class="server2.Service" />
</beans>
I tried to modify it into:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/core
http://cxf.apache.org/schemas/core.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<jaxrs:server id="testAutomateRestfulStateless" address="/">
<jaxrs:serviceBeans>
<ref bean="myWebService" />
</jaxrs:serviceBeans>
<jaxrs:features>
<cxf:logging />
</jaxrs:features>
</jaxrs:server>
<bean id="myWebService" class="server.Service" />
</beans>
but I get always the same exception:
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating
bean
with name 'org.apache.cxf.bus.spring.BusApplicationListener' defined in
class path resource [META-INF/cxf/cxf.xml]: Initialization of bean
failed;
nested exception is
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'cxf' defined in class path resource
[META-INF/cxf/cxf.xml]: Instantiation of bean failed; nested exception
is
org.springframework.beans.BeanInstantiationException: Could not
instantiate
bean class [org.apache.cxf.bus.CXFBusImpl]: Constructor threw exception;
nested exception is java.lang.ExceptionInInitializerError
Caused by: org.springframework.beans.factory.BeanCreationException:
Error
creating bean with name 'cxf' defined in class path resource
[META-INF/cxf/cxf.xml]: Instantiation of bean failed; nested exception
is
org.springframework.beans.BeanInstantiationException: Could not
instantiate
bean class [org.apache.cxf.bus.CXFBusImpl]: Constructor threw exception;
nested exception is java.lang.ExceptionInInitializerError
Caused by: org.springframework.beans.BeanInstantiationException: Could
not
instantiate bean class [org.apache.cxf.bus.CXFBusImpl]: Constructor
threw
exception; nested exception is java.lang.ExceptionInInitializerError
Caused by: java.lang.ExceptionInInitializerError
at org.apache.cxf.bus.CXFBusImpl.<init>(CXFBusImpl.java:54)
at org.apache.cxf.bus.CXFBusImpl.<init>(CXFBusImpl.java:41)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:85)
at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:757)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:722)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:386)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:757)
at
org.apache.cxf.bus.spring.BusExtensionPostProcessor.getBus(BusExtensionPostProcessor.java:62)
at
org.apache.cxf.bus.spring.BusExtensionPostProcessor.postProcessBeforeInitialization(BusExtensionPostProcessor.java:53)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:302)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1168)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:248)
at
org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:820)
at
org.springframework.context.support.AbstractApplicationContext.registerListeners(AbstractApplicationContext.java:597)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:349)
at
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:189)
at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
at
org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
at
org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.IllegalArgumentException: org.apache.cxf.Messages
!=
org.apache.cxf.APIMessages
at java.util.logging.Logger.getLogger(Logger.java:337)
at
org.apache.cxf.common.logging.LogUtils.createLogger(LogUtils.java:210)
at
org.apache.cxf.common.logging.LogUtils.getL7dLogger(LogUtils.java:152)
at org.apache.cxf.BusFactory.<clinit>(BusFactory.java:39)
... 40 more
Jun 10, 2013 4:11:10 PM org.apache.catalina.core.StandardContext
listenerStart
SEVERE: 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 'org.apache.cxf.bus.spring.BusApplicationListener' defined in
class path resource [META-INF/cxf/cxf.xml]: Initialization of bean
failed;
nested exception is
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'cxf' defined in class path resource
[META-INF/cxf/cxf.xml]: Instantiation of bean failed; nested exception
is
org.springframework.beans.BeanInstantiationException: Could not
instantiate
bean class [org.apache.cxf.bus.CXFBusImpl]: Constructor threw exception;
nested exception is java.lang.ExceptionInInitializerError
Caused by: org.springframework.beans.factory.BeanCreationException:
Error
creating bean with name 'cxf' defined in class path resource
[META-INF/cxf/cxf.xml]: Instantiation of bean failed; nested exception
is
org.springframework.beans.BeanInstantiationException: Could not
instantiate
bean class [org.apache.cxf.bus.CXFBusImpl]: Constructor threw exception;
nested exception is java.lang.ExceptionInInitializerError
Caused by: org.springframework.beans.BeanInstantiationException: Could
not
instantiate bean class [org.apache.cxf.bus.CXFBusImpl]: Constructor
threw
exception; nested exception is java.lang.ExceptionInInitializerError
Caused by: java.lang.ExceptionInInitializerError
at org.apache.cxf.bus.CXFBusImpl.<init>(CXFBusImpl.java:54)
at org.apache.cxf.bus.CXFBusImpl.<init>(CXFBusImpl.java:41)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:85)
at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:757)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:722)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:386)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:757)
at
org.apache.cxf.bus.spring.BusExtensionPostProcessor.getBus(BusExtensionPostProcessor.java:62)
at
org.apache.cxf.bus.spring.BusExtensionPostProcessor.postProcessBeforeInitialization(BusExtensionPostProcessor.java:53)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:302)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1168)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:248)
at
org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:820)
at
org.springframework.context.support.AbstractApplicationContext.registerListeners(AbstractApplicationContext.java:597)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:349)
at
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:189)
at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
at
org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
at
org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.IllegalArgumentException: org.apache.cxf.Messages
!=
org.apache.cxf.APIMessages
at java.util.logging.Logger.getLogger(Logger.java:337)
at
org.apache.cxf.common.logging.LogUtils.createLogger(LogUtils.java:210)
at
org.apache.cxf.common.logging.LogUtils.getL7dLogger(LogUtils.java:152)
at org.apache.cxf.BusFactory.<clinit>(BusFactory.java:39)
... 40 more
I didn't found any information about the cause of this error.
Could I have your help please to resolve it?
Kind Regards,
Diana ALLAM
--
View this message in context:
http://cxf.547215.n5.nabble.com/RESTful-example-Switch-from-cxf-5-x-to-cxf-7-x-tp5729061.html
Sent from the cxf-user mailing list archive at Nabble.com.
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com
------------------------------
If you reply to this email, your message will be added to the discussion
below:
http://cxf.547215.n5.nabble.com/RESTful-example-Switch-from-cxf-5-x-to-cxf-7-x-tp5729061p5729063.html
To unsubscribe from RESTful example: Switch from cxf 5.x to cxf 7.x, click
here<http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5729061&code=YWxsYW1jeGZVc2VyMjAxM0BnbWFpbC5jb218NTcyOTA2MXwxNzI3MzMyODI4>
.
NAML<http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>