help me to solve this problem,binding a String object to a string

P

preethamkumarrai

Hi All,
I am pretty new to weblogic8.1.I am Getting a error if i try to
concatenate a object to the string in out.println

statement.
For your kind reference progam and error pattern is enclosed.


public class Test extends HttpServlet
{
PrintWriter out;

public void doGet(HttpServletRequest req,HttpServletResponse res)
throws ServletException,IOException
{
out=res.getWriter();
String aaa="Google";
out.println("Hai"+aaa);
} }


ERROR IS:

Error 500--Internal Server Error
java.lang.NoClassDefFoundError: java/lang/StringBuilder
at Test.doGet(Test.java:15)
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:971)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
at

weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6350)
at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635)
at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)

-------------------------------------------------------------------------------------------------------------------------

--

If i use the statement like;
out.println("Hai");
out.println(aaa); ...It works fine

Plz, help me out there.Thanks All.

Prith
 
V

Venky

One reason could be is that the servlet class is compiled using java1.5
compiler and when its running in java 1.4x jvm.. Because in java 1.4x
the string concatenation is done using StringBuffer and in Java 1.5,
its done using StringBuilder class and this class is not available in
java 1.4x..

Before deploying the jar file in weblogic, compile your classes with
java 1.4x compiler or use java 1.5 with weblogic..
 
O

ozgwei

StringBuilder is a new class introduced in Java 5.

I suspect that you use a Java 5 compiler when compiling this Test class
but run it on a JVM of Java 1.4 or lower.

I don't think that WebLogic 8.1 is running Java 5.

Please check.
 
R

Roedy Green

-target 1.4 -source 1.4 -bootclasspath /usr/java/j2re1.4.2/lib/rt.jar

the catch is, Javac will happily let you use StringBuilder in -target
1.4 code. It does not know that it is a new class. That why you need
the -bootclasspath to restrict it to old classes.
 
T

Thomas Hawtin

Venky said:
One reason could be is that the servlet class is compiled using java1.5
compiler and when its running in java 1.4x jvm.. Because in java 1.4x
the string concatenation is done using StringBuffer and in Java 1.5,
its done using StringBuilder class and this class is not available in
java 1.4x..

Sun's 1.5 compiler only uses StringBuilder for target of 1.5. So either
the code is being compiled with some buggy compiler or the JRE (possibly
BEA JRockit) is broken in accepting class files with higher version
numbers than it is capable of running. Perhaps more likely, some
ham-fisted intermediate program is rewriting the class file incorrectly.
Before deploying the jar file in weblogic, compile your classes with
java 1.4x compiler or use java 1.5 with weblogic..

Or use

-target 1.4 -source 1.4 -bootclasspath /usr/java/j2re1.4.2/lib/rt.jar

Normally I'd suggest using the latest javac and options similar to
those. However, for the 1.4 to 1.5 jump the compiler was destabilised
considerably.

Tom Hawtin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top