1 Reply Latest reply on Jan 4, 2012 8:14 PM by Daniel Rowe

    s:convertentity throwing null pointer exception

    bhanu prakash yadav Newbie
      hi all ,

               iam using selectonemenu in my form .


                                                                                      <h:selectOneMenu id="roomtypeID" label="Room Type" value="#{paymentDetailsAction.paymentdetails.roomconfig}" style="width: 150px;">                                      
                                                                                              <s:selectItems  value="#{paymentDetailsAction.getResRoomList()}"     var="roomtype" label="#{roomtype.appRoomNameGiven}" noSelectionLabel="Please select"/>
                                                                                              <s:convertEntity />
                                                                                      </h:selectOneMenu>                                       
                                                                     



      but iam getting null pointer when i use <s:convertentity>


      Error Rendering View[/guestreservation/paymentdetails/paymentdetails.xhtml]
      java.lang.NullPointerException
              at org.jboss.seam.persistence.HibernatePersistenceProvider.getSession(HibernatePersistenceProvider.java:355)
              at org.jboss.seam.persistence.HibernatePersistenceProvider.getId(HibernatePersistenceProvider.java:163)
              at org.jboss.seam.framework.EntityIdentifier.<init>(EntityIdentifier.java:13)
              at org.jboss.seam.ui.JpaEntityLoader.createIdentifier(JpaEntityLoader.java:29)
              at org.jboss.seam.ui.AbstractEntityLoader.put(AbstractEntityLoader.java:46)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
              at java.lang.reflect.Method.invoke(Unknown Source)
              at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
              at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
              at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:95)
              at org.jboss.seam.util.Work.workInTransaction(Work.java:47)
              at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:89)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
              at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
             


      thanks in advance
        • 1. Re: s:convertentity throwing null pointer exception
          Daniel Rowe Newbie
          |I'm not sure if this is your issue, but make sure the objects in your list (the class that gets returned in getResRoomList()) implements the equals and hashcode methods:


          `   @Override
             public boolean equals(Object obj) {
                if (obj == null)
                   return false;
                else if (!(obj instanceof RoomType))
                   return false;
                else
                   return ((RoomType)obj).getId().equals(this.getId());
             }

             @Override
             public int hashCode() {
                return super.hashCode();
             }