HTTP Status 500 wrapper can not find servlet class - java

I have created simple dynamic web project on eclipse. I am trying to submit the html form and passing the request to servlet. When I click on submit i get this exception:
HTTP Status 500 wrapper can not find servlet class com.tcs.navigator.Servlet.labServlet or a class it depends on
in jsp form actoin tag I had given same action path as per web xml which is :
action = "labServlet"
content of web.xml is :
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<welcome-file-list>
<welcome-file>home.jsp</welcome-file>
</welcome-file-list>
<servlet>
<description>To Upload Files for processing</description>
<display-name>labServlet</display-name>
<servlet-name>labServlet</servlet-name>
<servlet-class>com.tcs.navigator.Servlet.labServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>labServlet</servlet-name>
<url-pattern>/labServlet</url-pattern>
</servlet-mapping>
</web-app>
I tried following workarounds:
clean tomcat directory
open/close project
clean projects
restart eclipse
Verifying class path
created new dynamic web project with same code
But still the same exception persist.
all libraries like servlet-api.jar are present in build path.

you have kept capital S in "Servlet.labServlet" . system is getting it as a Class named Servlet. name your servlet starting with caps like "LabServlet" in the code and start all your package name with small letters. so your complete class path should be
com.tcs.navigator.servlets.LabServlet

Related

How to change path to index.html (AngularJS) in GAE j2ee

I have a j2ee app running on GAE. There is that pre-generated index.html, which is called every time I run the server - let's say http://localhost:8080. But I want to write my own front-end using AngularJS. For that, I created the whole project with Yeoman and copied all the files to folder in my j2ee project.
Right now -> I can call manually the AngularJS webapp like this: http://localhost:8080/webapp/app/index.html
But obviously, that is not the way one wants to go. I would like to call it simply on http://localhost:8080. How can I achieve this?
So it took me longer than expected, but here's how I got it working using the welcome file:
Here's my folder structure:
web.xml file:
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<servlet>
<servlet-name>So123</servlet-name>
<servlet-class>so123.So123Servlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>So123</servlet-name>
<url-pattern>/so123</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>webapp/app/index.html</welcome-file>
</welcome-file-list>
</web-app>
Hope this helps.
https://developers.google.com/appengine/docs/java/config/webxml#The_Welcome_File_List
You can also change the root directory in the appengine-web.xml file. Full documentation here.
<public-root>/app</public-root>

Deploying WebContent folder from github as a WAR file

I downloaded the following project as a zip file from https://github.com/blueimp/jQuery-File-Upload
I was hoping to use my IDE to build me a WAR file but gave up after encountering some netbeans related dependencies.
After I managed to compile it in eclipse and obtained a classes directory which I placed within the WEB-INF folder of WebContent.
The webContent folder looks like a an average WAR folder so I zipped up WebContent and renamed it to WebContent.war which I deployed into my tomcat 6 webapps directory. I am using the same JRE as I compiled it within to run tomcat.
However it won't run.
Content of the web.xml (located in WEB-INF is:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 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">
<display-name>fileupload</display-name>
<servlet-mapping>
<servlet-name>UploadServlet</servlet-name>
<url-pattern>/UploadServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<description/>
<display-name>UploadServlet</display-name>
<servlet-name>UploadServlet</servlet-name>
<servlet-class>info.sudr.file.UploadServlet</servlet-class>
</servlet>
</web-app>
I can see the following message in my tomcat error log:
28-Dec-2013 20:20:27 org.apache.catalina.startup.ContextConfig applicationWebConfig
SEVERE: Parse error in application web.xml file at jndi:/localhost/WebContent/WEB-INF/web.xml
java.lang.IllegalArgumentException: Servlet mapping specifies an unknown servlet name UploadServlet
If I then remove the following from web.xml (or move it to below the definition containing the servlet class):
<servlet-mapping>
<servlet-name>UploadServlet</servlet-name>
<url-pattern>/UploadServlet</url-pattern>
</servlet-mapping>
I can see the bear bones html of the index.html located in WebContent but I can't access the servlet itself.
Am I right to suspect the form action being called in the index.html may need some mapping in the web.xml file also as I do not see how upload can do anything:
<form id="fileupload" action="upload" method="POST" enctype="multipart/form-data">
I have tried changing action to action="UploadServlet" and action="/UploadServlet" but to no avail.
I have uploaded the WAR file here (Just click the smaller download button in the middle!)

How to configure the Project ( depends on maven/web.xml/servlet APi) AJAX call not to include the Project name in it?

I am trying to deploy my WAR in TOMCAT server, and i am using MAVEN 2. My Project name is
"Jira-Synchronization". My project is a simple Ajax call and returns result to display to the user. I have only one page( that's the scope of my project). This is how i made the Ajax call and web.xml
$.getJSON('/Jira-Synchronization/jirarequest','OK', function(jiraData)
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>Jira-Synchronization</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>JiraSyncServlet</servlet-name>
<servlet-class>JiraSyncServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>JiraSyncServlet</servlet-name>
<url-pattern>/jirarequest/*</url-pattern>
</servlet-mapping>
if you notice the ajax call is taking the Project name( first i felt weired why it is doing that and to move on with the project i just kept it that way) and every thing worked fine inside eclipse running tomcat(This is the URL i used when running from eclipse http://localhost:8080/Jira-Synchronization/index.html).
When i tried to build it using maven and deploy in tomcat(out side of eclipse) the War is made using this name "Jira-Synchronization-0.0.1-SNAPSHOT. My URL has changed tohttp://localhost:8080/Jira-Synchronization-0.0.1-SNAPSHOT/index.html and now my Ajax call which have my project name in it is also need to be changed. this is how my pom.xml looks like
How should i configure my web.xml or pom.xml so that the ajax request excludes the project name to it?
What worked for me is in the Pom.xml i added this <finalName>Jira-Synchronization</finalName> under the <build> tag and that was able to output the WAR with the desired name as i like

can i use "index" as the name of the servlet name?

I am getting this error in RAD Web Application 3.0 Deployment Descriptor Editor:
Servlet Mapping (index):
Servlet Name:The value is not among the
possible selections
Then under my Markers:
Web Problem:
The servlet mapping "index" refers to a servlet that is
not defined
web.xml
/myweb/WebContent/WEB-INF
Unknown Web Problem
My web.xml as follows:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp" version="3.0" 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_3_0.xsd">
...
<servlet>
<display-name>index</display-name>
<servlet-name>index</servlet-name>
<jsp-file>/jsp/index.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>index</servlet-name>
<url-pattern>/index</url-pattern>
</servlet-mapping>
...
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
wonder what am i doing wrong..?
Its possible to map your servlet to /index, but if you want it at the root address you need to map it at /
Error I think is in the url pattern which you are using
use /index
at welcome file list name
or directly specify
/jsp/index.jsp
I just commented the declarations, saved and rebuild the project..
then it disappeared..
uncomment them back and seems ok again.. #.#
must have been one of those days..
first, for the servlet-name of index must be allowed.
then, where dose your servlet-class locate? is it in the src directory?
please make sure. Good luck!

appengine java development server displaying source code

When I access a jsp page like this on an appengine development server:
localhost:8888/index.jsp/
it's displaying the source code of index.jsp in the browser. if you access without the trailing slash (i.e. index.jsp) then it renders jsp but with the trailing slash (i.e. index.jsp/) it displays the source code
Any idea why is this? and how to fix it?
It seems to happen only in development server and not in production. Production gives a 404 Not Found error, which is fine.
I am using SDK 1.6.4
web.xml:
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<servlet>
<servlet-name>RegisterPage</servlet-name>
<jsp-file>/register.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>RegisterPage</servlet-name>
<url-pattern>/signup</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
==========
so...
index.jsp -> renders page
index.jsp/ -> returns source code
register.jsp/ -> returns source code
register.jsp -> renders jsp
signup/ -> renders register.jsp
signup -> renders register.jsp
so it seems like it's the urls with *.jsp/ that have the issue
You should move all the *.jsp files into the /WEB-INF directory, and update your web.xml.
This way the *.jsp files will not be accessible directly, and the source code will be hidden.
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<servlet>
<servlet-name>RegisterPage</servlet-name>
<jsp-file>/WEB-INF/register.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>RegisterPage</servlet-name>
<url-pattern>/signup</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>IndexPage</servlet-name>
<jsp-file>/WEB-INF/index.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>IndexPage</servlet-name>
<url-pattern>/index</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/index</welcome-file>
</welcome-file-list>
I have the some problem when i have used "redirect" and apache tomcat 7, because the redirect is not supported in new version of apache. For solve your problem search news in changelog of your version of apache (if you use it) for the tag you used in your page, or publish code of your page to be able to suggest other solutions. May be that you're using deprecated tags. Also, keep in check the file localhost[DATE].log for more details

Categories