[jboss-user] [JBoss Seam] - Re: Hibernate SessionFactory in Seam App?

PatrickMadden do-not-reply at jboss.com
Thu Dec 21 10:22:30 EST 2006


Hi, I'm getting a exception as follows when trying to do as you described. I must have something else wrong unfortunately.

anonymous wrote : javax.naming.NameNotFoundException: EntityManagerFactory not bound

I've wrapped my servlet with SeamServletFilter as follows in web.xml

	
  | <!-- propogate seam context to servlets (pvm) addition -->
  | 	<filter>
  | 		<filter-name>Seam Servlet Filter</filter-name>
  | 		<filter-class>org.jboss.seam.servlet.SeamServletFilter</filter-class>
  | 	</filter>
  | 	<filter-mapping>
  | 		<filter-name>Seam Servlet Filter</filter-name>
  | 		<url-pattern>/servlet/*</url-pattern>
  | 	</filter-mapping>
  | <!-- end seam context to servlets -->
  | 

And for my verify user servlet mapping I have the following


  |   	<servlet>
  | 	  	<servlet-name>VerifyUser</servlet-name>
  | 	    <servlet-class>
  | 	        com.clooster.web.servlet.VerifyUser
  | 	    </servlet-class>  	 	
  |   	</servlet>
  |   
  | 	  <servlet-mapping>
  | 	    <servlet-name>VerifyUser</servlet-name>
  | 	    <url-pattern>/servlet/VerifyUser</url-pattern>
  | 	  </servlet-mapping> 
  | 

Inside my servlet I have an API to get the EntityManager as follows:


  |     protected EntityManager getEntityManager() throws NamingException
  |     {
  |         EntityManagerFactory factory = (EntityManagerFactory)
  |             Naming.getInitialContext().lookup("java:/EntityManagerFactory");
  |         
  |         EntityManager em = factory.createEntityManager();
  |         
  |         return em;
  |     }
  | 

Calling the above method results in the NameNotFoundException.

One another note, once I have the above problem solved - what is the prescribed way to redirect a user to a property seam page. I'm going to attempt to do the following - will it work?


  |                     EntityManager em = this.getEntityManager();                   
  |                     
  |                     ClUsers user = em.find(ClUsers.class, greeter.getName());
  |                     
  |                     if (user != null)
  |                     {                   
  |                         // ok we have verified that this user's email address is valid
  |                         // and he/she is whom they say they are - set the status
  |                         // in the db and commit for this user.
  |                         
  |                         user.setStatus((short) 1);
  |                         
  |                         em.persist(user);
  |                         
  |                         // now login the user
  |                         LoginAction loginAction = (LoginAction) Component.getInstance(LoginAction.class);
  |                         Contexts.getSessionContext().set("greeter", greeter);
  |                         loginAction.login();
  |                     }
  |                     else
  |                     {
  |                         response.getOutputStream().println(
  |                                 "Invalid User");
  |                     }  
  |  

Or should I be using the HttpServletResponse.enodeRedirectURL API?

Again, thank you for your great work!

PVM

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

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



More information about the jboss-user mailing list