6 Replies Latest reply on Nov 7, 2006 5:25 AM by Pete Muir

    a problem with jBpm in Seam

    Mohammad Norouzi Novice

      Hi
      I am trying to change registration example in order to work with JBpm. but at the first page it is a button with action #"{register.register}"

      I define in pageflow if the user already exists tnot change the current page and if not, go to next page, but It calls action register first and it check the database and because user is not exist then that action persist the data into the database and that action is calling again and in the second time, that user already persisted so the current page staty intact and a message will be displayed.

      here is pageflow definition file:

      <pageflow-definition name="SeamPracticePageFlow">
      
       <start-page name="start" view-id="/pages/register.jsp">
       <transition name="register" to="checkUser" />
       </start-page>
      
       <decision name="checkUser" expression="#{register.alreadyExists}" >
       <transition name="false" to="registered" >
       <action expression="#{register.register}" />
       </transition>
       <transition name="true" to="start" />
       </decision>
      
       <page name="registered" view-id="/pages/registered.jsp">
       <redirect/>
       <transition name="welcomeMessage" to="listMessage" >
       <action expression="/pages/messages.seam" />
       </transition>
       </page>
      
       <page name="listMessage" view-id="/pages/messages.jsp">
       <redirect/>
       <end-conversation/>
       </page>
      
      </pageflow-definition>
      


      and jsp file:
       <f:view>
       <h:form>
       <table border="0">
       <s:validateAll>
       <tr>
       <td>Username</td>
       <td><h:inputText value="#{user.username}" required="true"/></td>
       </tr>
       <tr>
       <td>Full Name</td>
       <td><h:inputText value="#{user.fullName}" required="true"/></td>
       </tr>
       <tr>
       <td>Password</td>
       <td><h:inputSecret value="#{user.password}" required="true"/></td>
       </tr>
       </s:validateAll>
       </table>
       <h:messages/>
       <h:commandButton type="submit" value="Register" action="#{register.register}"/>
       </h:form>
       </f:view>
      


      and the action:
       @Create
       @Begin(join=true,pageflow="SeamPracticePageFlow")
       public void register() {
       try {
       if(isAlreadyExists()) {
       userNotExists = false;
       em.persist(user);
       logger.info("user #{user.username} registered.");
       //return "/pages/registered.jsp";
       }else {
       logger.info("user #{user.username} already registered.");
       userNotExists = true;
       }
       } catch (Exception e) {
       e.printStackTrace();
       }
      
       }
      
       public boolean isUserNotExists() {
       return userNotExists;
       }
      
       public boolean isAlreadyExists() {
       try {
       List registered = em.createQuery("select username from User where username = :u")
       .setParameter("u",user.getUsername())
       .getResultList();
       if(registered == null || registered.size() == 0) {
       return true;
       }else {
       FacesMessages.instance().add("user #{user.username} already exists.");
       return false;
       }
       }catch(Exception e) {
       e.printStackTrace();
       }
       FacesMessages.instance().add("something's wrong...");
       return false;
       }
      
      


        • 1. Re: a problem with jBpm in Seam
          Pete Muir Master

          Looks to me like you want to split out starting the pageflow and registering the user into two seperate methods in the action e.g.

          public void register() {
           try {
           if(isAlreadyExists()) {
           userNotExists = false;
           em.persist(user);
           logger.info("user #{user.username} registered.");
           //return "/pages/registered.jsp";
           }else {
           logger.info("user #{user.username} already registered.");
           userNotExists = true;
           }
           } catch (Exception e) {
           e.printStackTrace();
           }
          }
          
          @Create
          @Begin(join=true,pageflow="SeamPracticePageFlow")
          public void startPageFlow() {
          }
          (make sure to declare startPageFlow on the interface)

          • 2. Re: a problem with jBpm in Seam
            Mohammad Norouzi Novice

            Hi Petemuir

            as you said, I did it but nothing has changed. I think JBpm didnt started to work. do you have any other idea?

            thanks

            • 3. Re: a problem with jBpm in Seam
              Pete Muir Master

              Obviously you need to alter the JSP as well to change the method called to startPageFlow.

              • 4. Re: a problem with jBpm in Seam
                Mohammad Norouzi Novice

                hi

                yes, of course. let me show my codes:

                jsp files:

                .....
                 <tr>
                 <td>Password</td>
                 <td><h:inputSecret value="#{user.password}" required="true"/></td>
                 </tr>
                 <!-- validateAll -->
                 </table>
                 <h:messages/>
                 <h:commandButton type="submit" value="Register" action="register"/>
                 </h:form>
                ......
                


                 @Create
                 @Begin(join=true,pageflow="SeamPracticePageFlow")
                 public void begin() {
                 userNotExists = false;
                 }
                



                <pageflow-definition name="SeamPracticePageFlow">
                
                 <start-page name="start" view-id="/pages/register.jsp">
                 <transition name="register" to="checkUser" >
                 <action expression="#{register.register}" />
                 </transition>
                 </start-page>
                
                 <decision name="checkUser" expression="#{register.alreadyExists}" >
                 <transition name="false" to="registered" />
                 <transition name="true" to="start" />
                 </decision>
                
                 <page name="registered" view-id="/pages/registered.jsp">
                 <redirect/>
                 <transition name="welcomeMessage" to="listMessage" >
                 <action expression="/pages/messages.seam" />
                 </transition>
                 </page>
                ..........
                


                thank you again

                • 5. Re: a problem with jBpm in Seam
                  Mohammad Norouzi Novice

                  Hi again

                  As I had doubt on not loading Jbpm xml file, I decided to put my pageflow.jbpm.xml in the "deploy" directory and remove it from ear file. now it seems the Jboss try to deploy it but deployment fails and there is no noticeable exception message.

                  the name of pageflow file is myproject.jpdl.xml

                  2006-11-07 10:09:26,187 INFO [org.jboss.deployment.EARDeployer] Started J2EE application: file:/H:/jboss-4.0.4.GA/server/default/deploy/registration.ear
                  2006-11-07 10:09:26,187 DEBUG [org.jboss.deployment.MainDeployer] End deployment start on package: registration.ear
                  2006-11-07 10:09:26,187 DEBUG [org.jboss.deployment.MainDeployer] Deployed package: file:/H:/jboss-4.0.4.GA/server/default/deploy/registration.ear
                  2006-11-07 10:09:26,187 DEBUG [org.jboss.deployment.scanner.URLDeploymentScanner] Watch URL for: file:/H:/jboss-4.0.4.GA/server/default/deploy/registration.ear -> file:/H:/jboss-4.0.4.GA/server/default/deploy/registration.ear
                  2006-11-07 10:09:26,187 DEBUG [org.jboss.deployment.MainDeployer] Starting deployment of package: file:/H:/jboss-4.0.4.GA/server/default/deploy/myproject.jpdl.xml
                  2006-11-07 10:09:26,187 DEBUG [org.jboss.deployment.MainDeployer] Starting deployment (init step) of package at: file:/H:/jboss-4.0.4.GA/server/default/deploy/myproject.jpdl.xml
                  2006-11-07 10:09:26,203 DEBUG [org.jboss.deployment.MainDeployer] Copying file:/H:/jboss-4.0.4.GA/server/default/deploy/myproject.jpdl.xml -> H:\jboss-4.0.4.GA\server\default\tmp\deploy\tmp42474myproject.jpdl.xml
                  2006-11-07 10:09:26,203 DEBUG [org.jboss.deployment.MainDeployer] No deployer found for url: file:/H:/jboss-4.0.4.GA/server/default/deploy/myproject.jpdl.xml
                  2006-11-07 10:09:26,203 DEBUG [org.jboss.deployment.MainDeployer] deployment waiting for deployer: file:/H:/jboss-4.0.4.GA/server/default/deploy/myproject.jpdl.xml
                  2006-11-07 10:09:26,218 DEBUG [org.jboss.deployment.MainDeployer] Watching new file: file:/H:/jboss-4.0.4.GA/server/default/deploy/myproject.jpdl.xml
                  2006-11-07 10:09:26,218 DEBUG [org.jboss.deployment.MainDeployer] Deployment of package: file:/H:/jboss-4.0.4.GA/server/default/deploy/myproject.jpdl.xml is waiting for an appropriate deployer.
                  2006-11-07 10:09:26,218 DEBUG [org.jboss.deployment.scanner.URLDeploymentScanner] Watch URL for: file:/H:/jboss-4.0.4.GA/server/default/deploy/myproject.jpdl.xml -> file:/H:/jboss-4.0.4.GA/server/default/deploy/myproject.jpdl.xml
                  2006-11-07 10:09:26,218 ERROR [org.jboss.deployment.scanner.URLDeploymentScanner] Incomplete Deployment listing:
                  
                  --- Packages waiting for a deployer ---
                  org.jboss.deployment.DeploymentInfo@8644f4a0 { url=file:/H:/jboss-4.0.4.GA/server/default/deploy/myproject.jpdl.xml }
                   deployer: null
                   status: null
                   state: INIT_WAITING_DEPLOYER
                   watch: file:/H:/jboss-4.0.4.GA/server/default/deploy/myproject.jpdl.xml
                   altDD: null
                   lastDeployed: 1162881566218
                   lastModified: 1162881566203
                   mbeans:
                  
                  --- Incompletely deployed packages ---
                  org.jboss.deployment.DeploymentInfo@8644f4a0 { url=file:/H:/jboss-4.0.4.GA/server/default/deploy/myproject.jpdl.xml }
                   deployer: null
                   status: null
                   state: INIT_WAITING_DEPLOYER
                   watch: file:/H:/jboss-4.0.4.GA/server/default/deploy/myproject.jpdl.xml
                   altDD: null
                   lastDeployed: 1162881566218
                   lastModified: 1162881566203
                   mbeans:
                  
                  
                  2006-11-07 10:09:26,234 DEBUG [org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread] Notified that enabled: true
                  2006-11-07 10:09:26,234 DEBUG [org.jboss.deployment.scanner.URLDeploymentScanner] Started jboss.deployment:type=DeploymentScanner,flavor=URL
                  2006-11-07 10:09:26,250 DEBUG [org.jboss.system.ServiceController] Starting dependent components for: jboss.deployment:type=DeploymentScanner,flavor=URL dependent components: []
                  2006-11-07 10:09:26,343 DEBUG [org.jboss.deployment.MainDeployer] End deployment start on package: jboss-service.xml
                  2006-11-07 10:09:26,343 DEBUG [org.jboss.deployment.MainDeployer] Deployed package: file:/H:/jboss-4.0.4.GA/server/default/conf/jboss-service.xml
                  2006-11-07 10:09:26,343 DEBUG [org.jboss.web.tomcat.tc5.Tomcat5] Saw org.jboss.system.server.started notification, starting connectors
                  2006-11-07 10:09:26,421 INFO [org.apache.coyote.http11.Http11BaseProtocol] Starting Coyote HTTP/1.1 on http-0.0.0.0-8080
                  2006-11-07 10:09:27,078 INFO [org.apache.jk.common.ChannelSocket] JK: ajp13 listening on /0.0.0.0:8009
                  2006-11-07 10:09:27,171 INFO [org.apache.jk.server.JkMain] Jk running ID=0 time=0/156 config=null
                  2006-11-07 10:09:27,187 INFO [org.jboss.system.server.Server] JBoss (MX MicroKernel) [4.0.4.GA (build: CVSTag=JBoss_4_0_4_GA date=200605151000)] Started in 55s:250ms
                  2006-11-07 10:16:46,156 DEBUG [org.jboss.resource.connectionmanager.IdleRemover] run: IdleRemover notifying pools, interval: 450000
                  2006-11-07 10:24:16,156 DEBUG [org.jboss.resource.connectionmanager.IdleRemover] run: IdleRemover notifying pools, interval: 450000
                  2006-11-07 10:31:46,156 DEBUG [org.jboss.resource.connectionmanager.IdleRemover] run: IdleRemover notifying pools, interval: 450000
                  
                  


                  • 6. Re: a problem with jBpm in Seam
                    Pete Muir Master

                    Try using

                    <h:commandButton type="submit" value="Register" action="#{register.begin}"/>


                    @Begin(join=true,pageflow="SeamPracticePageFlow")
                     public void begin() {
                     userNotExists = false;
                     }


                    I suspect the bean is not being created so the @Create method isn't running. N.B. This might require you to change start-page to start-state.

                    No, you shouldn't put the pageflow.xml in the deploy directory, JBoss doesn't know how to use them, Seam does so they go in the ear and are referenced in components.xml