开发者

Spring Web App - CannotLoadBeanClassException caused by Java.lang.ClassNotFoundException

Iv been struggling with this for a while now an I have exhausted all my possible solutions so any help is greatly appreciated.

This is a simple web app used to test Springs SimpleJdbcTemplate running on a web app, tho when deployed i get the following error message in the Tomcat Logs

   10-Jan-2011 18:12:36 org.springframework.web.context.ContextLoader initWebApplicationContext
SEVERE: Context initialization failed
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [example.jersey.spring.dao] for bean with name 'testDAO' defined in class path resource [ApplicationContext.xml]; nested exception is java.lang.ClassNotFoundException: example.jersey.spring.dao
 at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1141)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:524)
 at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1177)
 at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:758)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:422)
 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
 at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
 at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
 at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
 at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:905)
 at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:525)
 at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1359)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
 at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(Unknown Source)
 at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(Unknown Source)
 at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1500)
 at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:670)
 at org.apache.catalina.manager.ManagerServlet.doPut(ManagerServlet.java:435)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:640)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:558)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
 at java.lang.Thread.run(Unknown Source)
Caused bmore
y: java.lang.ClassNotFoundException: example.jersey.spring.dao
 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
 at org.springframework.util.ClassUtils.forName(ClassUtils.java:211)
 at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:385)
 at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1138)
 ... 42 10-Jan-2011 18:12:36 org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart

Now the file is on the tomcat server as I have checked this manually. I have also checked the application context file and the reference is correct . The source folders are also all on the classpath so this doesnt seem to be the issue either.

<bean id="testDAO" class="example.jersey.spring.dao">
        <property name="dataSource" ref="dataSource"/>
    </bean>

So this has left me pointing at the POM file is it possible that I have an lesser version of spring or am perhaps missing some JARs i am new to Spring so I am not 100 percent on what i should have but this is the spring dependency in my POM.

<dependency>
       <groupId>com.sun.jersey.contribs</groupId>
       <artifactId>jersey-spring</artifactId>
       <version>${jersey-version}</version>
   </dependency>
     <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring</artifactId>
      <version>${spring-开发者_JS百科version}</version>
      </dependency>

Thanks any help is appreciated !


I'd bet there is no class named example.jersey.spring.dao on your classpath. Make sure you are creating beans only of existing classes. (This thing is a package most likely)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜