• Post Reply Bookmark Topic Watch Topic
  • New Topic

useBean

 
Sree kanth
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While executing my jsp page which uses a Javabean, it throws an error as follows
* I am using j2ee1.4


* There is no problem while deploying. The class file is automatically getting added into web-inf/classes. But it is true that the beanclass file is not present in the automatically generated jsp classfile

The error is a s follows
------------------------
HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

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

Generated servlet error:
[javac] E:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-apps\MyJspear\war-ic_war\org\apache\jsp\Register_jsp.java:43: cannot resolve symbol
[javac] symbol : class MyClass
[javac] location: class org.apache.jsp.Register_jsp
[javac] MyClass objusr = null;
[javac] ^


Generated servlet error:
[javac] E:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-apps\MyJspear\war-ic_war\org\apache\jsp\Register_jsp.java:45: cannot resolve symbol
[javac] symbol : class MyClass
[javac] location: class org.apache.jsp.Register_jsp
[javac] objusr = (MyClass) _jspx_page_context.getAttribute("objusr", PageContext.SESSION_SCOPE);
[javac] ^


Generated servlet error:
[javac] E:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-apps\MyJspear\war-ic_war\org\apache\jsp\Register_jsp.java:48: cannot resolve symbol
[javac] symbol : class MyClass
[javac] location: class org.apache.jsp.Register_jsp
[javac] objusr = (MyClass) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "MyClass");
[javac] ^


Generated servlet error:
[javac] E:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-apps\MyJspear\war-ic_war\org\apache\jsp\Register_jsp.java:85: cannot resolve symbol
[javac] symbol : variable objuser
[javac] location: class org.apache.jsp.Register_jsp
[javac] boolean reg=objuser.insertUserDetails();
[javac] ^
[javac] 4 errors




org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:88)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:337)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:429)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:489)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:468)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:456)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:516)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:307)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:251)
javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:324)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)


note The full stack trace of the root cause is available in the Sun-Java-System/Application-Server logs.


--------------------------------------------------------------------------------

Sun-Java-System/Application-Server

What might be the problem?
Please help me.

Rgds
SRee
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you import MyClass?

Is MyClass in a package other than the default?

Have you read the JSP FAQ entry on this very subject?
[ December 08, 2005: Message edited by: Bear Bibeault ]
 
Sree kanth
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI

MyClass is in the default package


Rgds
Sree
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sree kanth:
HI

MyClass is in the default package


Rgds
Sree


Starting with Java 1.4.1 non packaged (default package) classes can not be imported from packaged classes.
Put your classes in packages.
 
Sree kanth
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank u so much BEN.
Now it is working.
But why such a restriction is required?


Rgds
Sree
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The restriction was always in the JRE spec but older versions of Sun's JRE let it slip through the cracks.
They tightened up the implementation in 1.4.1.

I'm not sure what the exact reason was but I think it's always been a good idea to explicitly package your classes.




[Added:]
See section 8, Bullet 2 in this page.
They don't really go into the reasoning here either.
http://java.sun.com/j2se/1.4/compatibility.html#incompatibilities1.4

I'll add this link to the JSP FAQ as well.
[ December 12, 2005: Message edited by: Ben Souther ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!