[jboss-user] [JBoss jBPM] - Injecting the hibernate session

chrisrjcox do-not-reply at jboss.com
Mon Mar 3 11:29:37 EST 2008


Hi,

 I have the following code within a Message Driven Bean, I can get it to create a JbpmContext however I'm getting stuck with regards to Injecting the hibernate session...

Eclipse is stating that I "cannot make a static reference to the none static ethod getCurrentSession() from the type SessionFactory"

I'm following this from Chaper 7 page 5 on the jbpm guide. (7.1.4)


  | package com.distributed.jbpm.mdb;
  | 
  | import javax.ejb.MessageDriven;
  | import javax.ejb.ActivationConfigProperty;
  | 
  | import javax.jms.JMSException;
  | import javax.jms.Message;
  | import javax.jms.MessageListener;
  | import javax.jms.TextMessage;
  | 
  | import org.jbpm.JbpmConfiguration;
  | import org.jbpm.JbpmContext;
  | import org.jbpm.graph.exe.ProcessInstance;
  | import org.hibernate.*;
  | 
  | 
  | 
  | @MessageDriven(activationConfig =
  | 	{
  | 		@ActivationConfigProperty(propertyName="acknowledgeMode", propertyValue = "Auto-acknowledge"),
  | 		@ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
  | 		@ActivationConfigProperty(propertyName="destination", propertyValue="/queue/jbpmQueueTwo")
  | 	})
  | 
  | public class PartTwoMDB implements MessageListener
  | {
  | 	static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
  | 	
  | 	public void onMessage(Message inMessage)
  | 	{
  | 		TextMessage textMessage = null;
  | 		try
  | 		{
  | 			if(inMessage instanceof TextMessage)
  | 			{
  | 				textMessage = (TextMessage) inMessage;
  | 				System.out.println("PartTwoMDB: Message received: "+ textMessage.getText());
  | 				
  | 				JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
  | 				System.out.println("PartTwoMDB: jbpmContextCreated");
  | 				try
  | 				{
  | 					jbpmContext.setSession(SessionFactory.getCurrentSession());
  | 					String processDefinitionName = "processTwo";
  | 					System.out.println("PartTwoMDB: processDefinitionName * " + processDefinitionName + " * String created.");
  | 					ProcessInstance processInstance = jbpmContext.newProcessInstance(processDefinitionName);
  | 					System.out.println("PartTwoMDB: Instance" + processInstance.toString() + " Loaded.");
  | 					processInstance.signal();
  | 					System.out.println("PartTwoMDB: Instance signal sent.");
  | 				}
  | 				finally
  | 				{
  | 					jbpmContext.close();
  | 				}
  | 				
  | 			}
  | 			else
  | 			{
  | 				System.out.println("PartTwoMDB: Message of wrong type: " + inMessage.getClass().getName());
  | 			}
  | 		}
  | 		catch (JMSException e)
  | 		{
  | 			e.printStackTrace();
  | 		}
  | 		catch (Throwable t)
  | 		{
  | 			t.printStackTrace();
  | 		}
  | 		
  | 	}
  | }
  | 
  | 

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

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



More information about the jboss-user mailing list