[jboss-user] [JBoss Seam] - Re: Serious issue getting a basic example of seam 2, jbpm, e

mickknutson do-not-reply at jboss.com
Wed Oct 24 16:46:03 EDT 2007


Got that, and that helped. Thanks!

I have another isuue though as soon as that one was complete:

Exception during request processing:
Caused by javax.servlet.ServletException with message: "#{userService.startRegistration}: javax.ejb.EJBTransactionRolledbackException: @In attribute requires non-null value: userService.user"

Here is my UserServiceAction:

  | package com.baselogic.yoursos.user;
  | 
  | import org.hibernate.validator.InvalidStateException;
  | import org.hibernate.validator.InvalidValue;
  | 
  | import org.jboss.seam.annotations.Begin;
  | import org.jboss.seam.annotations.In;
  | import org.jboss.seam.annotations.Name;
  | import org.jboss.seam.annotations.Out;
  | import org.jboss.seam.bpm.Actor;
  | import org.jboss.seam.contexts.Context;
  | import org.jboss.seam.faces.FacesMessages;
  | import org.jboss.seam.security.Identity;
  | 
  | import javax.annotation.Resource;
  | 
  | import javax.ejb.Remove;
  | import javax.ejb.SessionContext;
  | import javax.ejb.Stateful;
  | 
  | import javax.persistence.EntityManager;
  | import javax.persistence.PersistenceContext;
  | 
  | 
  | /**
  |  * User Service Bean.
  |  */
  | @Stateful
  | @Name("userService")
  | public class UserServiceAction implements UserService {
  | 
  |     /** variable. */
  |     @PersistenceContext EntityManager em;
  | 
  |     /** variable. */
  |     @Resource SessionContext ctx;
  | 
  |     /** variable. */
  |     @In Context sessionContext;
  | 
  |     /** variable. */
  |     @In(create=true)
  |     @Out
  |     User user;
  | 
  |     /** variable. */
  |     @In FacesMessages facesMessages;
  | 
  |     /** variable. */
  |     @In Identity identity;
  | 
  |     /** variable. */
  |     String password = null;
  | 
  |     /**
  |      * todo DOCUMENT ME!
  |      *
  |      * @param  password  todo DOCUMENT ME!
  |      */
  |     public void setPasswordVerify(String password) {
  |         this.password = password;
  |     }
  | 
  |     /**
  |      * todo DOCUMENT ME!
  |      *
  |      * @return  todo DOCUMENT ME!
  |      */
  |     public String getPasswordVerify() {
  |         return password;
  |     }
  | 
  | 
  |     /**
  |      * todo DOCUMENT ME!
  |      */
  |     @Begin(
  |         nested = true,
  |         pageflow = "registration"
  |     )
  |     public void startRegistration() {
  |     }
  | 
  |     /**
  |      * todo DOCUMENT ME!
  |      *
  |      * @return  todo DOCUMENT ME!
  |      */
  |     public boolean isValidNamePassword() {
  |         boolean ok = true;
  | 
  |         if (!isUniqueName()) {
  |             facesMessages.add("userName", "This name is already in use");
  |             ok = false;
  |         }
  | 
  |         if (!isPasswordsMatch()) {
  |             facesMessages.add("passwordVerify", "Must match password field");
  |             ok = false;
  |         }
  | 
  |         return ok;
  |     }
  | 
  |     /**
  |      * todo DOCUMENT ME!
  |      *
  |      * @return  todo DOCUMENT ME!
  |      */
  |     @SuppressWarnings("unchecked")
  |     private boolean isUniqueName() {
  |         String name = user.getUsername();
  | 
  |         /*if (name == null) return true;
  | 
  |         List<User> results = em.createQuery("select u from User u where u.userName = :name")
  |                 .setParameter("name", name)
  |                 .getResultList();
  | 
  |         return results.size() == 0;*/
  |         return true;
  |     }
  | 
  |     /**
  |      * todo DOCUMENT ME!
  |      *
  |      * @return  todo DOCUMENT ME!
  |      */
  |     private boolean isPasswordsMatch() {
  |         String customerpass = user.getPassword();
  | 
  |         return (password != null) && (customerpass != null)
  |             && (customerpass.equals(password));
  |     }
  | 
  |     /**
  |      * todo DOCUMENT ME!
  |      *
  |      * @return  todo DOCUMENT ME!
  |      */
  |     public String saveUser() {
  | 
  |         if (!isValidNamePassword()) {
  |             /////facesMessages.add("User name #{customer.userName} is not unique");
  | 
  |             return null;
  |         }
  | 
  |         try {
  |             em.persist(user);
  |             sessionContext.set("currentUser", user);
  |             Actor.instance().setId(user.getUsername());
  | 
  |             identity.setUsername(user.getUsername());
  |             identity.setPassword(user.getPassword());
  |             identity.login();
  | 
  |             facesMessages.addFromResourceBundle("createCustomerSuccess");
  | 
  |             return "success";
  |         } catch (InvalidStateException e) {
  |             InvalidValue[] vals = e.getInvalidValues();
  | 
  |             for (InvalidValue val : vals) {
  |                 facesMessages.add(val);
  |             }
  | 
  |             return null;
  |         } catch (RuntimeException e) {
  |             ctx.setRollbackOnly();
  | 
  |             facesMessages.addFromResourceBundle("createCustomerError");
  | 
  |             return null;
  |         }
  |     }
  | 
  |     /*public Map<String, Integer> getCreditCardTypes() {
  |         Map<String, Integer> map = new TreeMap<String, Integer>();
  |         for (int i = 1; i <= 5; i++) {
  |             map.put(Customer.cctypes[i - 1], i);
  |         }
  |         return map;
  |     }*/
  | 
  |     /**
  |      * todo DOCUMENT ME!
  |      */
  |     @Remove public void destroy() {
  |     }
  | 
  | } // The End...
  | 


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

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



More information about the jboss-user mailing list