Base is null Error.
xterm Nov 10, 2006 5:29 AMGreetings,
I'm building a simple Seam application from scratch. However i've ran into an error when trying to access a method in a session bean. Sadly i was unable to debug the error granted i'm fairly new to JBoss Seam.
The application merely retrieves data from the database and lists them using jsf DataTable.
Here's a detailed list of the data i currently have:
application.xml
<display-name>Phone Directory</display-name> <module> <web> <web-uri>phonedir.war</web-uri> <context-root>/phonedir</context-root> </web> </module> <module> <ejb>phonedir.ejb3</ejb> </module> <module> <java>jboss-seam.jar</java> </module> </application>
components.xml
<?xml version="1.0" encoding="utf-8"?>
<components>
<component name="org.jboss.seam.core.init">
<property name="jndiPattern">phonedir/#{ejbName}/local</property>
</component>
</components>
ejb-jar.xml
<ejb-jar> <assembly-descriptor> <interceptor-binding> <ejb-name>*</ejb-name> <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class> </interceptor-binding> </assembly-descriptor> </ejb-jar>
faces-config.xml
<faces-config> <lifecycle> <phase-listener>org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener</phase-listener> </lifecycle> </faces-config>
persistence.xml
<persistence> <persistence-unit name="userDatabase"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>java:/PhonedirDS</jta-data-source> <properties> <property name="hibernate.hbm2ddl.auto" value="update"/> </properties> </persistence-unit> </persistence>
web.xml
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <!-- Seam --> <listener> <listener-class>org.jboss.seam.servlet.SeamListener</listener-class> </listener> <!-- MyFaces --> <listener> <listener-class> org.apache.myfaces.webapp.StartupServletContextListener </listener-class> </listener> <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>client</param-value> </context-param> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!-- Faces Servlet Mapping --> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.seam</url-pattern> </servlet-mapping> </web-app>
Contact entity bean
@Entity
@Name("contact")
@Table(name="phonedir")
public class Contact implements Serializable {
private int id;
private String fullName;
private String telephone;
private String extension;
private String company;
private String switchBoard;
@Id @GeneratedValue
public int getId(){
return id;
}
public void setId(int id){
this.id = id;
}
public String getFullName(){
return fullName;
}
public void setFullName(String fullName){
this.fullName = fullName;
}
public String getTelephone(){
return telephone;
}
public void setTelephone(String telephone){
this.telephone = telephone;
}
public String getExtension(){
return extension;
}
public void setExtension(String extension){
this.extension = extension;
}
public String getCompany(){
return company;
}
public void setCompany(String company){
this.company = company;
}
public String getSwitchboard(){
return switchBoard;
}
public void setSwitchboard(String switchboard){
this.switchBoard = switchboard;
}
}
Local interface ContactManager
@Local
public interface ContactManager {
public String getAllContacts();
}
Stateless bean
@Stateless
@Name("contactManager")
@Interceptors(SeamInterceptor.class)
public class ContactManagerBean implements ContactManager{
@Out
private List <Contact> allContacts;
@PersistenceContext
private EntityManager em;
public String getAllContacts(){
System.out.println("Inside method");
allContacts = em.createQuery("from Contact c").getResultList();
return null;
}
}
jsf page (omitted headers)
<f:view>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
</head>
<body>
<h:form>
<h:commandButton type="submit" value="fetch" action="#{contactManager.getAllContacts}"/>
</h:form>
<f:subview id="allContacts" rendered="#{!empty(allContacts)}">
<f:verbatim>
<p>List of Contacts:</p>
</f:verbatim>
------- 1
<h:dataTable value="#{allContacts}" var="contact">
<h:column>
<h:outputText value="#{contact.fullName}"/>
</h:column>
</h:dataTable>
------- 2
</f:subview>
</body>
</f:view>
-------------
Packaging and deploying the application generates no header. Loading the initial page as well generates no errors. However upon clicking the button. The following error is generated: (Note that the debug statement does not print hence the method was not invoked to begin with.)
12:05:37,605 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
javax.faces.FacesException: Error calling action method of component with id _idJsp0:_idJsp1
at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
at javax.faces.component.UICommand.broadcast(UICommand.java:106)
at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:94)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:168)
at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:343)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
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.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.faces.el.EvaluationException: Exception while invoking expression #{contactManager.getAllContacts}
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:165)
at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:58)
at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:71)
at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:58)
at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:71)
at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
... 25 more
Caused by: javax.faces.el.PropertyNotFoundException: Base is null: contactManager
at org.apache.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(ValueBindingImpl.java:460)
at org.apache.myfaces.el.MethodBindingImpl.resolveToBaseAndProperty(MethodBindingImpl.java:180)
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:114)
... 30 more
Please advise.