Hi Matthieu,
Thanks for the tip, but I am using this outside of any container,
standalone. Use only Spring DI to
configure Bitronix transaction manager.
I'll have to check out that perhaps OpenJpa and Hibernate get mixed up in
standalone environment as well.
Have Hibernate on my classpath since I (wrongly?) assumed hibernate is
required for OpenJpa,
will do some additional testings.
Thanks
On Feb 5, 2008 11:03 PM, Matthieu Riou <[EMAIL PROTECTED]> wrote:
> Hi,
>
> You seem to have an environmental problem as OpenJPA is configured as your
> persistence layer but javax.persistence.Persistence picks up Hibernate.
> Are
> you running under JBoss? There are some configuration issues under JBoss
> as
> Hibernate is picked up by default as a JPA implementation, bypassing
> OpenJPA. You'll probably need to have a look at JBoss documentation to see
> how to make it a bit more "agnostic" in that respect.
>
> Cheers,
> Matthieu
>
> On Feb 5, 2008 9:44 AM, xenHalfLife <[EMAIL PROTECTED]> wrote:
>
> > Hello all,
> >
> > I'm having trouble configuring external transaction manager and
> externally
> > managed data source;
> > looking in sources and tests, including Axis and ServiceMix integration
> > API
> > implementations
> > I could not find the answer.
> >
> > Thanks in advance
> >
> >
> > Scenario:
> >
> > Trying to configure ODE to work with external transaction manager and
> > externally managed DataSource.
> >
> > As transaction manager I am using Bitronix, and as XA capable database
> > MySql.
> >
> > It should not be issue with Bitronix since XA tests with 2 MySql
> instances
> > and ActiveMq broker are working as expected (These tests didnt include
> > ODE).
> >
> > Implementation of Integration API is based on those found in bpel-test
> > module
> > of source ODE distribution:
> >
> > org.apache.ode.test.MessageExchangeContextImpl
> > org.apache.ode.test.BindingContextImpl
> > org.apache.ode.test.PartnerRoleChannelImpl
> >
> > Source code of above classes has not been modified, and
> "bpel/2.0/TestIf"
> > is
> > the
> > bpel/wsdl definition used for testing.
> >
> >
> > The configuration of BPEL server at startup time is as follows:
> >
> > Note: dataSource variable is instance of javax.sql.DataSource, and
> > txManager
> > is instance
> > of javax.transaction.TransactionManager.
> >
> >
> >
> ------------------------------------------------------------------------------------------------
> > MessageExchangeContextImpl ctx = new
> MessageExchangeContextImpl();
> > this.server = new BpelServerImpl();
> > this.scheduler = new MockScheduler(this.txManager);
> >
> > Properties jpaProps = new Properties();
> > jpaProps.put("openjpa.jdbc.DBDictionary", "
> > org.apache.openjpa.jdbc.sql.MySQLDictionary");
> > jpaProps.put("openjpa.Log", "DefaultLevel=TRACE");
> > BPELDAOConnectionFactoryImpl factory = new
> > BPELDAOConnectionFactoryImpl();
> > factory.setTransactionManager(this.txManager);
> > factory.setDataSource(this.dataSource);
> > factory.init(jpaProps);
> >
> > this.server.setDaoConnectionFactory(factory);
> >
> > this.server.setScheduler(scheduler);
> > this.server.setBindingContext(new BindingContextImpl());
> > this.server.setMessageExchangeContext(ctx);
> > scheduler.setJobProcessor(this.server);
> >
> >
> > // this line prints true
> > System.out.println(this.dataSource instanceof DataSource);
> >
> > this.processStore = new ProcessStoreImpl(this.dataSource, "jpa",
> > true);
> > this.processStore.registerListener(new ProcessStoreListener() {
> > public void onProcessStoreEvent(ProcessStoreEvent event) {
> > BpelManager.this.server.unregister(event.pid);
> > if (event.type != ProcessStoreEvent.Type.UNDEPLOYED) {
> > ProcessConfImpl conf = (ProcessConfImpl)
> > BpelManager.this.processStore
> > .getProcessConfiguration(event.pid);
> > conf.setTransient(true);
> > BpelManager.this.server.register(conf);
> > }
> > }
> > });
> > Properties props = new Properties();
> > props.setProperty("debugeventlistener.dumpToStdOut", "no");
> > this.server.setConfigProperties(props);
> > this.server.registerBpelEventListener(new
> > DebugBpelEventListener());
> > this.server.init();
> > this.server.start();
> >
> > Collection<QName> deployed = this.processStore.deploy(new
> > File("data/bpel/2.0/TestIf"));
> > for (QName name : deployed) {
> > ProcessConfImpl conf = (ProcessConfImpl) this.processStore
> > .getProcessConfiguration(name);
> > conf.setTransient(true);
> > this.server.register(conf);
> > }
> >
> >
> -------------------------------------------------------------------------------------------------
> >
> >
> >
> > In main method following is performed:
> >
> >
> >
> -------------------------------------------------------------------------------------------------
> > transactionManager.begin();
> >
> > Statement stmt = dataSource.getConnection().createStatement();
> > stmt.executeUpdate("insert into mytable values('somevalue" +
> > System.currentTimeMillis() + "')");
> >
> > MyRoleMessageExchange exchange =
> > manager.getServer().getEngine().createMessageExchange(""
> >
> > + System.currentTimeMillis(), new QName("
> > http://ode/bpel/unit-test.wsdl", "HelloService"), "hello");
> >
> > Message message = exchange.createMessage(new QName("
> > http://ode/bpel/unit-test.wsdl", "HelloMessage"));
> > message.setMessage(DOMUtils.stringToDOM("<message><TestPart>2.0
> > </TestPart></message>"));
> > Future<MessageExchange.Status> running = exchange.invoke
> (message);
> >
> > transactionManager.commit();
> >
> >
> -------------------------------------------------------------------------------------------------
> >
> >
> > Obviously one needs to have reference to ProcessStore in order to deploy
> > processes, and above way is only one
> > I have managed to figure out.
> >
> > When I run this example I get following stack trace:
> >
> >
> >
> >
> -------------------------------------------------------------------------------------------------
> > Bitronix has been initialized...
> > 2008-02-05 12:01:50,953 INFO [org.hibernate.cfg.annotations.Version] -
> > Hibernate Annotations 3.3.0.GA
> > 2008-02-05 12:01:51,000 INFO [org.hibernate.cfg.Environment] - Hibernate
> > 3.2.5
> > 2008-02-05 12:01:51,000 INFO [org.hibernate.cfg.Environment] -
> > hibernate.properties not found
> > 2008-02-05 12:01:51,000 INFO [org.hibernate.cfg.Environment] - Bytecode
> > provider name : cglib
> > 2008-02-05 12:01:51,015 INFO [org.hibernate.cfg.Environment] - using JDK
> > 1.4
> > java.sql.Timestamp handling
> > 2008-02-05 12:01:51,078 INFO [org.hibernate.ejb.Version] - Hibernate
> > EntityManager 3.3.1.GA
> > 2008-02-05 12:01:51,093 DEBUG [org.hibernate.ejb.Ejb3Configuration] -
> Look
> > up for persistence unit: ode-dao
> > 0 ode-dao TRACE [main] openjpa.Runtime - Setting the following
> > properties
> > from "jar:file:/C:/DEVELOPMENT/workspaces/ODE/bpel-xa/lib/ode-
> > dao-jpa-1.1.1.jar!/META-INF/persistence.xml" into configuration: {
> > openjpa.FlushBeforeQueries=false,
> > openjpa.jdbc.DBDictionary=org.apache.openjpa.jdbc.sql.MySQLDictionary,
> > openjpa.BrokerFactory=jdbc, openjpa.ConnectionFactory=aPoolingDataSource
> > containing an XAPool of resource mysql-1 with 1 connection(s) (1 still
> > available), openjpa.Log=DefaultLevel=TRACE, openjpa.MetaDataFactory=jpa
> > (Types=org.apache.ode.dao.jpa.ActivityRecoveryDAOImpl
> >
> ;org.apache.ode.dao.jpa.CorrelationSetDAOImpl;org.apache.ode.dao.jpa.CorrelatorDAOImpl;org.apache.ode.dao.jpa.EventDAOImpl;org.apache.ode.dao.jpa.FaultDAOImpl;org.apache.ode.dao.jpa.MessageDAOImpl;org.apache.ode.dao.jpa.MessageExchangeDAOImpl;org.apache.ode.dao.jpa.MessageRouteDAOImpl;org.apache.ode.dao.jpa.PartnerLinkDAOImpl;org.apache.ode.dao.jpa.ProcessDAOImpl;org.apache.ode.dao.jpa.ProcessInstanceDAOImpl;org.apache.ode.dao.jpa.ScopeDAOImpl;org.apache.ode.dao.jpa.XmlDataDAOImpl;org.apache.ode.dao.jpa.CorrSetProperty;org.apache.ode.dao.jpa.MexProperty;org.apache.ode.dao.jpa.XmlDataProperty),
> >
> >
> [EMAIL PROTECTED]
> > ,
> >
> >
> javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl
> > ,
> > openjpa.ConnectionFactoryMode=managed, openjpa.Id=ode-dao}
> > Must be true: true
> > 2008-02-05 12:01:51,750 DEBUG [org.hibernate.ejb.Ejb3Configuration] -
> Look
> > up for persistence unit: ode-store
> > javax.persistence.PersistenceException: Provider error. Provider:
> > org.hibernate.ejb.HibernatePersistence
> > at javax.persistence.Persistence.createFactory(Persistence.java:175)
> > at javax.persistence.Persistence.createEntityManagerFactory(
> > Persistence.java:111)
> > at org.apache.ode.store.jpa.DbConfStoreConnectionFactory.<init>(
> > DbConfStoreConnectionFactory.java:45)
> > at org.apache.ode.store.ProcessStoreImpl.<init>(ProcessStoreImpl.java
> > :122)
> > at com.mytest.xa.BpelManager.init(BpelManager.java:73)
> > at com.mytest.xa.Main.main(Main.java:35)
> > Caused by: javax.persistence.PersistenceException:
> > java.lang.ClassCastException:
> bitronix.tm.resource.jdbc.PoolingDataSource
> > at org.hibernate.ejb.Ejb3Configuration.configure(
> Ejb3Configuration.java
> > :258)
> > at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(
> > HibernatePersistence.java:120)
> > at javax.persistence.Persistence.createFactory(Persistence.java:171)
> > ... 5 more
> > Caused by: java.lang.ClassCastException:
> > bitronix.tm.resource.jdbc.PoolingDataSource
> > at org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy(
> > PersistenceXmlLoader.java:113)
> > at org.hibernate.ejb.Ejb3Configuration.configure(
> Ejb3Configuration.java
> > :215)
> > ... 7 more
> > Feb 5, 2008 12:01:51 PM bitronix.tm.BitronixTransactionManager shutdown
> > INFO: shutting down Bitronix Transaction Manager
> >
> >
> -------------------------------------------------------------------------------------------------
> >
> >
> > What is confusing me is
> > org.apache.ode.store.jpa.DbConfStoreConnectionFactory class which in
> > constructors
> > calls "propMap.put("javax.persistence.nonJtaDataSource", ds);" marking
> > DataSource as non-managed, though
> > I want it to be externally managed.
> >
> > I have double checked if Bitronix correctly implements
> > javax.sql.DataSource,
> > and its ok. Outside of ODE
> > XA transaction are working correctly.
> >
> > Any tips appreciated.
> >
> > Thanks.
> >
>