java.lang.InstantiationException("bean newTeam not found within scope")

What causes this error? I have looked in the java code generated by my jsp page and found this

com.football.Team newTeam = null;

synchronized (request) {

newTeam = (com.football.Team) _jspx_page_context.getAttribute("newTeam", PageContext.REQUEST_SCOPE);

if (newTeam == null){

throw new java.lang.InstantiationException("bean newTeam not found within scope");

The value of my bean is null,how do i solve this?

Any ideas? I am new to JSP

[486 byte] By [Styx218a] at [2007-11-27 1:40:36]
# 1

Most probably caused by your jsp:useBean tag.

I am guessing you have

<jsp:useBean id="newTeam" type="com.football.Team" scope="request"/>

Try:

<jsp:useBean id="newTeam" class="com.football.Team" scope="request"/>

There is a difference between "type" and "class"

Class will create the bean if it is not already present. Type will throw an exception.

Is the newTeam bean attribute meant to be already present?

evnafetsa at 2007-7-12 0:55:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
When i change it from type to class it throwsorg.apache.jasper.JasperException: The value for the useBean class attribute com.football.Team is invalid.I am trying to populate the bean from a form on the jsp page
Styx218a at 2007-7-12 0:55:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Ok, its a different error message at least.

Check the following on your bean com.football.Team

1 - It has a public constructor that takes no parameters

2 - The class implements java.io.Serializable

3 - The class is compiled properly, and is in the correct place (presumably the file /WEB-INF/classes/com/football/Team.class)

Try restarting your server to see if that makes a difference.

evnafetsa at 2007-7-12 0:55:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Thanks that did it
Styx218a at 2007-7-12 0:55:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...