[jboss-user] [JBoss Seam] - EntityManager not injected in onMessage method

rmcalderero do-not-reply at jboss.com
Sat Feb 9 13:17:03 EST 2008


This is our first Seam application (Seam 2.0.0 GA on Tomcat 6) and we need now to persist in DB the data received from a jms queue.

The jms connection works ok but then we get a NullPointerException in the last line bellow, because the entity manager is not been injected

Are we missing something? In other asynchronous calls in other methods
in the project the entity manager is been injected correcly. Any help would be appreciated.

Our class: 
	
  | @Name("serviceReader")
  | @Scope(APPLICATION)
  | @Startup
  | public class ServicioResultados implements MessageListener {
  | 
  | 	@In
  | 	private EntityManager em;
  | 
  | 	@In(value = "JMSConnectionFactory")
  | 	ConnectionFactory connectionFactory;
  | 
  | 	.....
  | 
  | 	@Create
  | 	public void init() {
  | 
  | 		try {
  | 			connection = connectionFactory.createConnection();
  | 			connection.start();
  | 
  | 			session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
  | 
  | 	.....
  | 
  | 	public void onMessage(Message message) {
  | 
  | 		log.debug("Se ejecuta el Servicio de Resultados: Nuevo mensaje......");
  | 
  | 		try {
  | 			AnalisisCerrado ac = (AnalisisCerrado) ((ObjectMessage) message).getObject();
  | 			ac = em.merge(ac);
  | 		....
  | 

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

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



More information about the jboss-user mailing list