6 Replies Latest reply on Nov 9, 2006 12:08 AM by gavin.king

    @In bijected attributes remaining null?

    gregory.pierce

      I have a Seam application in which I'm attempting bijection with @In,
      but for some reason the object that is being bijected isn't getting a
      value from the JSF layer. How does one go about debugging this? I can
      see all the tables, components, etc. get created and the JSF page is
      showing up and the call to the controller (action) is happing fine as I
      put in some System.out.printlns to confirm this, but the entity bean
      that is being created simply never gets injected and I'm stumped.

      Can anyone point me towards some things that might be culprits?

        • 1. Re: @In bijected attributes remaining null?
          gavin.king

          Show your code, please.

          • 2. Re: @In bijected attributes remaining null?
            gregory.pierce

             

            <application 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/application_1_4.xsd"
             version="1.4">
            
             <display-name>Simple example of application</display-name>
            
             <module>
             <ejb>sojournerserver-model.jar</ejb>
             </module>
            
             <module>
             <ejb>sojournerserver-ws.jar</ejb>
             </module>
            
             <module>
             <java>jboss-seam.jar</java>
             </module>
            
             <module>
             <web>
             <web-uri>sojournerserver.war</web-uri>
             <context-root>/sojourner</context-root>
             </web>
             </module>
            
            </application>
            


            <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
             version="3.0">
            
             <interceptors>
             <interceptor>
             <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
             </interceptor>
             </interceptors>
            
             <assembly-descriptor>
             <interceptor-binding>
             <ejb-name>*</ejb-name>
             <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
             </interceptor-binding>
             </assembly-descriptor>
            
            </ejb-jar>
            


            <jboss-app>
             <loader-repository>seam.jboss.org:loader=sojournerserver</loader-repository>
            </jboss-app>
            


            <?xml version="1.0" encoding="UTF-8"?>
            
            <deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
             xmlns="urn:jboss:bean-deployer">
            
            
            
             <bean name="sojournerserverDatasourceBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
             <property name="driverClass">org.hsqldb.jdbcDriver</property>
             <property name="connectionURL">jdbc:hsqldb:.</property>
             <property name="userName">sa</property>
             <property name="jndiName">java:/sojournerserverDatasource</property>
             <property name="minSize">0</property>
             <property name="maxSize">10</property>
             <property name="blockingTimeout">1000</property>
             <property name="idleTimeout">100000</property>
             <property name="transactionManager"><inject bean="TransactionManager"/></property>
             <property name="cachedConnectionManager"><inject bean="CachedConnectionManager"/></property>
             <property name="initialContextProperties"><inject bean="InitialContextProperties"/></property>
             </bean>
            
             <bean name="sojournerserverDatasource" class="java.lang.Object">
             <constructor factoryMethod="getDatasource">
             <factory bean="sojournerserverDatasourceBootstrap"/>
             </constructor>
             </bean>
            
            </deployment>
            


            <persistence>
             <persistence-unit name="sojourner">
             <provider>org.hibernate.ejb.HibernatePersistence</provider>
             <jta-data-source>java:/sojournerserverDatasource</jta-data-source>
             <properties>
             <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
            
             <property name="hibernate.show_sql" value="true"/>
            
             <!-- These are the default for JBoss EJB3, but not for HEM: -->
            
             <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
            
             <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
             </properties>
             </persistence-unit>
            </persistence>
            


            <components>
             <component name="org.jboss.seam.core.init">
             <property name="jndiPattern">sojournerserver/#{ejbName}/local</property>
             <property name="debug">true</property>
             <property name="myFacesLifecycleBug">false</property>
             </component>
            
             <component class="org.jboss.seam.core.Ejb" installed="false" />
            
            
            
            </components>
            


            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE faces-config
            PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
             "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
            <faces-config>
            
             <!-- A phase listener is needed by all Seam applications -->
             <!--
             <lifecycle>
             <phase-listener>org.jboss.seam.jsf.SeamPhaseListener</phase-listener>
             </lifecycle>
            
             <lifecycle>
             <phase-listener>org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener</phase-listener>
             </lifecycle> -->
            
            
            
             <!--
             <application>
             <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
             </application> -->
            
             <lifecycle>
             <phase-listener>org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener</phase-listener>
             </lifecycle>
            
             <application>
             <message-bundle>messages</message-bundle>
             <locale-config>
             <default-locale>en</default-locale>
             <supported-locale>en</supported-locale>
             </locale-config>
             </application>
            
             <navigation-rule>
             <navigation-case>
             <from-outcome>home</from-outcome>
             <to-view-id>index.jsp</to-view-id>
             <redirect />
             </navigation-case>
             </navigation-rule>
            
            
            
            
            </faces-config>
            


            <?xml version="1.0" encoding="UTF-8"?>
            <web-app version="2.5"
             xmlns="http://java.sun.com/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
             http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
            
            
             <display-name>Sojourner Application</display-name>
            
             <listener>
             <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
             </listener>
            
             <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>
            
             <context-param>
             <param-name>facelets.DEVELOPMENT</param-name>
             <param-value>true</param-value>
             </context-param>
            
             <context-param>
             <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
             <param-value>.jsp</param-value>
             </context-param>
            
            
             <filter>
             <filter-name>Seam Exception Filter</filter-name>
             <filter-class>org.jboss.seam.servlet.SeamExceptionFilter</filter-class>
             </filter>
            
             <filter>
             <filter-name>Seam Redirect Filter</filter-name>
             <filter-class>org.jboss.seam.servlet.SeamRedirectFilter</filter-class>
             </filter>
            
             <filter-mapping>
             <filter-name>Seam Exception Filter</filter-name>
             <url-pattern>/*</url-pattern>
             </filter-mapping>
            
             <filter-mapping>
             <filter-name>Seam Redirect Filter</filter-name>
             <url-pattern>*.seam</url-pattern>
             </filter-mapping>
            
             <servlet>
             <servlet-name>Faces Servlet</servlet-name>
             <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
             <load-on-startup>1</load-on-startup>
             </servlet>
            
             <servlet-mapping>
             <servlet-name>Faces Servlet</servlet-name>
             <url-pattern>*.seam</url-pattern>
             </servlet-mapping>
            
            </web-app>
            



            Those are the config files. If there are any files that can be removed, let me know as James and I started just added everything to try and get it to work.

            • 3. Re: @In bijected attributes remaining null?
              gregory.pierce

               

              package com.sojournermobile.service.model.user;
              
              
              import javax.persistence.*;
              import java.io.Serializable;
              import java.util.Collection;
              
              import org.jboss.seam.annotations.*;
              import static org.jboss.seam.ScopeType.SESSION;
              
              @Entity
              @Name("user")
              @Scope(SESSION)
              public class User implements Serializable
              {
               @Id
               @GeneratedValue(strategy = GenerationType.AUTO)
               private int id;
              
               @Column(unique = true)
               private String userName;
               private String password;
              
               public User()
               {
              
               }
              
               public User( String userName, String password )
               {
               this.userName = userName;
               this.password = password;
               }
              
              
               public int getId()
               {
               return id;
               }
              
               public void setId(int id)
               {
               this.id = id;
               }
              
              
               public String getUserName()
               {
               return userName;
               }
              
               public void setUserName(String userName)
               {
               this.userName = userName;
               }
              
               public String getPassword()
               {
               return password;
               }
              
               public void setPassword(String password)
               {
               this.password = password;
               }
              
              }
              
              


              package com.sojournermobile.service.webservices.user;
              
              
              import com.sojournermobile.service.model.user.Profile;
              import com.sojournermobile.service.model.user.User;
              
              import javax.ejb.Stateless;
              import javax.jws.WebMethod;
              import javax.jws.WebParam;
              import javax.jws.WebService;
              import javax.jws.soap.SOAPBinding;
              import javax.persistence.EntityManager;
              import javax.persistence.PersistenceContext;
              import java.util.Date;
              import java.util.List;
              
              import org.jboss.seam.annotations.Name;
              import org.jboss.seam.annotations.In;
              import org.jboss.seam.annotations.Out;
              
              @WebService
              @Stateless
              @Name("userController")
              @SOAPBinding(style = SOAPBinding.Style.RPC)
              public class UserController implements UserControllerIF
              {
               @PersistenceContext(unitName = "sojourner")
               EntityManager em;
              
               @In @Out
               private User user;
              
              
               public User getUser() {
               return user;
               }
              
               public void setUser(User user) {
               this.user = user;
               }
              
               @WebMethod
               public int getUserCount()
               {
               return ((Long) em.createQuery("select count(u) from User u").getSingleResult()).intValue();
               }
              
               @WebMethod
               public List getUsers()
               {
               return em.createQuery("select u from User u").getResultList();
               }
              
               public String register()
               {
               System.out.println("Registering user " + user);
               em.persist( user );
              
               return "happy";
               }
              
              
              
              }
              



              package com.sojournermobile.service.webservices.user;
              
              import javax.ejb.Local;
              import java.util.Date;
              
              @Local
              public interface UserControllerIF
              {
               public int getUserCount();
              
               public String register();
              }
              



              • 4. Re: @In bijected attributes remaining null?
                gregory.pierce

                 

                <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
                <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
                <%@ taglib uri="http://jboss.com/products/seam/taglib" prefix="s" %>
                <html>
                 <head>
                 <title>Register New User</title>
                 </head>
                 <body>
                 <f:view>
                 <h:form>
                 <table border="0">
                 <tr>
                 <td>Username</td>
                 <td><h:inputText value="#{user.userName}"/></td>
                 </tr>
                 <tr>
                 <td>Password</td>
                 <td><h:inputSecret value="#{user.password}"/></td>
                 </tr>
                 </table>
                 <h:messages/>
                 <h:commandButton type="submit" value="Register" action="#{userController.register}"/>
                 </h:form>
                 </f:view>
                 </body>
                </html>
                


                • 5. Re: @In bijected attributes remaining null?
                  gavin.king

                  And where does user get created? I don't see @In(create=true), so it is happening somewhere you have not told me about. The xhtml?

                  • 6. Re: @In bijected attributes remaining null?
                    gavin.king

                    Oh, the JSP appeared after I posted.