-
1. Re: where should I put javabean class?
joelvogt Nov 25, 2002 5:50 PM (in response to maofan)this is the right place to put them. How is jboss not working? How are you using them? Also make sure there are no conflicts on your classpath.
-
2. Re: where should I put javabean class?
maofan Nov 26, 2002 4:21 AM (in response to maofan)I 'm using JBoss-3.0.4_Tomcat-4.0.6
I have ever written such simple javabean to test:
UserBean.java
public class UserBean{
private String name;
private String address;
private String email;
public UserBean(){}
public String getName(){
return this.name;
}
public void setName(String name){
this.name=name;
}
public String getAddress(){
return this.address;
}
public void setAddress(String address){
this.address=address;
}
public String getEmail(){
return this.email;
}
public void setEmail(String email){
this.email=email;
}
}
I put UserBean.class into "WEB-INF/classes"
test.jsp
<jsp:useBean id="user" class="UserBean" >
<jsp:setProperty name="user" property="name" value="testName" />
<jsp:setProperty name="user" property="address" value="testAddress" />
<jsp:setProperty name="user" property="email" value="test@hotmail.com" />
<jsp:getProperty name="user" property="name" />
<jsp:getProperty name="user" property="address" />
<jsp:getProperty name="user" property="email" />
</jsp:useBean>
but when I run test.jsp
HTTP Status 500 - Internal Server Error
--------------------------------------------------------------------------------
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 0 in the jsp file: /bean.jsp
Generated servlet error:
[javac] Compiling 1 source file
E:\java\jboss\tomcat-4.1.x\work\MainEngine\localhost\test\bean_jsp.java:41: cannot resolve symbol
symbol : class UserBean
location: class org.apache.jsp.bean_jsp
UserBean user = null;
^
An error occurred at line: 0 in the jsp file: /bean.jsp
Generated servlet error:
E:\java\jboss\tomcat-4.1.x\work\MainEngine\localhost\test\bean_jsp.java:43: cannot resolve symbol
symbol : class UserBean
location: class org.apache.jsp.bean_jsp
user = (UserBean) pageContext.getAttribute("user", PageContext.PAGE_SCOPE); ^
An error occurred at line: 0 in the jsp file: /bean.jsp
Generated servlet error:
E:\java\jboss\tomcat-4.1.x\work\MainEngine\localhost\test\bean_jsp.java:46: cannot resolve symbol
symbol : class UserBean
location: class org.apache.jsp.bean_jsp
user = (UserBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "UserBean");
............................ -
3. Re: where should I put javabean class?
maofan Nov 26, 2002 4:26 AM (in response to maofan)I 'm using JBoss-3.0.4_Tomcat-4.0.6
I have ever written such simple javabean to test:
UserBean.java
public class UserBean{
private String name;
private String address;
private String email;
public UserBean(){}
public String getName(){
return this.name;
}
public void setName(String name){
this.name=name;
}
public String getAddress(){
return this.address;
}
public void setAddress(String address){
this.address=address;
}
public String getEmail(){
return this.email;
}
public void setEmail(String email){
this.email=email;
}
}
I put UserBean.class into "WEB-INF/classes"
test.jsp
<jsp:useBean id="user" class="UserBean" >
<jsp:setProperty name="user" property="name" value="testName" />
<jsp:setProperty name="user" property="address" value="testAddress" />
<jsp:setProperty name="user" property="email" value="test@hotmail.com" />
<jsp:getProperty name="user" property="name" />
<jsp:getProperty name="user" property="address" />
<jsp:getProperty name="user" property="email" />
</jsp:useBean>
but when I run test.jsp
HTTP Status 500 - Internal Server Error
--------------------------------------------------------------------------------
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 0 in the jsp file: /bean.jsp
Generated servlet error:
[javac] Compiling 1 source file
E:\java\jboss\tomcat-4.1.x\work\MainEngine\localhost\test\bean_jsp.java:41: cannot resolve symbol
symbol : class UserBean
location: class org.apache.jsp.bean_jsp
UserBean user = null;
^
An error occurred at line: 0 in the jsp file: /bean.jsp
Generated servlet error:
E:\java\jboss\tomcat-4.1.x\work\MainEngine\localhost\test\bean_jsp.java:43: cannot resolve symbol
symbol : class UserBean
location: class org.apache.jsp.bean_jsp
user = (UserBean) pageContext.getAttribute("user", PageContext.PAGE_SCOPE); ^
An error occurred at line: 0 in the jsp file: /bean.jsp
Generated servlet error:
E:\java\jboss\tomcat-4.1.x\work\MainEngine\localhost\test\bean_jsp.java:46: cannot resolve symbol
symbol : class UserBean
location: class org.apache.jsp.bean_jsp
user = (UserBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "UserBean");
............................ -
4. Re: where should I put javabean class?
maofan Nov 26, 2002 4:35 AM (in response to maofan)I 'm using JBoss-3.0.4_Tomcat-4.0.6
I have ever written such simple javabean to test:
UserBean.java
public class UserBean{
private String name;
private String address;
private String email;
public UserBean(){}
public String getName(){
return this.name;
}
public void setName(String name){
this.name=name;
}
public String getAddress(){
return this.address;
}
public void setAddress(String address){
this.address=address;
}
public String getEmail(){
return this.email;
}
public void setEmail(String email){
this.email=email;
}
}
I put UserBean.class into "WEB-INF/classes"
test.jsp
<jsp:useBean id="user" class="UserBean" >
<jsp:setProperty name="user" property="name" value="testName" />
<jsp:setProperty name="user" property="address" value="testAddress" />
<jsp:setProperty name="user" property="email" value="test@hotmail.com" />
<jsp:getProperty name="user" property="name" />
<jsp:getProperty name="user" property="address" />
<jsp:getProperty name="user" property="email" />
</jsp:useBean>
but when I run test.jsp
HTTP Status 500 - Internal Server Error
--------------------------------------------------------------------------------
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 0 in the jsp file: /bean.jsp
Generated servlet error:
[javac] Compiling 1 source file
E:\java\jboss\tomcat-4.1.x\work\MainEngine\localhost\test\bean_jsp.java:41: cannot resolve symbol
symbol : class UserBean
location: class org.apache.jsp.bean_jsp
UserBean user = null;
^
An error occurred at line: 0 in the jsp file: /bean.jsp
Generated servlet error:
E:\java\jboss\tomcat-4.1.x\work\MainEngine\localhost\test\bean_jsp.java:43: cannot resolve symbol
symbol : class UserBean
location: class org.apache.jsp.bean_jsp
user = (UserBean) pageContext.getAttribute("user", PageContext.PAGE_SCOPE); ^
An error occurred at line: 0 in the jsp file: /bean.jsp
Generated servlet error:
E:\java\jboss\tomcat-4.1.x\work\MainEngine\localhost\test\bean_jsp.java:46: cannot resolve symbol
symbol : class UserBean
location: class org.apache.jsp.bean_jsp
user = (UserBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "UserBean");
............................ -
5. Re: where should I put javabean class?
partha Dec 8, 2002 9:11 PM (in response to maofan)I am having the same problem. I get the exact same
errors as posted in this question. My classpath
seems to be correct. I don't have problems with
running ejb or servlet examples. Can someone shed
some light on this?
Thanks.
Partha -
6. Re: where should I put javabean class?
partha Dec 14, 2002 3:05 PM (in response to maofan)can someone please shed some light on this issue?
thanks.
partha -
7. Re: where should I put javabean class?
lijianghua Dec 15, 2002 5:46 AM (in response to maofan)you should put javabean classes in the WEB-INF/classes not the web-inf/classes!
for example:
I have a class in the WEB-INF/classes/test/Test.class
then in my jsp file,I can use it like this:
<jsp:useBean id="test" class="test.Test" scope="request"/>
then I think,it's ok!
just try it like this! -
8. Re: where should I put javabean class?
partha Dec 17, 2002 12:57 AM (in response to maofan)Actually, I have put the javabean class in WEB-INF/classes
directory. I still get the same error. For example,
when I use the bean in a JSP page as follows:
<jsp:useBean id="languageBean" class="LanguageBean" scope="request"/>
I get the following error:
An error occurred at line: 1 in the jsp file: /beans.jsp
Generated servlet error:
/usr/java/jboss-3.0.3_tomcat-4.0.5/catalina/work/MainEngine/localhost/jspExamples/beans$jsp.java:56: Class org.apache.jsp.LanguageBean not found.
LanguageBean languageBean = null;
Please let me know what else can go wrong.
Thanks.
Partha -
9. Re: where should I put javabean class?
cyourth Dec 30, 2002 11:29 PM (in response to maofan)1. put UserBean class file into /WEB-INF/classes directory.
2. add 'page import' directive to your JSP file to locate your class file.
3. if you still have problems, try adding the following attribute to tomcat41-service.xml:
<attribute name="Java2ClassLoadingCompliance">false</attribute>
- default is true
- this allows the class files to be loaded from WAR file first.
- Java2ClassLoadingCompliance, enables the standard Java2 parent delegation class loading
model rather than the servlet 2.3 load from war first model. This is true by default as
loading from wars that include client jars with classes used by EJBs causes class
loading conflicts. If you enable the servlet 2.3 class loading model by setting this
flag to false, you will need to organize your deployment package to avoid duplicate
classes in the deployment.
4. example JSP code:
<%@ page language="java" %>
<%@ page import="UserBean" %>
<html>
<body>
<jsp:useBean id="user" class="UserBean" >
<jsp:setProperty name="user" property="name" value="testName" />
<jsp:setProperty name="user" property="address" value="testAddress" />
<jsp:setProperty name="user" property="email" value="test@hotmail.com" />
<jsp:getProperty name="user" property="name" /><br>
<jsp:getProperty name="user" property="address" /><br>
<jsp:getProperty name="user" property="email" /><br>
</jsp:useBean>
</body>
</html>