I download the Aries “ariestrader” example.
I intend to use container-managed “JPA” with blueprint services.
Run the example with the configuration:
Geronimo v3.0
JDK for source compilation – JDK 1.6.0_33
So I make the following changes to test the concept:
1. Change “derby” data source to “oracle” datasource
<bean id="dataSource" class="oracle.jdbc.pool.OracleDataSource">
<property name="URL" value="jdbc:oracle:thin:@192.168.28.13:1522:o10utf8"/>
<property name="user" value="jpos_sinomax2"/>
<property name="password" value="jpos_sinomax2"/>
</bean>
<service id="OracleDataSource" ref="dataSource"
interface="javax.sql.DataSource">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/OracleDataSource"/>
</service-properties>
</service>
Note: it is impossible to start up “JPA by using the following jta-data-souce
declaration,
<
jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/
OracleDataSource)</jta-data-source>
but I can success to start up JPA module with the following “jta-data-source”
setting
<jta-data-source>osgi:service/jdbc/OracleDataSource</jta-data-source>
2. For the module “ariestrader-entities”, change persistence.xml
definition to only keep “tradeServicesBeanJPA-CM” persistence unit only
(transaction-type=”JTA”)
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
<persistence-unit transaction-type="JTA" name="ariestrader-cm1">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<jta-data-source>osgi:service/jdbc/OracleDataSource</jta-data-source>
<class>org.apache.aries.samples.ariestrader.entities.AccountDataBeanImpl</class>
<class>org.apache.aries.samples.ariestrader.entities.AccountProfileDataBeanImpl</class>
<class>org.apache.aries.samples.ariestrader.entities.HoldingDataBeanImpl</class>
<class>org.apache.aries.samples.ariestrader.entities.OrderDataBeanImpl</class>
<class>org.apache.aries.samples.ariestrader.entities.QuoteDataBeanImpl</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="openjpa.BrokerImpl" value="non-finalizing" />
<property name="openjpa.Sequence" value="table(Table=OPENJPASEQ,
Increment=100)"/>
<property name="openjpa.jdbc.UpdateManager"
value="org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager"/>
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema"/>
<property name="openjpa.jdbc.DBDictionary" value="oracle"/>
<property name="openjpa.InitializeEagerly" value="true"/>
<property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO, SQL=TRACE"/>
</properties>
</persistence-unit>
3. remove “default-activition=”lazy” attribute inside <ariestrader
path>\modules\ariestrader-persist-jpa-cm\src\main\resources\OSGI-INF\blueprint\blueprint.xml
as follow:
<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.0.0"
xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0">
<bean id="tradeServicesBeanJPA-CM"
class="org.apache.aries.samples.ariestrader.persist.jpa.cm.TradeJpaCm"
init-method="init">
<jpa:context property="entityManager" unitname="ariestrader-cm" />
<tx:transaction method="*" value="Required"/>
</bean>
<service id="tradeServicesJPA-CM" ref="tradeServicesBeanJPA-CM"
interface="org.apache.aries.samples.ariestrader.api.TradeServices">
<service-properties>
<entry key="mode" value="JPA_CM"/>
</service-properties>
</service>
</blueprint>
Found the following error after deployment:
2012-11-20 11:29:15,154 WARN [TomcatModuleBuilder] Web application . does not
contain a WEB-INF/geronimo-web.xml deployment plan. This may or may not be a
problem, depending on whether you have things like resource references that
need to be resolved. You can also give the deployer a separate deployment plan
file on the command line.
1390 ariestrader-cm TRACE [DefaultThreadPool 97] openjpa.jdbc.SQL - <t
698548234, conn 114985483> executing prepstmnt 1971330543 SELECT SEQUENCE_OWNER
AS SEQUENCE_SCHEMA, SEQUENCE_NAME FROM ALL_SEQUENCES
1420 ariestrader-cm TRACE [DefaultThreadPool 97] openjpa.jdbc.SQL - <t
698548234, conn 114985483> [29 ms] spent
12583 ariestrader-cm TRACE [DefaultThreadPool 97] openjpa.jdbc.SQL - <t
698548234, conn 114985483> executing prepstmnt 61624102 SELECT SEQUENCE_OWNER
AS SEQUENCE_SCHEMA, SEQUENCE_NAME FROM ALL_SEQUENCES
12583 ariestrader-cm TRACE [DefaultThreadPool 97] openjpa.jdbc.SQL - <t
698548234, conn 114985483> [0 ms] spent
18019 ariestrader-cm TRACE [DefaultThreadPool 97] openjpa.jdbc.SQL - <t
698548234, conn 114985483> executing prepstmnt 1744381087 SELECT SEQUENCE_OWNER
AS SEQUENCE_SCHEMA, SEQUENCE_NAME FROM ALL_SEQUENCES
18044 ariestrader-cm TRACE [DefaultThreadPool 97] openjpa.jdbc.SQL - <t
698548234, conn 114985483> [25 ms] spent
24061 ariestrader-cm TRACE [DefaultThreadPool 97] openjpa.jdbc.SQL - <t
698548234, conn 114985483> executing prepstmnt 1787648660 SELECT SEQUENCE_OWNER
AS SEQUENCE_SCHEMA, SEQUENCE_NAME FROM ALL_SEQUENCES
24075 ariestrader-cm TRACE [DefaultThreadPool 97] openjpa.jdbc.SQL - <t
698548234, conn 114985483> [14 ms] spent
30173 ariestrader-cm TRACE [DefaultThreadPool 97] openjpa.jdbc.SQL - <t
698548234, conn 114985483> executing prepstmnt 711799828 SELECT SEQUENCE_OWNER
AS SEQUENCE_SCHEMA, SEQUENCE_NAME FROM ALL_SEQUENCES
30185 ariestrader-cm TRACE [DefaultThreadPool 97] openjpa.jdbc.SQL - <t
698548234, conn 114985483> [12 ms] spent
33465 ariestrader-cm TRACE [DefaultThreadPool 97] openjpa.jdbc.SQL - <t
698548234, conn 114985483> executing prepstmnt 1333601763 SELECT SEQUENCE_OWNER
AS SEQUENCE_SCHEMA, SEQUENCE_NAME FROM ALL_SEQUENCES
33478 ariestrader-cm TRACE [DefaultThreadPool 97] openjpa.jdbc.SQL - <t
698548234, conn 114985483> [12 ms] spent
2012-11-20 12:52:15,156 ERROR [BlueprintContainerImpl] Unable to start
blueprint container for bundle
org.apache.aries.samples.ariestrader.persist.jpa.cm
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to
instantiate components
at
org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:644)
at
org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:331)
at
org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:227)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.VerifyError: (class:
org/apache/aries/samples/ariestrader/persist/jpa/cm/$TradeJpaCm639751507,
method: <init> signature: (Ljava/lang/reflect/InvocationHandler;)V) Call to
wrong initialization method
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.getConstructor(Class.java:1657)
at
org.apache.aries.proxy.impl.gen.ProxySubclassGenerator.newProxySubclassInstance(ProxySubclassGenerator.java:159)
at
org.apache.aries.proxy.impl.AsmProxyManager.createNewProxy(AsmProxyManager.java:81)
at
org.apache.aries.proxy.impl.AbstractProxyManager.createProxy(AbstractProxyManager.java:50)
at
org.apache.aries.blueprint.container.BeanRecipe.addInterceptors(BeanRecipe.java:688)
at
org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:728)
at
org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:64)
at
org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:219)
at
org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:147)
at
org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:640)
... 10 more
After removing “tx-transaction” on the blueprint definition at
ariestrader\modules\ariestrader-persist-jpa-cm\src\main\resources\OSGI-INF\blueprint\blueprint.xml
<bean id="tradeServicesBeanJPA-CM"
class="org.apache.aries.samples.ariestrader.persist.jpa.cm.TradeJpaCm"
init-method="init">
<jpa:context property="entityManager" unitname="ariestrader-cm" />
<!-- tx:transaction method="*" value="Required"/ -->
</bean>
then it is successful to start up the blueprint service again.
Anyway, it is impossible to start up any blueprint service with
“tx-transaction” annotation.
Herewith the amended source attachment and the compilation steps, any help for
solving the problem is welcome
Unzip the problem2.zip into a temp folder
And fire “mvn clean install” to compile the sources
and then deploy the following osgi bundles through Geronimo web console step by
step:
1. ariestrader-derby-ds -
ariestrader\modules\ariestrader-derby-ds\target\org.apache.aries.samples.ariestrader.derby.ds-1.0.0.ja
2. ariestrader-util -
ariestrader\modules\ariestrader-util\target\org.apache.aries.samples.ariestrader.util-1.0.0.jar
3. ariestrader-api -
ariestrader\modules\ariestrader-api\target\org.apache.aries.samples.ariestrader.api-1.0.0.jar
4. ariestrader-entities -
ariestrader\modules\ariestrader-entities\target\org.apache.aries.samples.ariestrader.entities-1.0.0.jar
5. ariestrader-persist-jpa-cm -
ariestrader\modules\ariestrader-persist-jpa-cm\target\org.apache.aries.samples.ariestrader.persist.jpa.cm-1.0.0.ja
The source can be downloaded at the following link:
http://apache-geronimo.328035.n3.nabble.com/Fail-to-startup-Blueprint-service-with-quot-tx-transaction-quot-annotation-td3986039.html