Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > help me to solve this problem,binding a String object to a string

Reply
Thread Tools

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

 
 
preethamkumarrai@gmail.com
Guest
Posts: n/a
 
      01-29-2006

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$ServletI nvocationAction.run(ServletStubImpl.java:971)
at
weblogic.servlet.internal.ServletStubImpl.invokeSe rvlet(ServletStubImpl.java:402)
at
weblogic.servlet.internal.ServletStubImpl.invokeSe rvlet(ServletStubImpl.java:305)
at

weblogic.servlet.internal.WebAppServletContext$Ser vletInvocationAction.run(WebAppServletContext.java :6350)
at
weblogic.security.acl.internal.AuthenticatedSubjec t.doAs(AuthenticatedSubject.java:317)
at
weblogic.security.service.SecurityManager.runAs(Se curityManager.java:11
at
weblogic.servlet.internal.WebAppServletContext.inv okeServlet(WebAppServletContext.java:3635)
at
weblogic.servlet.internal.ServletRequestImpl.execu te(ServletRequestImpl.java:2585)
at weblogic.kernel.ExecuteThread.execute(ExecuteThrea d.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.ja va:170)

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

--

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

Plz, help me out there.Thanks All.

Prith

 
Reply With Quote
 
 
 
 
Venky
Guest
Posts: n/a
 
      01-29-2006
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..

 
Reply With Quote
 
 
 
 
ozgwei
Guest
Posts: n/a
 
      01-29-2006
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.

 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      01-29-2006
On 29 Jan 2006 02:36:57 -0800, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote,
quoted or indirectly quoted someone who said :

>java.lang.NoClassDefFoundError: java/lang/StringBuilder

I have cataloged 31 causes for that error message. I wish Sun would
do something to be more specific.

Happily your cause is #1 on the list.

See http://mindprod.com/jgloss/caq.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      01-29-2006
On Sun, 29 Jan 2006 15:32:44 +0000, Thomas Hawtin
<(E-Mail Removed)> wrote, quoted or indirectly quoted someone
who said :

>
> -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.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
Thomas Hawtin
Guest
Posts: n/a
 
      01-29-2006
Venky wrote:
> 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
--
Unemployed English Java programmer
http://jroller.com/page/tackline/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
java.util.Properties extending from HashMap<Object, Object> insteadof HashMap<String, String> Rakesh Java 10 04-08-2008 04:22 AM
Help to solve error while reading a file? Erland ASP .Net 1 04-13-2006 01:44 AM
Object creation - Do we really need to create a parent for a derieved object - can't the base object just point to an already created base object jon wayne C++ 9 09-22-2005 02:06 AM
Experts Can you help me solve this dynamic textbox validation prob =?Utf-8?B?S3Vt?= ASP .Net 1 06-08-2005 09:44 PM
How can I solve this Puzzle???Java String heinz Java 9 06-19-2004 08:26 PM



Advertisments