Results 1 to 4 of 4

Thread: org.apache.jasper.JasperException: Unable to compile class for JSP

  1. #1

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Resolved org.apache.jasper.JasperException: Unable to compile class for JSP

    I've been trying to run this jsp page i have which uses a bean. Everytime i run the jsp page a get an error "unable to compile class" Is there anyway i can fix this? Thanks

  2. #2

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: org.apache.jasper.JasperException: Unable to compile class for JSP

    I found this. http://www.coreservlets.com/Apache-Tomcat-Tutorial/ and followed number 3. I took the classes out of the development directory C:\Jakarta\jakarta-tomcat-5.0.28\webapps\ora\WEB-INF\classes and put them in C:\JavaBeans, set the class path in the autpexec.bat file to @SET CLASSPATH=C:\JavaBeans and added the package directory to the top of my bean. ie package JavaBeans; and i still have the same problem I am using the following tag in the jsp page. <jsp:useBean id = "testbean" class = "TestBean"/>

  3. #3

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Resolved Re: org.apache.jasper.JasperException: Unable to compile class for JSP

    I just created this directory structure classes\com\MyCompany\Beans, dumped my beans in there and added package com.MyCompany.Beans; to the top of them. Seems to work. Why i can't get them to run just in the classes directory i havent a clue.

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: org.apache.jasper.JasperException: Unable to compile class for JSP

    Because of the way Java looks for classes.
    (Side note: naming convention says that package names are always all lowercase.)

    If you have a class called com.cornedbee.beans.CacaoBean, Java will look for the file CacaoBean.class, running a little loop like this:
    Code:
    $file = null;
    for each path in $used_class_path do
      if exists $path/com/cornedbee/beans/CacaoBean.class then
        $file = $path/com/cornedbee/beans/CacaoBean.class
      fi
    done
    if $file == null then throw ClassDefNotFoundError
    In addition to this, web containers don't seem to like beans without a package name. No idea why.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width