aspose file tools*
The moose likes Other Application Frameworks and the fly likes Using Spring from web app- class not found exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Using Spring from web app- class not found exception" Watch "Using Spring from web app- class not found exception" New topic
Author

Using Spring from web app- class not found exception

j whiting
Greenhorn

Joined: Nov 19, 2004
Posts: 11
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)
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

What is core.model.controller.DomainManger ? Does it exist ? Is there a spellmiss ?


[My Blog]
All roads lead to JavaRanch
j whiting
Greenhorn

Joined: Nov 19, 2004
Posts: 11
yes - i copied the code/package paths from the java source to paste into the XML, etc...
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Where did you put DomainManger.class exactly ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using Spring from web app- class not found exception