Link to home
Start Free TrialLog in
Avatar of dkim18
dkim18

asked on

web.xml works with Tomcat 6, but not with Tomcat 7 - Invalid <servlet-name> [] in servlet definition error.

Hi Experts,

I am upgrading Struts framework web app with Tomcat 7(it was running with Tomcat 6 before.) and I am having this error when I start tomcat 7 from eclipse.

Mar 11, 2015 1:51:59 AM org.apache.tomcat.util.digester.Digester endElement
SEVERE: End event threw exception
java.lang.reflect.InvocationTargetException
      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.IntrospectionUtils.callMethodN(IntrospectionUtils.java:905)
      at org.apache.tomcat.util.digester.CallMethodRule.end(CallMethodRule.java:532)
      at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1063)
      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
      at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
      at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
      at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
      at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1561)
      at org.apache.catalina.startup.ContextConfig.parseWebXml(ContextConfig.java:1843)
      at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1263)
      at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:889)
      at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:386)
      at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
      at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5412)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
      at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
      at java.util.concurrent.FutureTask.run(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Invalid <servlet-name> [] in servlet definition.
      at org.apache.catalina.deploy.ServletDef.setServletName(ServletDef.java:113)
      ... 35 more
Mar 11, 2015 1:51:59 AM org.apache.catalina.startup.ContextConfig parseWebXml
SEVERE: Parse error in application web.xml file at jndi:/localhost/oir/WEB-INF/web.xml
java.lang.IllegalArgumentException: Invalid <servlet-name> [] in servlet definition.
      at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2711)
      at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2743)
      at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1066)
      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
      at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
      at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
      at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
      at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1561)
      at org.apache.catalina.startup.ContextConfig.parseWebXml(ContextConfig.java:1843)
      at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1263)
      at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:889)
      at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:386)
      at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
      at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5412)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
      at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
      at java.util.concurrent.FutureTask.run(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Invalid <servlet-name> [] in servlet definition.
      at org.apache.catalina.deploy.ServletDef.setServletName(ServletDef.java:113)
      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.IntrospectionUtils.callMethodN(IntrospectionUtils.java:905)
      at org.apache.tomcat.util.digester.CallMethodRule.end(CallMethodRule.java:532)
      at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1063)
      ... 28 more

Since the error says it caused by Invalid <servlet-name> and this is a part of the web.xml:
...
...
...
<servlet>
		<servlet-name />
		<servlet-class />
		<init-param>
			<param-name>debug</param-name>
			<param-value>2</param-value>
		</init-param>
		<load-on-startup>2</load-on-startup>
	</servlet>
	<servlet>
		<servlet-name>action</servlet-name>
		<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
		<init-param>
			<param-name>config</param-name>
			<param-value>/WEB-INF/struts-config.xml</param-value>
		</init-param>
		<load-on-startup>2</load-on-startup>
	</servlet>
	<servlet>
		<servlet-name>debugjsp</servlet-name>
		<description>Added to compile JSPs with debug info</description>
		<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
		<init-param>
			<param-name>classdebuginfo</param-name>
			<param-value>true</param-value>
		</init-param>
		<load-on-startup>3</load-on-startup>
	</servlet>
	<servlet>
		<servlet-name>imageservlet</servlet-name>
		<servlet-class>org.abc.servlet.ImageGeneratorServlet</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>imageservlet</servlet-name>
		<url-pattern>/imageservlet</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>action</servlet-name>
		<url-pattern>*.do</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>debugjsp</servlet-name>
		<url-pattern>*.jsp</url-pattern>
	</servlet-mapping>
...
...
...

Open in new window


Any ideas?

thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of mccarl
mccarl
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dkim18
dkim18

ASKER

It worked! Thanks!
You're welcome!