[jboss-user] [JBoss Seam] - null pointer exception in Seam conversation using <s:convert

billdurrell@hotmail.com do-not-reply at jboss.com
Tue Jul 24 16:05:29 EDT 2007


Hi ,  I searched the Seam forum for this problem but did not   find exactly this case . I get the following exception navigating my web app that includes a dropdown list . I can go the the page with the dropdown list and save to the database but when I go to the next page and try to return to the dropdown I get the null pointer exception (sometimes) .  Not sure how to proceed??? I really like Seam and would like to fix this problem . 


  | java.lang.NullPointerException
  | 	at com.sun.faces.renderkit.html_basic.MenuRenderer.renderOption(MenuRenderer.java:580)
  | 	at com.sun.faces.renderkit.html_basic.MenuRenderer.renderOptions(MenuRenderer.java:757)
  | 	at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:811)
  | 	at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:335)
  | 	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:833)
  | 	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:896)
  | 	at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
  | 	at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
  | 	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
  | 	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
  | 	at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:577)
  | 	at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
  | 	at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:233)
  | 	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
  | 	at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
  | 	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
  | 	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
  | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  | 	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
  | 	at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:63)
  | 	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | 	at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:87)
  | 	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | 	at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:63)
  | 	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | 	at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:46)
  | 	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | 	at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
  | 	at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
  | 	at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:40)
  | 	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  | 	at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:140)
  | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  | 	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
  | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  | 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
  | 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
  | 	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
  | 	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
  | 	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
  | 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
  | 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
  | 	at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
  | 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  | 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
  | 	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
  | 	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
  | 	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
  | 	at java.lang.Thread.run(Thread.java:595)
  | 


page :

  | 
  | <h:form id="orgProfile1">
  |  	<h1>Register Organization Profile</h1>
  | 	<hr/>
  |        <h:outputLabel for="orgType" value="#{messages.orgType}"/>
  |        <h:selectOneMenu value="#{organization.type}"  id="orgType">
  |          <s:selectItems value="#{orgTypeList}"  var="type"  label="#{type.type}" noSelectionLabel="Select your type"/>
  | 		 	<s:convertEntity/>
  |        </h:selectOneMenu>
  |     <h:commandButton type="submit" value="Save" action="#{profile.save}"/>
  |   </h:form>
  | 

  | 
  | package ca.gc.acdi_cida;
  | 
  | import  ....
  | 
  | @Stateful
  | @Name("profile")
  | public class OrganizationalProfileAction implements OrganizationalProfile {
  | 	
  | 	@In (required=false)
  | 	@Out (required=false)
  | 	private Organization organization ;
  | 	
  | 	@Out (required=false)
  | 	private List<OrganizationalType> orgTypeList;
  | 	
  |         @In(create=true)
  | 	private EntityManager entityManager;
  | 	
  | 	 
  | 	@Begin(join=true)
  | 	@SuppressWarnings("unchecked")
  | 	@Factory( "orgTypeList" )
  | 	public void findOrgTypes() {
  | 		System.out.println( " -------------------- Retrieving types..." );
  | 		orgTypeList = entityManager.createQuery("from OrganizationalType ").getResultList();
  | 		System.out.println(" ------------------ orgTypeList   size  : "+ orgTypeList.size());
  | 		
  | 	}
  | 	
  | 	@End
  | 	public String save(){
  | 		entityManager.persist(organization);
  | 		organization = new Organization();
  | 		return null;
  | 	}
  | 
  | 	 @Remove @Destroy
  | 	  public void destroy() {}
  | 
  | }
  | 

  | 
  | package ca.gc.acdi_cida;
  | 
  | import java.io.Serializable;
  | 
  | import javax.persistence.Entity;
  | import javax.persistence.GeneratedValue;
  | import javax.persistence.Id;
  | import javax.persistence.ManyToOne;
  | 
  | import org.jboss.seam.annotations.Name;
  | 
  | @Entity
  | @Name("organization")
  | 
  | public class Organization implements Serializable {
  | 
  | 	
  | 	private static final long serialVersionUID = 1L;
  | 	
  | 	
  | 	private Integer id;
  | 	private OrganizationalType type;
  | 	
  | 	public Organization(OrganizationalType type) {
  | 		this.type = type;
  | 	}
  | 	
  | 	public Organization() {}
  | 	
  | 	@Id @GeneratedValue	
  | 	public Integer getId() {return id;}
  | 	public void setId(Integer id) {this.id = id;}
  | 
  |     @ManyToOne
  | 	public OrganizationalType getType() {return type;}
  | 	public void setType(OrganizationalType type) {
  | 		System.out.println(" ------------ Type : " + type);
  | 		this.type = type;
  | 	}
  | 	
  | 	 
  | 
  | }
  | 
  | 
  | 
  | 

  | import javax.persistence.Entity;
  | import javax.persistence.GeneratedValue;
  | import javax.persistence.Id;
  | 
  | import org.jboss.seam.annotations.Name;
  | 
  | @Entity 
  | @Name("organizationalType")
  | 
  | 
  | public class OrganizationalType implements Serializable{
  | 	
  | 	/**
  | 	 * 
  | 	 */
  | 	private static final long serialVersionUID = 2490845589570967280L;
  | 	private String type ;
  | 	private Integer id;
  | 	
  |     public OrganizationalType(){}
  | 	
  | 	public OrganizationalType(String type) {
  | 		this.type = type;
  | 	}
  | 	
  | 	@Id @GeneratedValue
  | 	public Integer getId() {return id;}
  | 	public void setId(Integer id) {this.id = id;}
  | 	
  | 	public String getType() {return type;}
  | 	public void setType(String type) {this.type = type;}
  | }
  |  

components.xml

  | <persistence:managed-persistence-context name="entityManager"
  |                                      auto-create="true"
  |                       persistence-unit-jndi-name="java:/hopeEntityManagerFactory"/>
  |   
  | 
  | 
persistence.xml

  |    <?xml version="1.0" encoding="UTF-8"?>
  | <!-- Persistence deployment descriptor for dev profile -->
  | <persistence xmlns="http://java.sun.com/xml/ns/persistence" 
  |              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  |              xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" 
  |              version="1.0">
  |              
  |    <persistence-unit name="hope">
  |       <provider>org.hibernate.ejb.HibernatePersistence</provider>
  |       <jta-data-source>java:/DefaultDS</jta-data-source>
  |          <properties>
  |             <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" /> 
  |             <property name="hibernate.transaction.flush_before_completion" value="true" /> 
  |             <property name="hibernate.hbm2ddl.auto" value="create-drop" /> 
  |             <property name="hibernate.show_sql" value="true" /> 
  |             <property name="jboss.entity.manager.factory.jndi.name" value="java:/hopeEntityManagerFactory"/>
  |          </properties>
  |    </persistence-unit>
  |     
  | </persistence>
  | 

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

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



More information about the jboss-user mailing list