• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 826
  • Last Modified:

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
0
dkim18
Asked:
dkim18
  • 2
1 Solution
 
mccarlIT Business Systems Analyst / Software DeveloperCommented:
I'm surprised that it even worked in Tomcat 6. Unless I'm missing something big here, it seems pretty obvious that it would be the first servlet definition that you have; it has NO name, and further to that is has no class either so I don't even know WHY it would be there in the first place. Try removing it and see how you go.
0
 
dkim18Author Commented:
It worked! Thanks!
0
 
mccarlIT Business Systems Analyst / Software DeveloperCommented:
You're welcome!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now