• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using Spring from web app- class not found exception

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using spring from a ServletContextListener and when i try to retrieve a bean configured in the bean's xml file i get a ClassNotFoundException - but all spring jars and all my source jars are in WEB-INF/lib.




Code:
--------------------------------------------------------------
ServletContextResource resource = new ServletContextResource( ce.getServletContext(), "WEB-INF" + File.separatorChar + "ContentSchemaConfig.xml" );
XmlBeanFactory factory = new XmlBeanFactory(resource);
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
Object obj = factory.getBean("CORE_DOMAIN_MANAGER");




Configuration:
-------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

<bean id="CORE_DOMAIN_MANAGER" class="core.model.controller.DomainManger" scope="singleton">
<constructor-arg>
<value>CORE_DOMAIN_MANAGER</value>
</constructor-arg>
<property name="domainDAO" ref="DomainDAO"></property>
</bean>

<bean id="DomainDAO" class="core.model.dao.DomainDAO" scope="singleton">
<!-- collaborators and configuration for this bean go here -->
</bean>

<!-- more bean definitions go here... -->

</beans>




Exception:
----------------------------------------------------------
21:31:35,453 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from ServletContext resource [/WEB-INF/ContentSchemaConfig.xml]
21:31:38,984 INFO [STDOUT] org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [core.model.controller.DomainManger] for bean with name 'CORE_DOMAIN_MANAGER' defined in ServletContext resource [/WEB-INF/ContentSchemaConfig.xml]; nested exception is java.lang.ClassNotFoundException: core.model.controller.DomainManger
21:31:38,984 INFO [STDOUT] Caused by:
21:31:38,984 INFO [STDOUT] java.lang.ClassNotFoundException: core.soapbox.model.controller.DomainManger
21:31:38,984 INFO [STDOUT] at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
21:31:38,984 INFO [STDOUT] at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
21:31:38,984 INFO [STDOUT] at org.springframework.util.ClassUtils.forName(ClassUtils.java:229)
21:31:38,984 INFO [STDOUT] at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:327)
21:31:39,000 INFO [STDOUT] at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1073)
21:31:39,000 INFO [STDOUT] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:348)
21:31:39,000 INFO [STDOUT] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
21:31:39,000 INFO [STDOUT] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
21:31:39,000 INFO [STDOUT] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
21:31:39,000 INFO [STDOUT] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
21:31:39,000 INFO [STDOUT] at core.http.context.ApplicationStartupListener.contextInitialized(ApplicationStartupListener.java:105)
21:31:39,015 INFO [STDOUT] at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3854)
21:31:39,015 INFO [STDOUT] at org.apache.catalina.core.StandardContext.start(StandardContext.java:4359)
21:31:39,015 INFO [STDOUT] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:761)
21:31:39,015 INFO [STDOUT] at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:741)
21:31:39,015 INFO [STDOUT] at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
21:31:39,015 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
21:31:39,015 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
21:31:39,015 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
21:31:39,015 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:597)
21:31:39,015 INFO [STDOUT] at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
21:31:39,015 INFO [STDOUT] at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is core.model.controller.DomainManger ? Does it exist ? Is there a spellmiss ?
 
j whiting
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes - i copied the code/package paths from the java source to paste into the XML, etc...
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where did you put DomainManger.class exactly ?
reply
    Bookmark Topic Watch Topic
  • New Topic