Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
preethamkumarrai@gmail.com - 29 Jan 2006 10:36 GMT
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
Venky - 29 Jan 2006 12:00 GMT
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..
Thomas Hawtin - 29 Jan 2006 15:16 GMT
> 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
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/

Roedy Green - 29 Jan 2006 15:31 GMT
On Sun, 29 Jan 2006 15:32:44 +0000, Thomas Hawtin
<usenet@tackline.plus.com> 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.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

ozgwei - 29 Jan 2006 12:03 GMT
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.
Roedy Green - 29 Jan 2006 12:24 GMT
>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
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.