Hi all,
Just an update...
I just downloaded a fresh version of Karaf-2.2.8, did a checkout of
https://github.com/cschneider/Karaf-Tutorial, changed the
db/examplejpa/src/main/resources/OSGI-INF/blueprint/blueprint.xml file
to have a 'default-activation="lazy"', then followed the bundle install
instructions in the readme.txt and this is the result:
karaf@root> person:add 'Christian Schneider' @schneider_chris
Error executing command: No transaction currently active
If I leave the 'default-activation="eager"', there is a java.lang.Verify
exception thrown:
Caused by: java.lang.VerifyError: (class:
net/lr/tutorial/karaf/db/examplejpa/impl/$PersonServiceImpl723600344, method:
<init> signature: (Ljava/lang/reflect/InvocationHandler;)V) Call to wrong
initialization method
at java.lang.Class.getDeclaredConstructors0(Native Method)[:1.6.0_24]
at
java.lang.Class.privateGetDeclaredConstructors(Class.java:2406)[:1.6.0_24]
at java.lang.Class.getConstructor0(Class.java:2716)[:1.6.0_24]
at java.lang.Class.getConstructor(Class.java:1674)[:1.6.0_24]
at
org.apache.aries.proxy.impl.gen.ProxySubclassGenerator.newProxySubclassInstance(ProxySubclassGenerator.java:159)
at
org.apache.aries.proxy.impl.AsmProxyManager.createNewProxy(AsmProxyManager.java:81)
At the very least, this tells me that I am not doing anything wrong from
within my codebase. Yet, I am still hung up on this issue. Suggestions?
Regards,
Jason
On 07/24/2012 09:14 PM, Jason Reilly wrote:
David,
Yes....I deploy via a custom distribution, so all packages are set to
start on start-up. And I restarted the aries transaction bundle from
the interactive console.
Regards,
Jason
On 07/24/2012 08:39 PM, David Jencks wrote:
You did install/start the aries transaction manager bundle?
david jencks
On Jul 24, 2012, at 3:52 PM, Jason wrote:
Hi all,
I have been running into an exception lately and can't seem to
remedy the problem. I am getting a
"javax.persistence.TransactionRequiredException: No transaction
currently active" exception. I am using Karaf v2.2.8, ActiveMQ
5.6.0, OpenJPA 2.1.1, and CXF 2.6.1. I followed the Apache Aries
sample blog application, so there is a datasource registered via
blueprint...looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
default-activation="lazy">
<cm:property-placeholder persistent-id="edu.unc.mapseq.ds">
<cm:default-properties>
....snip....
</cm:default-properties>
</cm:property-placeholder>
<bean id="mapseq-ds-jta" class="org.postgresql.xa.PGXADataSource">
<property name="user" value="${username}" />
<property name="password" value="${password}" />
<property name="serverName" value="${serverName}" />
<property name="databaseName" value="${databaseName}" />
<property name="portNumber" value="${port}" />
</bean>
<service id="mapseqXADataSource" ref="mapseq-ds-jta"
interface="javax.sql.XADataSource">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/mapseqJTA" />
</service-properties>
</service>
<bean id="mapseq-ds-no-jta"
class="org.postgresql.ds.PGPoolingDataSource">
<property name="user" value="${username}" />
<property name="password" value="${password}" />
<property name="serverName" value="${serverName}" />
<property name="databaseName" value="${databaseName}" />
<property name="portNumber" value="${port}" />
<property name="initialConnections" value="${maxIdle}" />
<property name="maxConnections" value="${maxActive}" />
</bean>
<service id="mapseqDataSource" ref="mapseq-ds-no-jta"
interface="javax.sql.DataSource">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/mapseqNoJTA" />
</service-properties>
</service>
</blueprint>
Here is the persistence.xml:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="mapseq" transaction-type="JTA">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<jta-data-source>aries:services/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/mapseqJTA)</jta-data-source>
<non-jta-data-source>aries:services/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/mapseqNoJTA)</non-jta-data-source>
...snip...
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<!-- <property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)" /> -->
<!-- <property name="openjpa.Log" value="DefaultLevel=TRACE,
Runtime=TRACE, Tool=TRACE, SQL=TRACE" /> -->
<property name="openjpa.jdbc.MappingDefaults"
value="ForeignKeyDeleteAction=restrict,
JoinForeignKeyDeleteAction=restrict" />
<property name="openjpa.Log" value="DefaultLevel=WARN,
Runtime=INFO, Tool=INFO, SQL=WARN" />
<property name="openjpa.jdbc.DBDictionary"
value="postgres(SearchStringEscape=\, SupportsXMLColumn=false)" />
<property name="openjpa.DataCache" value="false" />
<property name="openjpa.QueryCache" value="false" />
</properties>
</persistence-unit>
</persistence>
And finally, the blueprint.xml file to register JPA DAO services:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0"
xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.0.0"
default-activation="lazy">
<bean id="accessControlDAOImpl"
class="edu.unc.mapseq.dao.jpa.AccessControlDAOImpl" init-method="init">
<tx:transaction method="*" value="Required" />
<jpa:context property="entityManager" unitname="mapseq" />
</bean>
<service ref="accessControlDAOImpl"
interface="edu.unc.mapseq.dao.AccessControlDAO" />
...snip...
</blueprint>
Here is part of the stacktrace:
Caused by: javax.persistence.TransactionRequiredException: No
transaction currently active
at
org.apache.aries.jpa.container.context.transaction.impl.JTAPersistenceContextRegistry.getCurrentPersistenceContext(JTAPersistenceContextRegistry.java:103)
at
org.apache.aries.jpa.container.context.transaction.impl.JTAEntityManager.getPersistenceContext(JTAEntityManager.java:83)
at
org.apache.aries.jpa.container.context.transaction.impl.JTAEntityManager.persist(JTAEntityManager.java:278)
at edu.unc.mapseq.dao.jpa.BaseDAOImpl.save(BaseDAOImpl.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)[:1.6.0_24]
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.6.0_24]
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.6.0_24]
at java.lang.reflect.Method.invoke(Method.java:616)[:1.6.0_24]
at
org.apache.aries.proxy.impl.ProxyHandler$1.invoke(ProxyHandler.java:50)
at
org.apache.aries.proxy.impl.DefaultWrapper.invoke(DefaultWrapper.java:31)
at
org.apache.aries.proxy.impl.ProxyHandler.invoke(ProxyHandler.java:78)
at $Proxy112.save(Unknown Source)
at
edu.unc.mapseq.ws.impl.HTSFSampleServiceImpl.save(HTSFSampleServiceImpl.java:45)[234:mapseq-web-service-htsf-sample:0.0.1.SNAPSHOT]
The exception occurs whenever I try to do anything that is
transaction related (like persisting an entity). I have set the
logging in Karaf to DEBUG and I can't seem to find anything out of
the ordinary. Anyone seen this before??? Suggested solutions?
Suggestions for debugging further?
Regards,
Jason