• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The value for the useBean class attribute is invalid

 
Jessid Leon Velez Gutierrez
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64724
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jessid Leon Velez Gutierrez
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64724
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64724
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64724
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1692
10
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic