Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Error 500: Failed to load target servlet

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am trying to deploy Servlet in Websphere Application Server V4.0 AES.I created MyServlet.ear using AAT.Created Servlet web component.I have added only one servlet.Context root is /webapp/MyServlet.In Servlet mapping URL Pattern is /MyServlet.I installed the Application.When I try to view MyServlet using http://localhost:9080/webapp/MyServlet/MyServlet I am getting following error. Error 500: Failed to load target servlet [MyServlet] In the log file it is saying Failed to load servlet�java.lang.NoClassDefFoundError: MyServlet (wrong name: webapp/MyServlet)Can anybody please help in solving this? Your help is greatly appreciated.
 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Copy the file MyServlet.class into "WebSphere/AppServer/MyServlet.ear/MyServlet.war/WEB-INF/classes folder. And try again
It should work.
Regards,
Bhiku.
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry, but I can't recommend you follow Bhiku's idea -- it doesn't solve the real problem, which is that your EAR (and WAR) are somehow misconstructed. Make sure you did the following:
(1) That you really included the .class file inside the WAR file (it's easy to forget that step -- often you select the file and forget to hit "add" in the add new file dialog)
(2) That the fully-qualified class name in the web.xml file matches the fully-qualified class name of your servlet.
Kyle
 
sharada narayan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have added MyServlet.claass while creating WAR file.My class file was in c:\data\classes.I chose this as root directory when I created WAR file.I can see this in AAT when I go to webmodules>MyServlet>class>Files>class Files.
Name: MyServlet.class
path:WEB-INF/classes.
MyServlet.class is in wbsphere\Appserver\installedapps\MyServlet.ear\MyServlet.war\WEB-INF\classes\MyServlet.class.
web.xml is
<?xml version="1.0" encoding="UTF-8"?>
< !DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">;
<web-app id="WebApp_ID">
<display-name>MyServlet</display-name>
<servlet id="Servlet_1">
<servlet-name>MyServlet</servlet-name>
<display-name>MyServlet</display-name>
<servlet-class>MyServlet</servlet-class>
</servlet>
<servlet-mapping id="ServletMapping_1">
<servlet-name>MyServlet</servlet-name>
<url-pattern>/MyServlet</url-pattern>
</servlet-mapping>
</web-app>
I am new to websphere.What else I need to add?
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is going to sound odd, but we've seen strange problems when you place classes in the default package -- the classloaders don't seem to like them very much. Please try putting your servlet in a package, then updating the web.xml and the class location with the new information.
Kyle
 
sharada narayan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I could able to deploy the servlet.I created MyServlet.java under webapp package.Updated web.xml.Thank you both for spending your time on this.
Sharada Narayan
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic