Home » Eclipse Projects » Virgo » Web app fails to start when including ContextLoaderListener in web.xml
Web app fails to start when including ContextLoaderListener in web.xml [message #721407] |
Thu, 01 September 2011 16:48 |
pinkfloyd_360 Messages: 15 Registered: August 2011 |
Junior Member |
|
|
Hi,
I'm building a web application as a demo for all the virgo OSGi bundles and services that I created. I'm having a problem with the web application. I based my code on the virgo splash and admin web bundles.
I have a splash page (working fine with no problems) and within it I have two links: one to the admin console (working fine) and the other to a "demo" link, which points to my 'demo' web application (based on the virgo 'admin' application').
I build a PAR file, which includes those two web apps, in addition to at least 20 other modules. All are working correctly with the following exception:
1. if I include the following in the demo web.xml file, the entire PAR file doesn't deploy:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
Here's the fail message:
[2011-09-01 09:36:40.960] start-signalling-12 <DE0006E> Start failed for bundle 'framework-0.0.1-com.sample.web.demo' version '0.0.1'. org.eclipse.virgo.kernel.deployer.core.DeploymentException: Web application failed to start
at org.eclipse.virgo.web.core.internal.WebBundleLifecycleListener.onStarted(WebBundleLifecycleListener.java:132)
at org.eclipse.virgo.kernel.install.artifact.internal.StandardArtifactStateMonitor.onStarted(StandardArtifactStateMonitor.java:247)
at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact.asyncStartSucceeded(AbstractInstallArtifact.java:294)
at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact.access$0(AbstractInstallArtifact.java:291)
at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact$StateMonitorSignal.signalSuccessfulCompletion(AbstractInstallArtifact.java:229)
at org.eclipse.virgo.kernel.core.internal.BundleStartTracker$1.run(BundleStartTracker.java:143)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Caused by: org.eclipse.gemini.web.core.WebApplicationStartFailedException: org.eclipse.gemini.web.core.spi.ServletContainerException: Web application at '/demo' failed to start. Check the logs for more details.
at org.eclipse.gemini.web.internal.StandardWebApplication.start(StandardWebApplication.java:108)
at org.eclipse.virgo.web.core.internal.WebBundleLifecycleListener.onStarted(WebBundleLifecycleListener.java:122)
... 8 common frames omitted
Caused by: org.eclipse.gemini.web.core.spi.ServletContainerException: Web application at '/demo' failed to start. Check the logs for more details.
at org.eclipse.gemini.web.tomcat.internal.TomcatServletContainer.startWebApplication(TomcatServletContainer.java:125)
at org.eclipse.gemini.web.internal.StandardWebApplication.start(StandardWebApplication.java:91)
... 9 common frames omitted
2. If I remove or comment the above code from web.xml file, everything loads correctly. I'm able to access the splash page and then when I try to connect to the 'demo' page I get a 404 HTTP Error. I suspect I have incorrect url-mapping for that one.
In the next few posts, I'll attach copies of my current files.
(I'm running virgo 3.0.0.RELEASE)
[Updated on: Thu, 01 September 2011 17:01] Report message to a moderator
|
|
|
Re: Web app fails to start when including ContextLoaderListener in web.xml [message #721408 is a reply to message #721407] |
Thu, 01 September 2011 16:58 |
pinkfloyd_360 Messages: 15 Registered: August 2011 |
Junior Member |
|
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>Sample Web Demo</display-name>
<description>Sample Web Console</description>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<!-- CONFIGURE A PARENT APPLICATION CONTEXT -->
<context-param>
<param-name>contextClass</param-name>
<param-value>org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
</context-param>
<!-- Here's the declaration that is causing the problem -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- DISPATCHER SERVLET CONFIG -->
<servlet>
<servlet-name>demo</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>demo</servlet-name>
<url-pattern>/web/*</url-pattern>
</servlet-mapping>
<!-- SECURITY CONFIG -->
<security-constraint>
<web-resource-collection>
<web-resource-name>Sample Web Console</web-resource-name>
<url-pattern>/web/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Sample Web Console</realm-name>
</login-config>
<security-role>
<role-name>admin</role-name>
</security-role>
</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />
<context:component-scan base-package="com.sample.web.demo" />
<!-- VIEW CONFIG -->
<bean id="topViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="java.lang.Exception">error</prop>
</props>
</property>
<property name="warnLogCategory" value="com.sample.web.demo" />
</bean>
</beans>
Manifest-Version: 1.0
Bundle-ClassPath: WEB-INF/classes
Bundle-Version: 0.0.1
Tool: Bundlor 1.1.0.BUILD-20101220120024
Bundle-Name: Sample Web Screens
Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.sample.web.demo
Web-ContextPath: /demo
Import-Package:
org.springframework.web;version="[3.0.6.RELEASE,3.0.6.RELEASE]",
org.springframework.web.servlet.mvc;version="[3.0.5, 3.1.0)",
org.springframework.web.servlet.view;version="[3.0.5, 3.1.0)",
org.springframework.web.servlet.handler;version="[3.0.5, 3.1)",
org.springframework.web.servlet;version="[3.0.5, 3.1)",
org.springframework.web.servlet.support;version="[3.0.5, 3.1)",
org.springframework.web.context.support;version="[2.5.6, 3.1)",
org.springframework.beans.factory.xml;version="[3.0.5, 3.1.0)",
org.springframework.context.config;version="[3.0.5, 3.1.0)",
org.springframework.context.support;version="[3.0.5, 3.1.0)",
org.springframework.web.multipart.commons;version="[3.0.5, 3.1.0)",
org.eclipse.virgo.web.dm;version="[2.0.0, 4.0.0)",
javax.servlet.jsp.jstl.core;version="[1.2.0, 2.0.0)",
javax.servlet.http;version="[2.5.0, 4.0.0)"
package com.sample.web.demo;
import java.util.Map;
import java.util.TreeMap;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public final class DemoController {
/**
*
*/
@RequestMapping("/info/overview.htm")
public ModelAndView overview() {
return
new ModelAndView("info-overview").addObject("properties", this.getDemoProperties());
}
private Map<String, String> getDemoProperties() {
Map<String, String> props = new TreeMap<String, String>();
props.put("Test1", "Value1");
props.put("Test2", "Value2");
props.put("Test3", "Value3");
return props;
}
}
[Updated on: Thu, 01 September 2011 17:03] Report message to a moderator
|
|
|
Re: Web app fails to start when including ContextLoaderListener in web.xml [message #721412 is a reply to message #721408] |
Thu, 01 September 2011 17:15 |
pinkfloyd_360 Messages: 15 Registered: August 2011 |
Junior Member |
|
|
Finally, here's the template.mf file:
Manifest-Version: 1.0
Bundle-Name: Sample Demo Web Bundle
Bundle-Version: 0.0.1
Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.sample.web.demo
Bundle-ClassPath: WEB-INF/classes
Web-ContextPath: /
Import-Template:
org.springframework.*;version="[3.0.5, 3.1)",
javax.servlet.http.*;version="3.0.4",
org.osgi.framework.*;version="0"
Excluded-Exports: *
Import-Package:
org.springframework.web;version="[3.0.6.RELEASE,3.0.6.RELEASE]",
org.springframework.web.servlet.mvc;version="[3.0.5, 3.1.0)",
org.springframework.web.servlet.view;version="[3.0.5, 3.1.0)",
org.springframework.web.servlet.handler;version="[3.0.5, 3.1)",
org.springframework.web.servlet;version="[3.0.5, 3.1)",
org.springframework.web.servlet.support;version="[3.0.5, 3.1)",
org.springframework.web.context.support;version="[2.5.6, 3.1)",
org.springframework.beans.factory.xml;version="[3.0.5, 3.1.0)",
org.springframework.context.config;version="[3.0.5, 3.1.0)",
org.springframework.context.support;version="[3.0.5, 3.1.0)",
org.springframework.web.multipart.commons;version="[3.0.5, 3.1.0)",
org.eclipse.virgo.web.dm;version="[2.0.0, 4.0.0)",
javax.servlet.jsp.jstl.core;version="[1.2.0, 2.0.0)",
javax.servlet.http;version="[2.5.0, 4.0.0)"
I"m quite new to Spring MVC so I wouldn't be surprised if I made many mistakes. However, I've been comparing the code and the configuration to those of the virgo splash and admin apps and have not been able to identify the issues.
I would appreciate any assistance on this.
Thanks
|
|
| | | | | |
Re: Web app fails to start when including ContextLoaderListener in web.xml [message #724120 is a reply to message #723895] |
Sat, 10 September 2011 22:03 |
pinkfloyd_360 Messages: 15 Registered: August 2011 |
Junior Member |
|
|
Hi Dmitry,
Thanks for your advice. At this point, I'm not really concerned about optimization so if I can include entire libraries that would be fine for now and later, once I get this prototype working, I can go back and figure out what are the exact dependencies.
I added two libs but I'm still getting errors. Here's an updated copy of my MANIFEST file:
Manifest-Version: 1.0
Bundle-Name: Sample Web Bundle
Bundle-Version: 0.0.1
Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.sample.web.demo
Bundle-ClassPath: .,WEB-INF/classes,WEB-INF/lib
Web-ContextPath: /demo
Import-Bundle: org.springframework.web;version="[3.0.6.RELEASE,3.0.6.RELEASE]"
Import-Template:
javax.management.*;version=0,
javax.servlet.*;version="[2.5.0, 4.0.0)",
javax.xml.stream.*;version="0",
org.eclipse.virgo.apps.admin.*;version="[3.0.0, 3.0.1)",
org.eclipse.virgo.kernel.*;version="[3.0.0, 3.0.1)",
org.eclipse.virgo.util.*;version="[3.0.0, 3.0.1)",
org.eclipse.virgo.web.*;version="[3.0.0, 3.0.1)",
org.osgi.framework.*;version="0",
org.osgi.service.cm.*;version="0",
org.slf4j;version="[1.6.1, 2.0.0)",
org.springframework.*;version="[3.0.5, 3.1)"
Require-TldBundle: org.apache.taglibs.standard.glassfish
Import-Library:
org.springframework.spring;version="[3.0.6.RELEASE,3.0.6.RELEASE]",
org.springframework.osgi;version="[1.1.0,1.1.0]"
Import-Package:
org.apache.taglibs.standard;version="[1.1.2,2.0.0)",
org.apache.taglibs.standard.extra.spath;version="[1.1.2,2.0.0)",
org.apache.taglibs.standard.functions;version="[1.1.2,2.0.0)",
org.apache.taglibs.standard.lang.jstl;version="[1.1.2,2.0.0)",
org.apache.taglibs.standard.lang.jstl.parser;version="[1.1.2,2.0.0)",
org.apache.taglibs.standard.lang.jstl.test;version="[1.1.2,2.0.0)",
org.apache.taglibs.standard.lang.jstl.test.beans;version="[1.1.2,2.0.0)",
org.apache.taglibs.standard.lang.support;version="[1.1.2,2.0.0)",
org.apache.taglibs.standard.resources;version="[1.1.2,2.0.0)",
org.apache.taglibs.standard.tag.common.core;version="[1.1.2,2.0.0)",
org.apache.taglibs.standard.tag.common.fmt;version="[1.1.2,2.0.0)",
org.apache.taglibs.standard.tag.common.sql;version="[1.1.2,2.0.0)",
org.apache.taglibs.standard.tag.common.xml;version="[1.1.2,2.0.0)",
org.apache.taglibs.standard.tag.el.core;version="[1.1.2,2.0.0)",
org.apache.taglibs.standard.tag.el.fmt;version="[1.1.2,2.0.0)",
org.apache.taglibs.standard.tag.el.sql;version="[1.1.2,2.0.0)",
org.apache.taglibs.standard.tag.el.xml;version="[1.1.2,2.0.0)",
org.apache.taglibs.standard.tei;version="[1.1.2,2.0.0)",
org.apache.taglibs.standard.tlv;version="[1.1.2,2.0.0)",
org.springframework.web;version="[3.0.6.RELEASE,3.0.6.RELEASE]",
org.springframework.web.servlet.mvc;version="[3.0.5, 3.1.0)",
org.springframework.web.servlet.view;version="[3.0.5, 3.1.0)",
org.springframework.web.servlet.handler;version="[3.0.5, 3.1)",
org.springframework.web.servlet;version="[3.0.5, 3.1)",
org.springframework.web.servlet.support;version="[3.0.5, 3.1)",
org.springframework.web.context.support;version="[2.5.6, 3.1)",
org.springframework.beans.factory.xml;version="[3.0.5, 3.1.0)",
org.springframework.context.config;version="[3.0.5, 3.1.0)",
org.springframework.context.support;version="[3.0.5, 3.1.0)",
org.springframework.web.multipart.commons;version="[3.0.5, 3.1.0)",
org.eclipse.virgo.web.dm;version="[2.0.0, 3.0.0)",
javax.servlet.jsp.jstl.core;version="[1.2.0, 2.0.0)",
javax.servlet.http;version="[2.5.0, 4.0.0)"
Excluded-Exports: *
Excluded-Imports: org.junit,
org.eclipse.virgo.teststubs.*,
org.springframework.mock.*
I'm still having a problem with dependencies, this is the error that I'm getting now:
Hot re-deploy failed for file 'framework-0.0.1.par'. org.eclipse.virgo.kernel.deployer.core.DeploymentException: Unsatisfied dependency detected when expanding imports for [bundle 'framework-0.0.1-com.sample.web.demo' version '0.0.1' in scope 'framework-0.0.1',
|
|
|
Re: Web app fails to start when including ContextLoaderListener in web.xml [message #725506 is a reply to message #724120] |
Thu, 15 September 2011 01:42 |
pinkfloyd_360 Messages: 15 Registered: August 2011 |
Junior Member |
|
|
This is another attempt ... I see that this topic has been viewed more than 6,500 times and yet I can't find anybody who has seen this problem before?
Simply stated, the main problem is in this code in web.xml file:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
If I remove this code or comment it, the file gets deployed with no problem (of course the servlet itself does not work). If the code is present in web.xml, the file cannot be deployed, I get the following error:
[2011-09-14 18:33:52.043] start-signalling-13 <DE0006E> Start failed for bundle 'framework-0.0.1-com.sample.web.demo' version '0.0.1'. org.eclipse.virgo.kernel.deployer.core.DeploymentException: Web application failed to start
at org.eclipse.virgo.web.core.internal.WebBundleLifecycleListener.onStarted(WebBundleLifecycleListener.java:132)
at org.eclipse.virgo.kernel.install.artifact.internal.StandardArtifactStateMonitor.onStarted(StandardArtifactStateMonitor.java:247)
at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact.asyncStartSucceeded(AbstractInstallArtifact.java:294)
at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact.access$0(AbstractInstallArtifact.java:291)
at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact$StateMonitorSignal.signalSuccessfulCompletion(AbstractInstallArtifact.java:229)
at org.eclipse.virgo.kernel.core.internal.BundleStartTracker$1.run(BundleStartTracker.java:143)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Caused by: org.eclipse.gemini.web.core.WebApplicationStartFailedException: org.eclipse.gemini.web.core.spi.ServletContainerException: Web application at '/demo' failed to start. Check the logs for more details.
at org.eclipse.gemini.web.internal.StandardWebApplication.start(StandardWebApplication.java:108)
at org.eclipse.virgo.web.core.internal.WebBundleLifecycleListener.onStarted(WebBundleLifecycleListener.java:122)
... 8 common frames omitted
Caused by: org.eclipse.gemini.web.core.spi.ServletContainerException: Web application at '/demo' failed to start. Check the logs for more details.
at org.eclipse.gemini.web.tomcat.internal.TomcatServletContainer.startWebApplication(TomcatServletContainer.java:125)
at org.eclipse.gemini.web.internal.StandardWebApplication.start(StandardWebApplication.java:91)
... 9 common frames omitted
I posted all my code. I compared it to the 'admin' web module that's shipped with virgo, as well as with the greenpages.web module. I can't see any difference in the configuration files (web.xml, applicationContext.xml and demo-servlet.xml).
Can I get help with these problem, please.
Thanks.
[Updated on: Thu, 15 September 2011 01:42] Report message to a moderator
|
|
| |
Re: Web app fails to start when including ContextLoaderListener in web.xml [message #727383 is a reply to message #725519] |
Wed, 21 September 2011 06:44 |
Tin N/A Messages: 46 Registered: December 2010 |
Member |
|
|
Has the original poster managed to solve this problem? Yesterday I ran into the same thing, so I reconfigured serviceability to tracing, and this is what it says in the logs:
[2011-09-21 08:17:55.405] DEBUG fs-watcher o.s.osgi.extender.internal.activator.ContextLoaderListener Processing bundle event [STARTED] for bundle [test]
[2011-09-21 08:17:55.405] DEBUG fs-watcher o.s.osgi.extender.internal.activator.ContextLoaderListener Scanning bundle [test bundle (test)] for configurations...
[2011-09-21 08:17:55.405] DEBUG fs-watcher o.s.osgi.extender.internal.activator.ContextLoaderListener Creating an application context for bundle [test bundle (test)]
[2011-09-21 08:17:55.405] TRACE fs-watcher o.s.osgi.extender.support.ApplicationContextConfiguration Configuration: AppCtxCfg [Bundle=test]isSpringBundle=false|async=true|wait-for-deps=true|publishCtx=true|timeout=300s
[2011-09-21 08:17:55.405] TRACE fs-watcher o.s.osgi.extender.support.DefaultOsgiApplicationContextCreator Created configuration AppCtxCfg [Bundle=test]isSpringBundle=false|async=true|wait-for-deps=true|publishCtx=true|timeout=300s for bundle test bundle (test)
[2011-09-21 08:17:55.405] DEBUG fs-watcher o.s.osgi.extender.internal.activator.ContextLoaderListener No application context created for bundle [test bundle (test)]
...
[2011-09-21 08:17:55.418] TRACE Thread-42 org.springframework.osgi.util.DebugUtils Could not find class [org.springframework.web.context.request.RequestContextListener] required by [test bundle(test)] scanning available bundles
[2011-09-21 08:17:55.474] ERROR start-signalling-6 org.eclipse.gemini.web.internal.StandardWebApplication Failed to start web application at bundleContext
path '/test' org.eclipse.gemini.web.core.spi.ServletContainerException: Web application at '/test' failed to start. Check the logs for more details.
It might not be the same cause as the original, but the setup and symptoms are the same: it's a Spring MVC web bundle, containing all the required manifest headers, and it fails to start without any detailed info. Now, from what can be seen above, some of the log lines I quoted are quite critical, yet they are logged using debug or trace levels. I have yet to confirm the quoted lines indicate all of the problems that prevent my application from starting, but they do indicate some problems so shouldn't they be logged using warn or error log levels?
[Updated on: Wed, 21 September 2011 07:11] Report message to a moderator
|
|
| | | | | | | | | | |
Goto Forum:
Current Time: Thu Sep 26 00:01:46 GMT 2024
Powered by FUDForum. Page generated in 0.06358 seconds
|