Hi,
Please see below
On 22/12/11 14:20, ChrisBarsouk wrote:
Hi all,
I am trying to set up a REST service with Apache CXF v2.5.0. I am using
Felix as OSGi container together with Spring and Maven. I have configured a
simple bean that is supposed to return a String when requested. But my
current configuration is throwing the following exception when I start the
server.
Exception in thread "SpringOsgiExtenderThread-8"
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'restContainer': Error setting property values; nested exception
is org.springframework.beans.PropertyBatchUpdateException; nested
PropertyAccessExceptions (1) are:
PropertyAccessException 1:
org.springframework.beans.MethodInvocationException: Property 'serviceBeans'
threw exception; nested exception is java.lang.ExceptionInInitializerError
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1361)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
at
org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
at
org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested
PropertyAccessExceptions (1) are:
PropertyAccessException 1:
org.springframework.beans.MethodInvocationException: Property 'serviceBeans'
threw exception; nested exception is java.lang.ExceptionInInitializerError
at
org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102)
at
org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1358)
... 15 more
In my bundle-context.xml I have registered the CXFServlet and tried to
configure my REST service bean (this is where the exception is coming from):
<?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:context="http://www.springframework.org/schema/context"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
xmlns:ctx="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/osgi-compendium
http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd
">
<context:annotation-config />
<osgi:service interface="javax.servlet.Servlet">
<osgi:service-properties>
<entry key="filterMappingUrlPattern" value="/cbs_rest/*" />
<entry key="alias" value="/cbs_rest/*" />
<entry key="servlet-name" value="CXFServlet" />
<entry key="debug" value="2" />
</osgi:service-properties>
<bean class="org.apache.cxf.transport.servlet.CXFServlet"></bean>
</osgi:service>
<bean id="managerService" class="com.cbs.ui.rest.ManagerService" />
<jaxrs:server id="restContainer" address="/">
<jaxrs:serviceBeans>
<ref bean="managerService" />
</jaxrs:serviceBeans>
</jaxrs:server>
</beans>
And this is my REST service bean. The constructor is by the way not called
at all.
package com.cbs.ui.rest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Produces(MediaType.TEXT_PLAIN)
@Path("/managerservice")
public class ManagerService {
public ManagerService() {
System.out.println("ManagerService Constructor");
}
@GET
@Path("/sites")
public String getSites() {
return "Halo";
}
}
I really cannot think of a reason anymore where this exception may come
from. I hope you can help me here.
Everything looks fine to me, and the only thing I can suspect is that
may be the jax-rs bundle is not available in time ? Unfortunately no CXF
specific classes are even visible in the trace, it would help if it were
possible to get more info somehow;
Sergey
Thank you in advance,
Chris
--
View this message in context:
http://cxf.547215.n5.nabble.com/Exception-on-bean-configuration-tp5094705p5094705.html
Sent from the cxf-user mailing list archive at Nabble.com.