[jboss-user] [JBoss Seam] - Problem about EntityManager.

grdzeli_kaci do-not-reply at jboss.com
Tue May 29 12:17:46 EDT 2007


hi all,
i updated my jboss application server to 4.2.0GA and also i got seam from CVS.
i tried to run simple seam-gen project,
everything works fine, but when i tried to use database level authentication i got an error like this :

  | javax.el.ELException: org.jboss.seam.RequiredException: In attribute requires non-null value: authenticator.em
  |         at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:329)
  |         at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:338)
  |         at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
  |         at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
  |         at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
  | ..................................................................
  | Caused by: org.jboss.seam.RequiredException: In attribute requires non-null value: authenticator.em
  |         at org.jboss.seam.Component.getValueToInject(Component.java:1923)
  |         at org.jboss.seam.Component.injectAttributes(Component.java:1372)
  |         at org.jboss.seam.Component.inject(Component.java:1203)
  |         at org.jboss.seam.interceptors.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
  | 
  | 

i did not understand why is this object is null :(

here is project snippets 
1. Authenticator class:

  | 
  | @Name("authenticator")
  | public class Authenticator  {
  |     
  |     @Logger Log log;
  |     
  |     @In Identity identity;
  |     
  |     @In() EntityManager em;
  |     
  |     public boolean authenticate() {
  |         try {
  |             log.info("authenticating = "+identity.getUsername());
  |             List<Users> users = (List<Users>)em.createNamedQuery("Users.findByUserName").setParameter("userName",identity.getUsername()).getResultList();
  |             if (users==null || (users!=null && users.isEmpty())) {
  |                 FacesMessages.instance().add("User #{user.username} does not exists");
  |                 return false;
  |             } else {
  |                 for (Users user : users) {
  |                     byte dbpaswd [] = user.getUserPwd();
  |                     String strpwd = identity.getPassword();
  |                     MessageDigest md5 = MessageDigest.getInstance("MD5");
  |                     md5.reset();
  |                     md5.update(strpwd.getBytes());
  |                     byte[] userpasswd = md5.digest();
  |                     
  |                     boolean result = MessageDigest.isEqual(userpasswd, dbpaswd);
  |                     if (result) {
  |                         identity.addRole("admin");
  |                         return true;
  |                     }
  |                 }
  |             }
  |             return false;
  |         } catch (Exception e) {
  |             FacesMessages.instance().add("Could not login. System Error");
  |             return false;
  |         }
  |     }
  | }
  | 

2. Components.xml :


  | <core:managed-persistence-context name="entityManager"
  |                                       auto-create="true"
  |                                       persistence-unit-jndi-name="java:/BillingEntityManagerFactory"/>
  | 
3. Billing-dev-ds.xml file :

  | <?xml version="1.0" encoding="UTF-8"?>
  | <datasources>
  |       <local-tx-datasource>
  |       <jndi-name>BillingDatasource</jndi-name>
  |       <connection-url>jdbc:oracle:thin:@192.168.9.135:1521:DEVSTR</connection-url>
  |       <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
  |       <user-name>ccare</user-name>
  |       <password>ccare</password>
  |    </local-tx-datasource>    
  | </datasources>
  | 

4. Client logi.xhtml

  | <h:commandButton id="loginBtn" value="Login" action="#{identity.login}"/>
  | 

what i did incorrect ?
is it possible that reason of it is i have not this jar files into my ear file ???
?commons-jci-core-1.0-406301.jar
?commons-jci-janino-2.4.3.jar
?commons-lang-2.1.jar
?stringtemplate-2.3b6.jar


this jars are described into documentation from where i got this example....



Regards,
Paata.

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

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



More information about the jboss-user mailing list