我正在开发球衣网络服务。我能够创建一些服务并且效果很好。
当我创建这个服务MClientManagerImpl我得到下面提到的错误。
球衣将 com.vxl.service.impl.MClientManagerImpl 类型的 Spring bean mClientManager 注册为根资源类。我不明白为什么 jersey 将其注册为根资源类。
@Service("mClientManager")
@Path("/clientmanager")
public class MClientManagerImpl extends GenericManagerImpl<MClient, Long>
implements MClientManager {
MClientDao mClientDao;
@Inject
@Autowired
public MClientManagerImpl(@InjectParam MClientDao mClientDao) {
super(mClientDao);
this.mClientDao = mClientDao;
}
@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Path("/getclient")
@Override
public String getclient(String json) {
System.out.println(json);
return null;
}
}
INFO: Initializing Spring root WebApplicationContext
Oct 16, 2013 9:52:53 AM com.sun.jersey.api.core.PackagesResourceConfig init
INFO: Scanning for root resource and provider classes in the packages:
com.vxl.service
Oct 16, 2013 9:52:53 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses
INFO: Root resource classes found:
class com.vxl.service.impl.FDefectManagerImpl
class com.vxl.service.impl.FComponentCodeMetricManagerImpl
class com.vxl.service.impl.DimTestCaseManagerImpl
class com.vxl.service.impl.FProjectManagerImpl
class com.vxl.service.impl.DimOrganizationManagerImpl
class com.vxl.service.impl.DimRequirementManagerImpl
class com.vxl.service.impl.FCodingBestPracticeViolationsManagerImpl
class com.vxl.service.impl.DimDefectManagerImpl
class com.vxl.service.impl.MSourceInstanceManagerImpl
class com.vxl.service.impl.DimProjectManagerImpl
Oct 16, 2013 9:52:53 AM com.sun.jersey.api.core.ScanningResourceConfig init
INFO: No provider classes found.
Oct 16, 2013 9:52:53 AM com.sun.jersey.spi.spring.container.servlet.SpringServlet getContext
INFO: Using default applicationContext
Oct 16, 2013 9:52:53 AM com.sun.jersey.spi.spring.container.SpringComponentProviderFactory registerSpringBeans
INFO: Registering Spring bean, mClientManager, of type com.vxl.service.impl.MClientManagerImpl as a root resource class
Oct 16, 2013 9:52:53 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.8 06/24/2011 12:17 PM'
Oct 16, 2013 9:52:54 AM com.sun.jersey.spi.spring.container.servlet.SpringServlet initiate
SEVERE: Exception occurred when intialization
org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'mClientManager' must be of type [com.vxl.service.impl.MClientManagerImpl], but was actually of type [com.sun.proxy.$Proxy134]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:360)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1109)
at com.sun.jersey.spi.spring.container.SpringComponentProviderFactory$SpringManagedComponentProvider.getInstance(SpringComponentProviderFactory.java:235)
at com.sun.jersey.server.impl.component.IoCResourceFactory$SingletonWrapper.init(IoCResourceFactory.java:178)
at com.sun.jersey.server.impl.application.WebApplicationImpl$10.f(WebApplicationImpl.java:584)
at com.sun.jersey.server.impl.application.WebApplicationImpl$10.f(WebApplicationImpl.java:581)
at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
at com.sun.jersey.server.impl.application.WebApplicationImpl.getResourceComponentProvider(WebApplicationImpl.java:581)
at com.sun.jersey.server.impl.application.WebApplicationImpl.initiateResource(WebApplicationImpl.java:658)
at com.sun.jersey.server.impl.application.WebApplicationImpl.initiateResource(WebApplicationImpl.java:653)
at com.sun.jersey.server.impl.application.RootResourceUriRules.<init>(RootResourceUriRules.java:124)
at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1298)
at com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:169)
at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:775)
at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:771)
at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:771)
at com.sun.jersey.spi.spring.container.servlet.SpringServlet.initiate(SpringServlet.java:117)
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:318)
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:609)
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:210)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:373)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:556)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
我用谷歌搜索但没有得到答案,请帮助我。