DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23336>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23336

Error including Hibernate libraries on JSP page

           Summary: Error including Hibernate libraries on JSP page
           Product: Tomcat 4
           Version: 4.1.18
          Platform: PC
               URL: http://tonib.homeip.net:8080/jgroups/index-error.jsp
        OS/Version: Linux
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Servlet & JSP API
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


I use Linux Mandrake 9.2, with Sun JDK 1.4.1.

Hibernate is a open source persistence layer (http://hibernate.bluemars.net/),
and I want to use it on my webapp.
Then, I have the following line to import the Hibernate libraries at my JSP page :
<%@ page import = "net.sf.hibernate.* " %>

Also, I have the following line, to load a bean of my application :

<jsp:useBean id="userSession" scope="session" class="jgroups.UserSession" />

But, there is the following problem. When Tomcat compiles the JSP, give me the
following message :

Generated servlet error:
    [javac] Compiling 1 source file

/usr/local/lib/jakarta-tomcat-4.1.18-LE-jdk14/work/Standalone/localhost/jgroups/menu_jsp.java:60:
reference to InstantiationException is ambiguous, both class
net.sf.hibernate.InstantiationException in net.sf.hibernate and class
java.lang.InstantiationException in java.lang match
            throw new InstantiationException(exc.getMessage());

I see the .java generated for the JSP page, and contains the following code :

jgroups.UserSession userSession = null;
      synchronized (session) {
        userSession = (jgroups.UserSession)
pageContext.getAttribute("userSession", PageContext.SESSION_SCOPE);
        if (userSession == null){
          try {
            userSession = (jgroups.UserSession)
java.beans.Beans.instantiate(this.getClass().getClassLoader(),
"jgroups.UserSession");
          } catch (ClassNotFoundException exc) {
            throw new InstantiationException(exc.getMessage());
          } catch (Exception exc) {
            throw new ServletException("Cannot create bean of class " +
"jgroups.UserSession", exc);
          }
          pageContext.setAttribute("userSession", userSession,
PageContext.SESSION_SCOPE);
        }
      }

The problem is that there is a InstantiationException into the Hibernate package
and into the Java standard library, and the compiler dont know what must to use.

The solution is change the generated code "new
InstantiationException(exc.getMessage());" to "new
java.lang.InstantiationException(exc.getMessage());".

I think all the JSP generated code must be fully package qualified to avoid
these kind of problems.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to