[jboss-user] [JBoss Seam] - component injection seam 1.2.1. ga

ccode do-not-reply at jboss.com
Mon Oct 15 05:23:57 EDT 2007


environment
jboss 4.2 
seam 1.2.1

i have seam component 
package iu.ce.ejb.service;
  | import javax.ejb.Local;
  | import iu.ce.entity.User;
  | @Local
  | public interface UserService {
  | 	public User getUser(String username, String password);
  | }

  | import iu.ce.service.UserService;
  | 
  | import javax.ejb.Stateless;
  | import javax.persistence.EntityManager;
  | import javax.persistence.NoResultException;
  | import javax.persistence.PersistenceContext;
  | import javax.persistence.Query;
  | 
  | import org.jboss.seam.annotations.In;
  | import org.jboss.seam.annotations.Logger;
  | import org.jboss.seam.annotations.Name;
  | import org.jboss.seam.annotations.Out;
  | import org.jboss.seam.log.Log;
  | import org.jboss.seam.security.Identity;
  | 
  | @Stateless
  | @Name("userServiceBean")
  | public class UserServiceBean implements UserService {
  | 	@In
  | 	Identity identity;
  | 	@Logger
  | 	Log log;
  | 	@PersistenceContext(unitName = "iuce")
  | 	private EntityManager entityManager;
  | 
  | 	
  | 	public User getUser(String username, String password) {
  | 		try {
  | 			Query q = entityManager.createQuery("from User u where"
  | 					+ " username=:username and password=:password");
  | 			q.setParameter("username", username);
  | 			q.setParameter("password", password);
  | 			return (User) q.getSingleResult();
  | 		} catch (NoResultException e) {
  | 			return null;
  | 		}
  | 	}
  | 	public void authenticate() {
  | 		log.info("authenticating #0", identity.getUsername());
  | 		getUser("", "");
  | 		//getUser("h","h");
  | 		//userServiceBean.getUser("h", "h");
  | 		// write your authentication logic here,
  | 		// return true if the authentication was
  | 		// successful, false otherwise
  | 		identity.addRole("admin");
  | 		//return true;
  | 	}
  | }
authentication works fine

in application server log
00:47:29,153 INFO  [Component] Component: userServiceBean, scope: STATELESS, type: STATELESS_SESSION_BEAN, class: iu.ce.bean.UserServiceBean, JNDI: iuce-ear/UserServiceBean/local
component seems installed

i have another component standart Authentication component which wizards creates.

when i tried to insert this
@In(create=true)
  | UserBeanService userBeanService 
  | 
or
@In
  | UserBeanService userBeanService 
  | 
it gives following error

  | In attribute requires non-null value ...
  | 
UserServiceBean returns null.

i want to learn how can i inject seam component to another component.


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

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



More information about the jboss-user mailing list