tags:

views:

86

answers:

1
org.apache.jasper.JasperException: /index.jsp(1,1) The value for the useBean class attribute com.b5 is invalid.
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
    org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1272)
    org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1178)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
    org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
    org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
    org.apache.jasper.compiler.Node$Root.accept(Node.java:495)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
    org.apache.jasper.compiler.Generator.generate(Generator.java:3426)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:216)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:332)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

Can anyone explain the cause and solution of this problem?

A: 
The value for the useBean class attribute com.b5 is invalid.

So you have a

<jsp:useBean id="b5" class="com.b5" />

This exception is typical when the following happening "behind the scenes" fails:

com.b5 b5 = new com.b5();

Apart from the requirement that it should be placed inside a package (which you thus correctly did), the bean should also have an (implicit) public no-arg constructor. I.e.

package com;

public class b5 {
    public b5() {
        // Default constructor.
    }
}

Normally this constructor is already present, but this will be hidden whenever you add another constructors which takes another arguments. You'll then need to add it yourself explicitly.

Another possible cause is that the bean class cannot be found in the runtime classpath. If this is your own bean, then ensure that its class file is located in /WEB-INF/classes/com/b5.class. Also ensure that the full qualified name com.b5 is literally correct, it's case sensitive.

You should look a bit further in the stacktrace for the exact cause of the problem. Head to the root cause or caused by parts at the bottom of the trace.


That said (and unrelated to the actual problem), the classname b5 is a pretty poor choice. It should be a sensible name starting with uppercase, e.g. User, Product, Order, etc.

BalusC