JSP silently fails to compile

Discussion in 'Java' started by Ronald Fischer, Oct 13, 2003.

  1. I've got a JSP which does not compile from within tomcat. I don't get any
    error message; there is a java file, but simply no class file.

    I suspect some kind of internal compiler error. I narrowed the problem down
    to the following observation:

    The working JSP (which compiles and works fine) differs from the non-working
    one only in that it contains the statement

    Map parameters;

    somewhere in an inner block of a while-loop. Note that the variable is
    only declared, not used.

    Further: When I replace this statement by

    HashMap parameters;

    a class file is generated, but reveals weird behaviour.

    Finally: When I move the HashMap declaration to the outermost block,
    withouth changing anything else, a class file is generated and works
    fine.

    Did anybody already experience something similar? Is there a way to
    find out more of what is happening during compilation (kind of a
    "verbose" feature for the JSP compiler)?

    Ronald
     
    Ronald Fischer, Oct 13, 2003
    #1
    1. Advertising

  2. Ronald Fischer

    Chris Smith Guest

    Ronald Fischer wrote:
    > I've got a JSP which does not compile from within tomcat. I don't get any
    > error message; there is a java file, but simply no class file.


    Have you tried compiling the file by hand with javac? What happens?

    --
    www.designacourse.com
    The Easiest Way to Train Anyone... Anywhere.

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
     
    Chris Smith, Oct 13, 2003
    #2
    1. Advertising

  3. Ronald Fischer

    Sudsy Guest

    Ronald Fischer wrote:
    > I've got a JSP which does not compile from within tomcat. I don't get any
    > error message; there is a java file, but simply no class file.
    >
    > I suspect some kind of internal compiler error. I narrowed the problem down
    > to the following observation:
    >
    > The working JSP (which compiles and works fine) differs from the non-working
    > one only in that it contains the statement
    >
    > Map parameters;


    Map is an interface, not a class.

    >
    > somewhere in an inner block of a while-loop. Note that the variable is
    > only declared, not used.
    >
    > Further: When I replace this statement by
    >
    > HashMap parameters;
    >
    > a class file is generated, but reveals weird behaviour.


    Like what?

    >
    > Finally: When I move the HashMap declaration to the outermost block,
    > withouth changing anything else, a class file is generated and works
    > fine.


    Which points to the logic in your code, right?

    >
    > Did anybody already experience something similar? Is there a way to
    > find out more of what is happening during compilation (kind of a
    > "verbose" feature for the JSP compiler)?


    I see lots of useful information in $TOMCAT_HOME/logs/jasper*.log
    files.

    >
    > Ronald
     
    Sudsy, Oct 13, 2003
    #3
  4. Sudsy <> wrote in message news:<>...
    > Ronald Fischer wrote:
    > > Map parameters;

    >
    > Map is an interface, not a class.


    Yes, but you sure can declare a variable of an interface type. Of course
    you would later have to write something like

    parameters = new HashMap();

    > > Further: When I replace this statement by
    > >
    > > HashMap parameters;
    > >
    > > a class file is generated, but reveals weird behaviour.

    >
    > Like what?


    For example, I have in the code *many* lines below the declaration
    of 'parameters' two successive statements writing something to a file.
    If I replace 'Map' by 'HashMap', only the first of these statements
    is executed.

    >
    > >
    > > Finally: When I move the HashMap declaration to the outermost block,
    > > withouth changing anything else, a class file is generated and works
    > > fine.

    >
    > Which points to the logic in your code, right?


    No, because the variable 'parameters' is never used anywhere in this
    code. A declaration of a variable, which is not use anywhere in a block,
    should not affect the logic of the program.

    > I see lots of useful information in $TOMCAT_HOME/logs/jasper*.log
    > files.


    Nothing. The logs directory is empty. Could it be that I have to do something
    to enable logs?

    Ronald
     
    Ronald Fischer, Oct 14, 2003
    #4
  5. Ronald Fischer

    Peter Kirk Guest


    > > I see lots of useful information in $TOMCAT_HOME/logs/jasper*.log
    > > files.

    >
    > Nothing. The logs directory is empty. Could it be that I have to do

    something
    > to enable logs?


    Don't you get anything displayed on your "console window" (a stack trace or
    something)?

    Peter
     
    Peter Kirk, Oct 14, 2003
    #5
  6. Ronald Fischer

    Scott Yanoff Guest

    Ronald Fischer wrote:
    > Further: When I replace this statement by
    >
    > HashMap parameters;
    >
    > a class file is generated, but reveals weird behaviour.
    >
    > Finally: When I move the HashMap declaration to the outermost block,
    > withouth changing anything else, a class file is generated and works
    > fine.


    Just a couple of quick things to check:
    Do you have the correct import statement for HashMap?
    Is your declaration shown above within the <%! %> tags or the <% %> tags?

    Good luck,
    --
    -Scott
    | http://www.yanoff.org | AOL IM: SAY KJY
     
    Scott Yanoff, Oct 14, 2003
    #6
  7. RESOLVED - but can this be true?? (Re: JSP silently fails to compile)

    Scott Yanoff <> wrote in message news:<3f8c2650$0$40218$>...
    > Do you have the correct import statement for HashMap?


    Actually you got closest to what happened: There WAS an error with my
    import statement. Now that I corrected it, everything runs as
    expected.

    In the course of tracking the bug, I learned one thing, which really
    surprises me:
    If I happen to write a JSP page, which somehow translates to a
    syntactically
    incorrect Java class, I do NOT get any feedback of what goes wrong -
    no error
    message, not even a message saying that there is an error at all. I
    found out
    what actually happened, when I looked at the directory in which the
    compiler
    places all java and class files from the JSP, and saw that the name of
    the
    generated java file (which contains an embedded versioning number) was
    *newer*
    than the class file, and the versioning number of these two files did
    not
    match either. From this I concluded that the translation of the class
    file
    to the java file must have failed. I tried to compile the java file
    then
    manually, and here I got the error message which pointed to the
    incorrect import
    statement.

    This explained why "nothing happened" when I tried to call up my page
    - the
    corresponding class file was simply missing. Of course this did not
    explain the
    strange behaviour I encountered on one occasion, where *part* of the
    JSP was
    executed (as if only "half a class" file had been generated,
    informally speaking),
    but I did not have the nerves to investigate this further.

    As you sure have guessed from my posting, I am a novice in JSP, and to
    me,
    the really simplest thing I expect from a "programming system" is that
    I
    get an error message if I write something which is not syntactically
    correct.
    I still remember with shudder the days of early translators of the APL
    programming language, where nearly the only error message you got read
    "SYNTAX ERROR". I was not aware that it can be done worse - i.e.
    getting
    no error message at all.

    I talked with people who have a deeper understanding in JSP and
    Tomcat, but
    nobody could tell me some way, how I can be automatically informed of
    errors
    resulting from the JSP compilation process. I therefore adapt the
    following strategy: If I have the impression that some page is
    missing,
    I try to find the name of the java file (which, due to name mangling,
    involves a bit of wild guessing), and if there is no class file with
    the
    same name, I compile manually. In case someone knows a better way of
    achieving this goal, please let me know.

    Ronald
     
    Ronald Fischer, Oct 20, 2003
    #7
  8. Re: RESOLVED - but can this be true?? (Re: JSP silently fails to compile)

    This is not my experience. When a jsp page contains an error, I get
    exception (if I can remember) in the returned html page. I think I also get
    an error in the log file.

    You could delete all local cache files you browser could use in case of
    error...
    "Ronald Fischer" <> a écrit dans le message de
    news:...
    > Scott Yanoff <> wrote in message

    news:<3f8c2650$0$40218$>...
    > > Do you have the correct import statement for HashMap?

    >
    > Actually you got closest to what happened: There WAS an error with my
    > import statement. Now that I corrected it, everything runs as
    > expected.
    >
    > In the course of tracking the bug, I learned one thing, which really
    > surprises me:
    > If I happen to write a JSP page, which somehow translates to a
    > syntactically
    > incorrect Java class, I do NOT get any feedback of what goes wrong -
    > no error
    > message, not even a message saying that there is an error at all. I
    > found out
     
    Xavier Tarrago, Oct 20, 2003
    #8
  9. Re: RESOLVED - but can this be true?? (Re: JSP silently fails to compile)

    "Xavier Tarrago" <> wrote in message news:<bn04r6$ekn$>...
    > This is not my experience. When a jsp page contains an error, I get
    > exception (if I can remember) in the returned html page.


    Only if it is a run-time error.

    If it is a compile-time error, there is nothing which can executed.

    Just try it out...

    Ronald
     
    Ronald Fischer, Oct 21, 2003
    #9
  10. Re: RESOLVED - but can this be true?? (Re: JSP silently fails tocompile)

    Ronald Fischer wrote:

    > "Xavier Tarrago" <> wrote in message news:<bn04r6$ekn$>...
    >
    >>This is not my experience. When a jsp page contains an error, I get
    >>exception (if I can remember) in the returned html page.

    >
    >
    > Only if it is a run-time error.
    >
    > If it is a compile-time error, there is nothing which can executed.


    No, I normally get exceptions reported by the JSP engine if compilation
    fails. Is it possible that you have configured an error page for your
    webapp that hangs? Or made some other configuration choice in your
    server or webapp that might explain the failure to deliver an error
    message to the client?


    John Bollinger
     
    John C. Bollinger, Oct 21, 2003
    #10
    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. lovecreatesbeauty
    Replies:
    2
    Views:
    426
    codigo
    Apr 25, 2005
  2. Nagaraj
    Replies:
    1
    Views:
    917
    Lionel B
    Mar 1, 2007
  3. Ben Phillips

    SwingWorker.execute() silently fails?

    Ben Phillips, Oct 8, 2008, in forum: Java
    Replies:
    3
    Views:
    627
    Ben Phillips
    Oct 9, 2008
  4. Leslie Viljoen

    SQL Server DBI insert silently fails

    Leslie Viljoen, Jul 28, 2006, in forum: Ruby
    Replies:
    2
    Views:
    234
    Leslie Viljoen
    Jul 28, 2006
  5. Jon Hendry
    Replies:
    5
    Views:
    254
    Jon Hendry
    Mar 7, 2007
Loading...

Share This Page