<jsp:useBean>

Hi i'm having trouble with a usebean in a jsp file. I get the following error message: The value for the useBean class attribute com.a.b.ui.ReportBean is invalid. ReportBean.java does have a no args constructor. ReportBean is in the following directory: C:\eclipse\workspace\OPR\com\a\b\ui and report.jsp is in the following directory: C:\eclipse\workspace\OPR\web\jsp\reports.

At the top of the jsp i have the following statement: <jsp:useBean id="report" class="com.a.b.ui.ReportBean" scope="session"/>

I used to get this working before when i was on a different project and can say im pretty sure there is nothing worng with the ReportBean class but i think it could be something to do with the location of the files and that report.jsp cant find ReportBean to instantiate it. anyone any ideas on something i can try to get this working?

Cheers,

Joe.

[967 byte] By [imloaded24_7a] at [2007-11-26 14:33:04]
# 1
did you try placing it in your src directory? (the bean i mean)
madppipera at 2007-7-8 2:28:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
I have no src directory. The file path shown is the structure we use. could this be the problem.
imloaded24_7a at 2007-7-8 2:28:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

The class file for the bean should be in the web application's /WEB-INF/classes/<package name>/ directory.

If you are not sure the IDE is putting the class file in the proper location, deploy manually until you figure out how to use the IDE to do it for you.

An alternatives to the above placement:

package all the class files into a JAR and move it to the web application's /WEB-INF/lib/ directory.

stevejlukea at 2007-7-8 2:28:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

I embed my application in tomcat as suppose to embedding tomcat into my application. could this cause problems. or should i just put my jar into:

C:\eclipse\workspace\OPR\dist\windows\tomcat\webapps\ROOT\WEB-INF\lib

all my jsp class files are in:

C:\eclipse\workspace\OPR\dist\windows\tomcat\work\CSTomcat\localhost\oprmanager\WEB-INF\classes\org\apache\jsp\reports

imloaded24_7a at 2007-7-8 2:28:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Hi i tried ensuring the jar file is in the web-inf/lib directory but that didnt help. does it make a difference that i am embedding the application into tomcat?Message was edited by: imloaded24_7
imloaded24_7a at 2007-7-8 2:28:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

I don't know what you mean by "embedding the application into tomcat".

Install Tomcat into a fresh location. Create an Web App. Copy the JSPs to the proper location. Copy the JAR file to the proper location. Take eclipe out of the picture and deploy 100% manually.

Or learn how eclipse is supposed to handle these things (if you have the proper plugins) and let Eclipse deploy for you. If you choose that, then go ask at the eclipse forums for help.

stevejlukea at 2007-7-8 2:28:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7

first thing u have to do is deploy manualy if ur puting in ROOT

put ur report.jsp in to <tomcat>\webapps\ROOT\

and put ur bean class , ReportBean.class ,in

<tomcat>\webapps\ROOT\WEB-INF\classes\com\a\b\ui

and restart ur tom cat and try

http://localhost:8080/report.jsp

Sabeer_Anchemparuthya at 2007-7-8 2:28:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8

Hi Its really strange. I can import my backing bean into the jsp and it finds it fine for example:

<%@ page import="com.a.b.ui.ReportBean" %>

then

<%

ReportBean d = new ReportBean();

d.loadData();

d.getOprSessions().size();

%>

but when i do the following it doesnt work:

<jsp:useBean id="report" class="com.a.b.ui.ReportBean" scope="session"/>

Message was edited by:

imloaded24_7

imloaded24_7a at 2007-7-8 2:28:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9

Hi

It is indeed strange...

Here is a checklist...

Does ReportBean Java file has proper package declaration?

Does class file reside in proper directory hierarchy?

Does class have public , no args constructor?

Is app redeployed after modification without errors? Restart tomcat for confirmation.

There might be more items here....but I hope it should work atleast after this.

__Dev-eloper__a at 2007-7-8 2:28:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...