[jboss-user] [Beginners Corner] - Could not instantiate Seam component

jhimmel do-not-reply at jboss.com
Mon May 21 11:49:05 EDT 2007


I wanted to practice creating a Seam web application that uses a stateful session bean (using the EJB 3.0 standard).  So I created a simple application with 2 pages, a session bean, and its local interface.  The idea was for the user to type in his name and click on the submit button.  The application is supposed to go to the second page and display the name that was typed in.  The goal here is to maintain field state across web pages.

However, when I ran the application, I received the following error: "Could not instantiate Seam component".  I noticed that in the stack trace, there was a point where it said "stateful not bound".    What am I missing?  

Here is the code for the first xhtml page:


  | <?xml version="1.0" encoding="ISO-8859-1" ?>
  | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  | <ui:composition xmlns="http://www.w3.org/1999/xhtml"
  | 	xmlns:s="http://jboss.com/products/seam/taglib"
  | 	xmlns:ui="http://java.sun.com/jsf/facelets"
  | 	xmlns:f="http://java.sun.com/jsf/core"
  | 	xmlns:h="http://java.sun.com/jsf/html" template="layout/template.xhtml">
  | 	<ui:define name="body">
  | 		<h:form>
  | 			Enter Your Name: <h:inputText id="YourNameInputText"
  | 				value="#{personName.name}" />
  | 			<h:commandButton id="CommandBtnSubmit" type="submit"
  | 				value="Submit Your Name" action="#{personName.sayHello}" />
  | 		</h:form>
  | 	</ui:define>
  | </ui:composition>
  | 

Here is the code for the second xhtml page:

  | <?xml version="1.0" encoding="ISO-8859-1" ?>
  | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  | <ui:composition xmlns="http://www.w3.org/1999/xhtml"
  | 	xmlns:s="http://jboss.com/products/seam/taglib"
  | 	xmlns:ui="http://java.sun.com/jsf/facelets"
  | 	xmlns:f="http://java.sun.com/jsf/core"
  | 	xmlns:h="http://java.sun.com/jsf/html" template="layout/template.xhtml">
  | 	<ui:define name="body">
  | 		<h:form>
  | 			Welcome <h:outputText value="#{personName.name}" id="testStateful2OutputText"/>
  | 		</h:form>
  | 	</ui:define>
  | </ui:composition>
  | 
  | 

Here is the local interface:

  | package com.pmacui;
  | 
  | import javax.ejb.*;
  | import java.util.*;
  | 
  | @Local
  | public interface IYourNameLocal
  | {
  | 	public String sayHello ();
  | 	public void destroy ();
  | }
  | 
  | 

Here is the session bean:

  | package com.pmacui;
  | 
  | import javax.ejb.*;
  | import org.jboss.seam.annotations.*;
  | import org.jboss.seam.ejb.*;
  | 
  | import static org.jboss.seam.ScopeType.SESSION;
  | 
  | @Stateful
  | @Name("personName")
  | @Scope (SESSION)
  | public class YourNameAction implements IYourNameLocal
  | {
  | 	@In @Out                                                               
  | 	private String name;
  | 	
  | 	public String GetName() { return this.name; }
  | 	public void SetName(String name) { this.name = name; }
  | 	
  | 	public String sayHello ()
  | 	{
  | 		return "/testStateful2.xhtml";
  | 	} 
  | 	                                                               
  | 	@Remove @Destroy
  | 	public void destroy ()
  | 	{	}
  | }  // end of class YourNameAction
  | 
  | 

Here is the part of the stack trace that displayed on the error page:


org.jboss.seam.InstantiationException: Could not instantiate Seam component: personName
	at org.jboss.seam.Component.newInstance(Component.java:1740)
	at org.jboss.seam.Component.getInstance(Component.java:1643)
	at org.jboss.seam.Component.getInstance(Component.java:1610)
	at org.jboss.seam.jsf.SeamVariableResolver.resolveVariable(SeamVariableResolver.java:53)
	at org.apache.myfaces.config.LastVariableResolverInChain.resolveVariable(LastVariableResolverInChain.java:42)
	at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:134)
	at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:65)
	at com.sun.el.parser.AstValue.getValue(AstValue.java:106)
	at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
	at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
	at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:56)
	at javax.faces.component.UIOutput.getValue(UIOutput.java:77)
	at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getStringValue(RendererUtils.java:217)
	at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.renderInput(HtmlTextRendererBase.java:135)
	at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:53)
	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:536)
	at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:242)
	at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
	at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
	at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:554)
	at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
	at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
	at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
	at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
	at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
	at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
	at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
	at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
	at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
	at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
	at java.lang.Thread.run(Thread.java:595)
Caused by: javax.naming.NameNotFoundException: stateful not bound
	at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
	at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
	at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
	at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
	at javax.naming.InitialContext.lookup(InitialContext.java:351)
	at org.jboss.seam.Component.instantiateSessionBean(Component.java:1107)
	at org.jboss.seam.Component.instantiate(Component.java:1093)
	at org.jboss.seam.Component.newInstance(Component.java:1736)
	... 51 more



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4047293#4047293

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4047293



More information about the jboss-user mailing list