Tomcat and JSP: Unable to compile class, cannot resolve to a type

Discussion in 'Java' started by tfrawley@gci.net, Oct 29, 2008.

  1. Guest

    I have installed Tomcat 6.0.18 and JDK 6u10.

    The tomcat server works fine except when I attempt to use a class
    file.

    The physical path to the test site is: C:\Tomcat6\webapps\test

    I placed a file named "index.jsp" in the above site with the following
    contents:

    <%@ page language="java"%>

    <%
    test.Hello h = new Hello();
    h.run();
    %>


    I used javac to compile the following class (javac -d Hello.java):

    package test;
    public class Hello{
    public void run(){
    System.out.println("Hello World");
    }}


    and placed the class file in: C:\Tomcat6\webapps\test\WEB-INF\classes

    When I open the site I get:

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

    An error occurred at line: 4 in the jsp file: /index.jsp
    test.Hello cannot be resolved to a type
    1: <%@ page language="java"%>
    2:
    3: <%
    4: test.Hello h = new Hello();
    5: h.run();
    6: %>
    7:


    An error occurred at line: 4 in the jsp file: /index.jsp
    Hello cannot be resolved to a type
    1: <%@ page language="java"%>
    2:
    3: <%
    4: test.Hello h = new Hello();
    5: h.run();
    6: %>
    7:


    This seems so simple but it refuses to work. What am I doing wrong!?!?
     
    , Oct 29, 2008
    #1
    1. Advertising

  2. Arne Vajhøj Guest

    Re: Tomcat and JSP: Unable to compile class, cannot resolve to atype

    wrote:
    > I have installed Tomcat 6.0.18 and JDK 6u10.
    >
    > The tomcat server works fine except when I attempt to use a class
    > file.
    >
    > The physical path to the test site is: C:\Tomcat6\webapps\test
    >
    > I placed a file named "index.jsp" in the above site with the following
    > contents:
    >
    > <%@ page language="java"%>
    >
    > <%
    > test.Hello h = new Hello();
    > h.run();
    > %>
    >
    > I used javac to compile the following class (javac -d Hello.java):
    >
    > package test;
    > public class Hello{
    > public void run(){
    > System.out.println("Hello World");
    > }}
    >
    > and placed the class file in: C:\Tomcat6\webapps\test\WEB-INF\classes
    >
    > When I open the site I get:
    >
    > org.apache.jasper.JasperException: Unable to compile class for JSP:
    >
    > An error occurred at line: 4 in the jsp file: /index.jsp
    > test.Hello cannot be resolved to a type
    > 1: <%@ page language="java"%>
    > 2:
    > 3: <%
    > 4: test.Hello h = new Hello();
    > 5: h.run();
    > 6: %>
    > 7:
    >
    >
    > An error occurred at line: 4 in the jsp file: /index.jsp
    > Hello cannot be resolved to a type
    > 1: <%@ page language="java"%>
    > 2:
    > 3: <%
    > 4: test.Hello h = new Hello();
    > 5: h.run();
    > 6: %>
    > 7:
    >
    > This seems so simple but it refuses to work. What am I doing wrong!?!?


    The second error is because you need:

    test.Hello h = new test.Hello();

    The first error is because the class file should be in:
    C:\Tomcat6\webapps\test\WEB-INF\classes\test

    Fix both and you should run.

    Arne
     
    Arne Vajhøj, Oct 29, 2008
    #2
    1. Advertising

  3. Guest

    Arne,

    That did it!

    Thank you Thank you Thank you!

    We are up and running!
     
    , Oct 30, 2008
    #3
    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. @lex-kid
    Replies:
    2
    Views:
    2,397
    @lex-kid
    Jul 7, 2003
  2. sufia
    Replies:
    1
    Views:
    3,046
    @lex-kid
    Jul 6, 2003
  3. Tim Meals
    Replies:
    0
    Views:
    4,865
    Tim Meals
    Sep 5, 2003
  4. Replies:
    1
    Views:
    10,193
  5. Vincent Ly
    Replies:
    14
    Views:
    14,734
    Arne Vajhøj
    Dec 3, 2009
Loading...

Share This Page