Re: how to disable toplink?
Just to note that we have both Toplink and OpenJPA deployed entirely inside a single EAR file under WebSphere 6.1.(which is Java 5 but J2EE 4). We can switch it back and forth between Toplink and OpenJPA modes of operation, without regenerating the EAR, as follows. - change the provider name in persistence.xml. - leave both toplink-essentials.jar and the openjpa jars in the root of the ear at all times - to run in openjpa mode, just update the provider name persistence.xml and in remove the dependency (manifest classpath entry) for toplink-essentials - it is not necessary to remove the dependencies on the openjpa jars when running under toplink. - it is not necessary to ever change any build paths or rebuild The reason that it is necessary to remove the dependency (classpath entry) for toplink when operating in openjpa mode is that otherwise toplink briefly gets control when openjpa enumerates the providers, and at that point toplink gets fatal exceptions because it is not the provider in persistence.xml. When running in toplink mode, toplink enumerates the openjpa provider but openjpa returns control nicely and does nothing when it sees that it has nothing to do! Incidentally, this is somewhat past tense for us because we have now switched to standard operation on OpenJPA and find it superior. So we may soon remove the toplink-essentials jar altogether. Don Marc Prud'hommeaux wrote: Roger- I think the first step would be to get it working in glassfish when deployed globally, and then move from there to seeing if it is possible to deploy it within a WAR. What is the error you get (if any) if you deploy globally? The following persistence.xml worked the last time I tried it: persistence xmlns=http://java.sun.com/xml/ns/persistence; version=1.0 persistence-unit name=pu1 providerorg.apache.openjpa.persistence.PersistenceProviderImpl/provider jta-data-sourcejdbc/__default/jta-data-source properties property name=openjpa.Log value=DefaultLevel=TRACE/ property name=openjpa.jdbc.SynchronizeMappings value=buildSchema/ /properties /persistence-unit /persistence On Nov 22, 2006, at 2:57 AM, roger.keays wrote: Hi Marc, Marc Prud wrote: What happens if you put the OpenJPA jars and dependencies in the system classpath of the container? Does it work then? I did try this unsuccessfully on glassfish, although some people have reported that they can get this to work. I'm really looking for a solution that doesn't require the user to hack their container though. Roger If so, then that might be the only solution, currently. IIRC, the spec doesn't say anything about allowing JPA implementations themselves to be bundled into WARs or EARs, so there might no be any generic way to do so (which isn't to say that it's impossible; it might just require some container-specific glue to make it work). On Nov 21, 2006, at 11:59 PM, roger.keays wrote: Is anybody aware of an effective way to ensure that the openjpa jars distributed in a WAR are used for the persistence implementation? I have tried providerorg.apache.openjpa.persistence.PersistenceProviderImpl/ provider in persistence.xml, and javax.persistence.spi.PersistenceProvider=org.apache.openjpa.persisten ce.PersistenceProviderImpl in the emf properties map but neither appear to work. This problem occurs when deploying to Glassfish, oc4j and (to a lesser extent) Resin (resin provides a buggy ejb30.jar). It seems to be a classloading problem, because these containers load the Persistence.class from their own lib instead of the webapp's. Since that class can't find openjpa, it just falls back to toplink. I had expected the webapp's classes to be loaded in preference to the containers though. Any suggestions? Roger --View this message in context: http://www.nabble.com/how-to-disable- toplink--tf2683540.html#a7485258 Sent from the open-jpa-dev mailing list archive at Nabble.com. --View this message in context: http://www.nabble.com/how-to-disable-toplink--tf2683540.html#a7486568 Sent from the open-jpa-dev mailing list archive at Nabble.com.
Should UserTransaction Work?
I cannot get UserTransaction to work. Nothing happens when I commit. This consists of: - Using a JTA datasource - specifying Bean Managed Transaction rather then CMT on the enclosing session Bean. - looking up a UserTransaction with: UserTransaction userTran = (UserTransaction) initCtx .lookup(java:comp/UserTransaction); then doing a begin on it, some entity lookup and changes, and a commit. Could anyone tell me if this should work? This is under WebSphere 6.1. As background, I am able to get a JTA data source to work fine if I use Container Managed Transactions rather than BMT. The problem with that approach for me is that I am calling the session Bean as a web-service-enable endpoint. If I leave committing the transaction entirely to JTA, the commit is done after all of my web service code has exited and any errors are thrown as soap faults. I want to be able to catch the error and analyze it before returning from the web service. I can also do this fine with Resource Local Transactions but then I do not get the benefits of a JTA datasource managed by WebSphere. So I am trying to use JTA with BMT which I believe would allow me to catch errors on commit. If this is too much of a user question for this list, please let me know. Thanks! Don
Re: Should UserTransaction Work?
Michael Dick wrote: If you lookup the UserTransaction in your Session Bean, then your approach should work. I tried making the Feature Pack sample application a BMT bean and it seemed to work for me. I can send you the application if you'd like. If the transaction is started prior to looking up a BMT bean, then it will be suspended before the bean method executes. I don't know much about web services, this might not be the case or possible. Michael and Craig and Kevin, I got it to work! Thanks very much for the help. My error was in failing to start the Transaction *prior to* creating the EntityManager. Once I did that, it worked. I should have realized that OpenJPA needed to have the Global Transaction already started by the time it looks to see if it is running in a Transaction context. As Craig mentioned, this BMT approach is a very nice pattern to have working, because it allows me to pass the underlying error back to the Web Service caller, rather than just the non-specfic TransactionRolledBackException from a CMT bean. Thanks, Don
Cache with two ConnectionFactories?
I could not figure this out in reading the OpenJPA documentation. We have just the one database and set of tables, but we need to have two separate Connection Pools to the same database in order to have two different userid's. (We want to set the priorities on the database differently for access by the two different usernames). One is to be used for updates and short queries, and the other for queries expected to give large result sets. In these circumstances, is it possible to use the Data Cache and the Query Cache? I am worried that if a new entity / data row is created in the Data Cache under one userid/pool/connectionFactory, it will not show up in the Query Cache for the other userid/pool/connectionFactory if a query is done. Thanks and if this is off-topic please let me know. Maybe the thing to do would be to have a cache enabled for the userid/pool/connectionFactory used for short queries and updates, but no cache for the userid/pool/connectionFactory? Don
Re: howto/pattern for working with three databases outside an EJB3 container
Patrick, Can the following not be used? createEntityManagerFactory(String name, String resource) Returns a new OpenJPAEntityManagerFactory specified by name in an XML configuration file at the resource location resource. Don Patrick Linskey wrote: Hmm. Theoretically, this is what the OpenJPAPersistence.getEntityManagerFactory() methods are there for. However, looking at them, there is no way to specify your persistence unit when using those methods. We should add those methods to OpenJPAPersistence. Am I overlooking something in the implementation of those methods, anyone? -Patrick