Reputation: 1826
I am trying to teach myself Java, Java EE, and Tomcat pretty much all at once.
(Experienced C/Obj-C dev)
I was following a tutorial at YouTube at: http://www.youtube.com/watch?v=bd50C6XUnFw
I am running:
The error I'm seeing is:
SEVERE: Parse error in application web.xml file at jndi:/localhost/FirstServlet/WEB-INF/web.xml
org.xml.sax.SAXParseException; systemId: jndi:/localhost/FirstServlet/WEB-INF/web.xml; lineNumber: 8; columnNumber: 19; Error at (8, 19) : Can't convert argument: null
at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2687)
at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2719)
at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1054)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609)
As shown in the video the web.xml (at path /Library/Tomcat/webapps/firstservlet/WEB-INF
) is:
<web-app>
<servlet>
<servlet-name>My FirstServlet</servlet-name>
<servlet-class>FirstServlet</servlet-class>
</servlet>
<servlet-mapping>
<url-pattern>/myfirstservlet</url-pattern>
</servlet-mapping>
</web-app>
The error indicates that the issue is a null it's hitting after the </servlet-mapping>
So my only assumption is that the tutorial on YouTube is missing something and I must be missing an argument. Suggestions strongly welcomed.
Upvotes: 2
Views: 20460
Reputation: 718787
Suggestions strongly welcomed.
Don't rely on a single tutorial as your sole source of information ...
These things are specified. If you have doubts about the accuracy of a "secondary source" such as a dubious tutorial video, look at the specification.
If reading a specification is too difficult for you1, then look for a reliable tutorial; e.g. for Java-related stuff, look for one written by Oracle.
1 - People who label a specification "obtuse" are probably missing the real point of the specification. A good specification is written with accuracy, precision and completeness as its primary goals. A (so-called) specification that reads like a tutorial is most likely not meeting its primary goals properly.
In this case, the Servlet spec 3.0 (section 14.4.11) makes it clear that you need a servlet-name
element to say what Servlet the matching requests are mapped to.
(You could most likely find the same information in other tutorials, etcetera ...)
Upvotes: 0
Reputation: 13334
I believe you're missing <servlet-name>...</servlet-name>
in <servlet-mapping>
section:
<servlet-mapping>
<servlet-name>My FirstServlet</servlet-name>
<url-pattern>/myfirstservlet</url-pattern>
</servlet-mapping>
Have a look at basic web.xml file
Upvotes: 3
Reputation: 1900
Between the element servlet-mapping the element servlet-name is missing
<servlet-mapping>
<servlet-name>MyFirstServlet</servlet-name>
<url-pattern>/myfirstservlet</url-patter>
</servlet-mapping>
The servlet name is a kind of id which creates a relationship between url and the guven Servlet class.
Upvotes: 1