thanks for the reply mkarami.
I am using Core Hibernate (instead of EJB3) with JTA (from jboss App server).
Secondly, if i look close when dunks reported this problem,
Code:
org.hibernate.HibernateException: Could not locate TransactionManager
his settings were similar as mine which were
Quote:
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" />
<property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory" />
<property name="jta.UserTransaction" value="java:comp/UserTransaction" />
The solution to this problem posted by jacekolszak was to have this code piece
Quote:
EJB3StandaloneBootstrap.boot(null);
deployer = new EJB3StandaloneDeployer();
deployer.setJndiProperties(getInitialContextProperties());
deployer.create();
deployer.start();
ctx = getInitialContext();
.
.
.
public static InitialContext getInitialContext() throws Exception {
Hashtable props = getInitialContextProperties();
return new InitialContext(props);
}
private static Hashtable getInitialContextProperties() {
Hashtable<String, String> props = new Hashtable<String, String>();
props.put("java.naming.factory.initial",
"org.jnp.interfaces.LocalOnlyContextFactory");
props.put("java.naming.factory.url.pkgs",
"org.jboss.naming:org.jnp.interfaces");
return props;
}
I am not sure how I can setup these initialContextProperties correctly when working with core Hibernate, I gave it a shot to get as close as possible. But I am still getting the same exact error and debug outputs.
Here's my latest
Patient Managerhttp://rafb.net/p/mQWNAq93.htmlThe only change I have done is this code block
Code:
UserTransaction utx=null;
Context ctx=null;
public PatientManager() throws Exception{
Configuration conf = new Configuration();
conf.setProperties(getInitialContextProperties());
utx= (UserTransaction) getInitialContext().lookup("java:comp/UserTransaction");
}
public static InitialContext getInitialContext() throws Exception {
Hashtable props = getInitialContextProperties();
return new InitialContext(props);
}
private static Properties getInitialContextProperties() {
Properties props = new Properties();
props.put("java.naming.factory.initial",
"org.jnp.interfaces.LocalOnlyContextFactory");
props.put("java.naming.factory.url.pkgs",
"org.jboss.naming:org.jnp.interfaces");
return props;
}
it uses Configuration object instead of EJB3StandaloneDeployer(I am assuming they are each other's equivalents in Hibernate core and EJb3 worlds)
My PatientTest and hibernate.cfg.xml stay the same.
Here's my Hibernate.cfg.xml
http://rafb.net/p/XpwAFE18.html
Here's the PatientTest
http://rafb.net/p/XeCRbb39.html
I notice I get this exception in my HibernateUtil class's static block..
Here's my HibernateUtil
http://rafb.net/p/s6XFlj76.html
Here's the exception trace again
http://rafb.net/p/0PyMuw56.html
Here's the DEBUG output again..
http://rafb.net/p/wK5Hdn55.html
I don't know why, please help ...