File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes NoClassDefFoundError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

NoClassDefFoundError

smita mishra
Ranch Hand

Joined: May 18, 2006
Posts: 31
how can I fix this error?
index.html code is
<html>
<head>
<title> weblogic 7 bibleapp </title>
<meta http-equiv="Content-Type" content="text/html">
</head>
<body>
welcome to BibleAPP

<form action="http://localhost:7001/BibleApp/Hello">
<br> Name: <input type="text" name="stdname" value="pinky" >
<input type="submit" >

</form>

</body>
</html>

my servlet code is :
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class HelloServlet extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse resp) throws ServletException,IOException
{
resp.setContentType("text/html");
PrintWriter out = resp.getWriter();
String param = req.getParameter("stdname");
if(param == null )
{
out.println("<html>"+"<body>" + "no parameter"+"</body>" +"</html>");
}
else

out.println(
"<html>"+"<body>"+
"my name is"+ param +"</body>"+
"</html>"
);

}
}

my web.xml code is:

<?xml version="1.0" ?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>

<servlet>
<servlet-name> servlet12 </servlet-name>
<servlet-class> servlet1 </servlet-class>
</servlet>

<servlet-mapping>
<servlet-name> servlet12 </servlet-name>
<url-pattern> /ser </url-pattern>
</servlet-mapping>

<servlet>
<servlet-name> Servlet2 </servlet-name>
<servlet-class>HelloServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name> Servlet2 </servlet-name>
<url-pattern> /Hello </url-pattern>
</servlet-mapping>

</web-app>

I deploy this application is in weblogic 8 platform.
when I click on submit button I got an error messaage:
Error 500--Internal Server Error
java.lang.NoClassDefFoundError: java/lang/StringBuilder
at HelloServlet.doGet(HelloServlet.java:18)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1006)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6718)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3764)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2644)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)my

why do I get this error message?How can I fix it?
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Is the jdk version which the weblogic is using is below 1.5?
I guess yes as StringBuilder is from jdk1.5

While compiling the classes you have used jdk1.5 , but at runtime you are using jdk1.4.


Rahul Bhattacharjee
LinkedIn - Blog
Muthukrishnan Palanichamy
Greenhorn

Joined: Nov 24, 2006
Posts: 2
I think version 1.5xof Java is causing a naming conflict with them.
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
Please don't post the same question multiple times.

Over here I made the same suggestion that you are running into a problem with java versions since StringBuilder was added with java 5.

WebLogic 7.0 supports JDK 1.3/1.4
WebLogic 8.1 supports JDK 1.4
WebLogic 9.x supports JDK 1.5 aka 5

You can check the BEA documentation for yourself at http://edocs.bea.com
 
jQuery in Action, 2nd edition
 
subject: NoClassDefFoundError