File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes Trying to deploy an web application on tomcat 6 and getting following error: Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Trying to deploy an web application on tomcat 6 and getting following error:" Watch "Trying to deploy an web application on tomcat 6 and getting following error:" New topic
Author

Trying to deploy an web application on tomcat 6 and getting following error:

Shriram Gopalakrishnan
Ranch Hand

Joined: Feb 20, 2007
Posts: 44
Trying to deploy an web application on tomcat 6 and getting following error:



Sep 8, 2009 11:50:36 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.access.BootstrapException: Unable to return specified BeanFactory instance: factory key [servicelayer-context], from group with resource name [classpath*:/resources/beanRefContext.xml]; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'servicelayer-context' is defined
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'servicelayer-context' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:360)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java:914)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:241)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:733)
at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:395)
at org.springframework.web.context.ContextLoader.loadParentContext(ContextLoader.java:316)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
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:526)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:850)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:518)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1473)
at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:250)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
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:525)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
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:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:619)


web.xml - entries



The classpath has spring.jar and resources folder. The same WAR works fine when deployed on JBoss server.

Appreciate any quick help.
Amit kull
Ranch Hand

Joined: Jun 05, 2008
Posts: 46
Hi,
We faced similar issue when we tried a spring-hibernate application on Tomcat. It used to work on websphere but gave problems with tomcat.
We were retrieving the .hbm.xml files from classpath.

I am not sure if this will help. But we got it working when we placed the xml files inside $TomcatHome/bin directory.

In your case I would suggest placing the resouces folder in $TomcatHome/bin folder.

If it works, could you find out the reason and let me know? We were busy then and our primary focus being Websphere, we did not bother to know the reason why it took classpath as tomcat home/ bin path. (Something to do with system path settings?)
Shriram Gopalakrishnan
Ranch Hand

Joined: Feb 20, 2007
Posts: 44
Thanks for Reply, I tried moving the folder to the bin folder and still it would give me the same error. Any other solution or suggestions?
Nickolas Case
Ranch Hand

Joined: Apr 26, 2008
Posts: 98
Your stack trace says you have no servicelayer-context bean in your /resources/beanRefContext.xml. Check your XML and if you do have that bean, paste your XML in here.
Shriram Gopalakrishnan
Ranch Hand

Joined: Feb 20, 2007
Posts: 44
>> The servicelayer-context bean exists as seen below in beanRefContext.xml. Also to mention again this WAR works fine when deployed in JBoss.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="servicelayer-context"
class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg>
<list>
<value>/resources/appContext.xml</value>
<value>/resources/spring-business.xml</value>
<value>/resources/spring-dao.xml</value>
</list>
</constructor-arg>
</bean>

</beans>
Nickolas Case
Ranch Hand

Joined: Apr 26, 2008
Posts: 98
I get the feeling your classpath is not correct. Your bean is in your XML, Tomcat just can't can't find your XML.
Shriram Gopalakrishnan
Ranch Hand

Joined: Feb 20, 2007
Posts: 44
Well have been using the same classpath in JBoss for quite sometime without any issues. Not sure if anything gets changed while migrating to Tomcat.
Nickolas Case
Ranch Hand

Joined: Apr 26, 2008
Posts: 98
Where is your spring.jar? It either needs to be in your WebContent/WEB-INF/lib or in Tomcat's lib folder.
Shriram Gopalakrishnan
Ranch Hand

Joined: Feb 20, 2007
Posts: 44
Thanks for reply, I resolved the issue by two options:

1. Either move the resources folder containing the spring related config files under classes folder.
OR
2. Copy it under main project folder parallel to src and add that as source in the build path. What happens then is that like java sources are compiled and copied to classes folder
similarly all the xml files are also copied under classes folder during Project Compilation.

Botton line is tomcat looks for these files under WEB-INF/classes folder. Yet to find solution if someone needs xml files in folder other than WEB-INF/classes.

Thanks all, also please input any comments/suggestions if any.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trying to deploy an web application on tomcat 6 and getting following error: