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

Discussion in 'Java' started by preethamkumarrai@gmail.com, Jan 29, 2006.

  1. Guest

    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
    , Jan 29, 2006
    #1
    1. Advertising

  2. Venky Guest

    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..
    Venky, Jan 29, 2006
    #2
    1. Advertising

  3. ozgwei Guest

    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.
    ozgwei, Jan 29, 2006
    #3
  4. Roedy Green Guest

    On 29 Jan 2006 02:36:57 -0800, 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.
    Roedy Green, Jan 29, 2006
    #4
  5. Roedy Green Guest

    On Sun, 29 Jan 2006 15:32:44 +0000, Thomas Hawtin
    <> 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.
    Roedy Green, Jan 29, 2006
    #5
  6. 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/
    Thomas Hawtin, Jan 29, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. titi
    Replies:
    20
    Views:
    889
    Claudio Puviani
    Feb 13, 2004
  2. emy86evil
    Replies:
    1
    Views:
    466
    emy86evil
    Nov 21, 2006
  3. Witless

    A problem to solve..need help

    Witless, Jul 10, 2004, in forum: C Programming
    Replies:
    5
    Views:
    292
    RoSsIaCrIiLoIA
    Jul 11, 2004
  4. Nac Temha
    Replies:
    7
    Views:
    60
    Asaf Las
    Jan 17, 2014
  5. Tim Chase
    Replies:
    0
    Views:
    64
    Tim Chase
    Jan 16, 2014
Loading...

Share This Page