facebook

Java Bean – can’t resolve symbol

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #200173 Reply

    stardev
    Member

    Hi,

    I have a simple Java Bean called from my JSP using “<jsp:includebean…”.

    When I run the application in debug mode (deployed to Tomcat 5) I get the following error:

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

    An error occurred at line: 30 in the jsp file: /MyJsp.jsp

    Generated servlet error:
    [javac] Compiling 1 source file

    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\HelloWorld\org\apache\jsp\MyJsp_jsp.java:69: cannot resolve symbol
    symbol : class User
    location: class org.apache.jsp.MyJsp_jsp
    User myUserBean = null;
    ^

    FYI, the User.class file has been deployed to the Tomcat webapps\WEB-INF\classes folder.

    Any ideas why this isn’t working? Do I need to add the WEB-INF\classes folder to the classpath?

    Regards

    D.

    #200179

    Scott Anderson
    Participant

    D,

    Is the User class in the default package or is there a proper export for it? Did the JSP pass compilation validation within the enviornment? You can ensure that this is on by checking the setting on the JSP editor preference page.

    –Scott
    MyEclipse Support

    #200183

    stardev
    Member

    Hi,

    The JSP is valid, so no worries there. Whether it’s correct or not is a different matter… 😀

    The class was in the default package. Consequently the JSP just referenced “User”, e.g.:

    <jsp:useBean id=”myUserBean” scope=”request” class=”User”/>

    <%
    out.println(“User is ” + myUserBean.getName());
    %>

    I don’t understand the bit about exporting? What is that?

    BTW, I have now moved my bean to a defined package (com.djwheatley) and added a “<%@ page import=”com.djwheatley.User” %> to my JSP. I then changed my “usebean” tag to specifically reference the package:

    <jsp:useBean id=”myUserBean” scope=”request” class=”com.djwheatley.User”/>

    Now everything works fine!

    I’m still confused though. Why should I need to put the bean in a defined package?

    Thanks for your help.

    D.

    #200194

    support-michael
    Keymaster

    I believe a error resulting from a reference to Java class located in the default package is a bug. I’m submitting this for further research.

    Michael
    MyEclipse Support

    #200195

    support-michael
    Keymaster

    I was just running test on our next release and it supports Java classes located in the default package without error. Maybe I’ll look a little closer. Please note that there this a bug in the handling of jsp:setProperty and jsp:getProperty that has been addressed and will be available shortly.

    Michael
    MyEclipse Support

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Java Bean – can’t resolve symbol

You must be logged in to post in the forum log in