aspose file tools*
The moose likes JSP and the fly likes The value for the useBean class attribute is invalid Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "The value for the useBean class attribute is invalid" Watch "The value for the useBean class attribute is invalid" New topic
Author

The value for the useBean class attribute is invalid

Jessid Leon Velez Gutierrez
Ranch Hand

Joined: Jan 19, 2011
Posts: 35
Hello. I am doing a very simple jsp using a JavaBean called Usuario which is located in package pruebas. I am trying to run this jsp and i get an error that says

org.apache.jasper.JasperException: /home.jsp(15,4) El valor el atributo de clsae useBean Usuario es inválido.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)


that means something like The value for the useBean class attribute is invalid. I dont understand why this is happening. Could someone please help me? Thanks




this is the Usuario class


Thanks a lot!!!
anirudh jagithyala
Ranch Hand

Joined: Dec 07, 2010
Posts: 41
<body>
<jsp:useBean id="usuarioEnSesion" class="Usuario" scope="session" />
<h1>Hello <jsp:getProperty name="usuarioEnSesion" property="login"/></h1>
</body>


try to replace the class attribute with the path as class="pruebas.Usuario"
Might the following code works...



Please check it out.....
Jessid Leon Velez Gutierrez
Ranch Hand

Joined: Jan 19, 2011
Posts: 35
anirudh jagithyala wrote:
<body>
<jsp:useBean id="usuarioEnSesion" class="Usuario" scope="session" />
<h1>Hello <jsp:getProperty name="usuarioEnSesion" property="login"/></h1>
</body>


try to replace the class attribute with the path as class="pruebas.Usuario"
Might the following code works...



Please check it out.....


Hello. I have just tried what you suggested, but it continues exactly the same exception message. I have even deleted the apache tomcat directory and uncompress it again, but it continues the same...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60980
    
  65

All beans (and other Java classes) need to be in a package other than the default, and need to exist in the package hierarchy under WEB-INF/classes.

Is this what you are doing? If so, give us the details. If not, then you know what to do.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jessid Leon Velez Gutierrez
Ranch Hand

Joined: Jan 19, 2011
Posts: 35
Bear Bibeault wrote:All beans (and other Java classes) need to be in a package other than the default, and need to exist in the package hierarchy under WEB-INF/classes.

Is this what you are doing? If so, give us the details. If not, then you know what to do.


Hello. First, thanks for answer.
I am using tomcat 6.0.32 under windows 64 bits. Netbeans 6.9. The javabeans i am using are in a package named pruebas, under web-inf/classes directory. I am beginning to suspect about netbeans, because it is giving me some troubles with jstl... perhaps is some configuration i havent done. Perhaps the web.xml is the one that i need to change.. I dont know. any way here is the fist part of it:



This si how i am using the tag

I have this code in the upper part of the document

Thanks again
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60980
    
  65

Jessid Leon Velez Gutierrez wrote:The javabeans i am using are in a package named pruebas, under web-inf/classes directory.

It must be WEB-INF/classes. Case counts.

None of the rest of what you have shown has much to do with this.
Jessid Leon Velez Gutierrez
Ranch Hand

Joined: Jan 19, 2011
Posts: 35
Bear Bibeault wrote:
Jessid Leon Velez Gutierrez wrote:The javabeans i am using are in a package named pruebas, under web-inf/classes directory.

It must be WEB-INF/classes. Case counts.

None of the rest of what you have shown has much to do with this.


Hello Bear. Thanks for your answer.... the problem continues... perhaps I should try with another IDE, but the truth is I dont want to add another variable to my java web learning process...

Have a nice day, and again: thanks a lot
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60980
    
  65

Here's an idea: dump the IDE until you know how to do things without the help of an IDE at all.
Jessid Leon Velez Gutierrez
Ranch Hand

Joined: Jan 19, 2011
Posts: 35
Bear Bibeault wrote:Here's an idea: dump the IDE until you know how to do things without the help of an IDE at all.


Good idea...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60980
    
  65

Indeed it is -- sometimes, IDEs do too much for us, which prevents us from learning how things really work, or they make assumptions that turn out to be wrong. Understanding how things work without an IDE helps us to know when there's really a problem with our code, and when it's just the IDE boofing up.

Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1017
There are three common causes for this error message

- Your class is not found
- Your class has a compile error
- Your class does not have a public constructor that takes no arguments.

In this case, it is the latter.
Your class must have a public constructor that doesn't take any arguments in order for it to be a valid bean.



Jessid Leon Velez Gutierrez
Ranch Hand

Joined: Jan 19, 2011
Posts: 35
Stefan Evans wrote:There are three common causes for this error message

- Your class is not found
- Your class has a compile error
- Your class does not have a public constructor that takes no arguments.

In this case, it is the latter.
Your class must have a public constructor that doesn't take any arguments in order for it to be a valid bean.





Hello Stefan Evans. You are right! I didn't even had had that in count. Now that i added the no-arg constructor, it is working as it should a week ago I will mark this post as solved. Thank you very much
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: The value for the useBean class attribute is invalid