Hello.

I'm going to check my XA configuration, but our tests seem to confirm
it works : our JMS and JDBC configurations are all based on factories
with pax-XXX-config, with pooling and XA features, and we have no
custom blueprints to set them...

In parallel I've found some interesting evidence in the bundle
pax-transx-tm-geronimo-0.5.3 code : I attach the Java class.

First, at line 141 the bundle try to instantiate a spring TM :

        try {
            try {
                transactionManager = new
SpringTransactionManagerCreator().create(transactionTimeout,
xidFactory, transactionLog);
                useSpring = true;
            } catch (NoClassDefFoundError e) {
                transactionManager = new
GeronimoTransactionManager(transactionTimeout, xidFactory,
transactionLog);
            }
        } catch (XAException e) {
            throw new RuntimeException("An exception occurred during
transaction recovery.", e);
        }

Then, at line159, depending on the result of the first block, the
PlatformTransactionManager is binded to the tm instance :

       if (useSpring) {
            clazzes.add(PLATFORM_TRANSACTION_MANAGER_CLASS);
        }

Does it mean that the classloader changes on :
- the first install of the features
- the stop/start
- the feature:refresh ???

I have no explicit dependency on Spring TM feature/bundle, and
nevertheless, the code that uses the PlatformTransactionManager
finally works.

I don't understand why the first time all is OK, and why the
stop/start and then refresh do changes on spring dependencies...

An idea ?

Thanks.

Regards.

Le mer. 12 avr. 2023 à 10:14, Maurice Betzel
<[email protected]> a écrit :
>
> Hi Ephemeris,
>
> First thing to notice, are you aiming to use XA transactions with JMS / JDBC? 
> As far as I know only the pax jdbc aries pool and transactionmanager support 
> this.
> The following setup is for Karaf 4.2.6 / ActiveMQ 5.15.9 / Camel 2.24.1 and 
> is proven in years of production.
>
> Basic Karaf runtime:
>
>                <startupFeatures>
>                         <feature>eventadmin</feature>
>                </startupFeatures>
> <bootFeatures>
>                         <feature>wrap</feature>
>                         <feature>shell</feature>
>                         <feature>feature</feature>
>                         <feature>jaas</feature>
>                         <feature>ssh</feature>
>                         <feature>management</feature>
>                         <feature>bundle</feature>
>                         <feature>config</feature>
>                         <feature>deployer</feature>
>                         <feature>diagnostic</feature>
>                         <feature>feature</feature>
>                         <feature>instance</feature>
>                         <feature>kar</feature>
>                         <feature>log</feature>
>                         <feature>package</feature>
>                         <feature>wrapper</feature>
>                         <feature>service</feature>
>                         <feature>system</feature>
>                  </bootFeatures>
>
> This is my ActiveMQ pooling and connection factory setup using activemq-camel 
> and JMS 1.1, I am just now migrating to pax transx and Artemis:
>
> <?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.3.0";
>            
> xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.5.0";>
>
>     <ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]"/>
>
>     <cm:property-placeholder 
> persistent-id="eu.abeel.platform.activemq.service" update-strategy="reload">
>         <cm:default-properties>
>             <cm:property name="broker-name" value="amq-broker"/>
>             <cm:property name="maximumRedeliveries" value="0"/>
>             <cm:property name="maximumRedeliveryDelay" value="-1"/>
>             <cm:property name="initialRedeliveryDelay" value="1000"/>
>             <cm:property name="redeliveryDelay" value="1000"/>
>             <cm:property name="useCollisionAvoidance" value="false"/>
>             <cm:property name="useExponentialBackOff" value="false"/>
>             <cm:property name="backOffMultiplier" value="5"/>
>         </cm:default-properties>
>     </cm:property-placeholder>
>
>     <bean id="activemqConnectionFactory" 
> class="org.apache.activemq.ActiveMQConnectionFactory">
>         <property name="brokerURL" 
> value="vm://${broker-name}?create=false&amp;waitForStart=10000"/>
>         <property name="userName" value="$[activemq.jms.user]"/>
>         <property name="password" value="$[activemq.jms.password]"/>
>     </bean>
>
>     <bean id="pooledConnectionFactory" 
> class="org.apache.activemq.pool.PooledConnectionFactory">
>         <property name="maxConnections" value="8"/>
>         <property name="connectionFactory" ref="activemqConnectionFactory"/>
>     </bean>
>
>     <!-- XA -->
>     <bean id="activeMQXAConnectionFactory" 
> class="org.apache.activemq.ActiveMQXAConnectionFactory">
>         <property name="brokerURL" 
> value="vm://${broker-name}?create=false&amp;waitForStart=10000"/>
>         <property name="userName" value="$[activemq.jms.user]"/>
>         <property name="password" value="$[activemq.jms.password]"/>
>         <property name="redeliveryPolicy">
>             <bean class="org.apache.activemq.RedeliveryPolicy">
>                 <property name="maximumRedeliveries" 
> value="${maximumRedeliveries}"/>
>                 <property name="maximumRedeliveryDelay" 
> value="${maximumRedeliveryDelay}"/>
>                 <property name="initialRedeliveryDelay" 
> value="${initialRedeliveryDelay}"/>
>                 <property name="useCollisionAvoidance" 
> value="${useCollisionAvoidance}"/>
>                 <property name="useExponentialBackOff" 
> value="${useExponentialBackOff}"/>
>                 <property name="backOffMultiplier" 
> value="${backOffMultiplier}"/>
>             </bean>
>         </property>
>     </bean>
>
>     <!-- connection factory wrapper to support auto-enlisting of XA resource 
> -->
>     <bean id="jcaPooledConnectionFactory" 
> class="org.apache.activemq.pool.JcaPooledConnectionFactory">
>         <property name="maxConnections" value="8"/>
>         <property name="connectionFactory" ref="activeMQXAConnectionFactory"/>
>         <property name="transactionManager" ref="osgiJtaTransactionManager"/>
>         <property name="name" value="activemq.${broker-name}"/>
>     </bean>
>
>     <!-- ActiveMQ XA Resource Manager -->
>     <bean id="resourceManager" 
> class="org.apache.activemq.pool.ActiveMQResourceManager" 
> init-method="recoverResource">
>         <property name="transactionManager" ref="osgiJtaTransactionManager"/>
>         <property name="connectionFactory" ref="jcaPooledConnectionFactory"/>
>         <property name="resourceName" value="activemq.${broker-name}"/>
>     </bean>
>
>     <reference id="osgiJtaTransactionManager" 
> interface="javax.transaction.TransactionManager" availability="mandatory"/>
>
>     <!-- Register the javax.jms.ConnectionFactory in the OSGi Service 
> Registry -->
>     <service ref="pooledConnectionFactory" 
> interface="javax.jms.ConnectionFactory">
>         <service-properties>
>             <entry key="name" value="platform-jms-cf"/>
>             <entry key="transacted" value="false"/>
>             <entry key="osgi.jndi.service.name" value="jms/platform-cf"/>
>         </service-properties>
>     </service>
>
>     <!-- Register the javax.jms.ConnectionFactory for the XA 
> PooledConnectionFactory in the OSGi Service Registry -->
>     <service ref="jcaPooledConnectionFactory" 
> interface="javax.jms.ConnectionFactory">
>         <service-properties>
>             <entry key="name" value="platform-jms-cf-xa"/>
>             <entry key="transacted" value="true"/>
>             <entry key="osgi.jndi.service.name" value="jms/platform-cf-xa"/>
>         </service-properties>
>     </service>
>
> </blueprint>
>
> This is the feature installing JMS:
>
> <feature name="platform-jms" description="ActiveMQ messaging" 
> version="${project.version}" start-level="50">
>         <details>MOM implementation provided by Apache ActiveMQ</details>
>         <feature>transaction</feature>
>         <feature>aries-blueprint</feature>
>         <feature>activemq-broker-noweb</feature>
>         <feature>activemq-camel</feature>
>         
> <bundle>mvn:eu.abeel.platform.activemq/service/${project.version}</bundle>
>         <configfile finalname="/etc/eu.abeel.platform.activemq.service.cfg">
>             
> mvn:eu.abeel.platform.activemq/service/${project.version}/cfg/activemq-service
>         </configfile>
>     </feature>
>
> This is my feature for MariaDB with pax-jdbc 1.5.0, Hibernate 5.2.18.Final 
> and Aries transactionmanager 1.3.3 with jpa 2.7.2, a JDBC connection pool 
> gets created only if a specified config file is deployed in the /etc folder:
>
>    <feature name="platform-facade-mariadb-persistence" 
> version="${project.version}">
>         <feature>aries-blueprint</feature>
>         <feature>transaction</feature>
>         <feature>jndi</feature>
>         <!-- Pax JDBC -->
>         <bundle>mvn:org.osgi/org.osgi.service.jdbc/1.0.0</bundle>
>         <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc/${pax.jdbc.version}</bundle>
>         
> <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-mariadb/${pax.jdbc.version}</bundle>
>         
> <bundle>mvn:org.apache.karaf.jdbc/org.apache.karaf.jdbc.core/${karaf.version}</bundle>
>         <bundle>mvn:org.apache.aries/org.apache.aries.util/1.1.3</bundle>
>         
> <bundle>mvn:org.apache.aries.transaction/org.apache.aries.transaction.manager/${aries.transaction.manager.version}</bundle>
>         
> <bundle>mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1</bundle>
>         
> <bundle>mvn:org.apache.geronimo.specs/geronimo-j2ee-connector_1.6_spec/1.0</bundle>
>         
> <bundle>mvn:org.apache.geronimo.specs/geronimo-validation_1.0_spec/1.1</bundle>
>         
> <bundle>mvn:org.apache.geronimo.components/geronimo-connector/3.1.4</bundle>
>         
> <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-pool-common/${pax.jdbc.version}</bundle>
>         
> <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-pool-aries/${pax.jdbc.version}</bundle>
>         
> <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jasypt/1.9.3_1</bundle>
>         
> <bundle>mvn:org.ops4j.pax.jdbc/pax-jdbc-config/${pax.jdbc.version}</bundle>
>         <!-- AriesJPA -->
>         <bundle>mvn:org.osgi/org.osgi.service.jpa/1.1.0</bundle>
>         
> <bundle>mvn:javax.interceptor/javax.interceptor-api/${javax.interceptor-api.version}</bundle>
>         
> <bundle>mvn:javax.persistence/javax.persistence-api/${javax.persistence-api.version}</bundle>
>         <capability>
>             
> osgi.service;effective:=active;objectClass=javax.persistence.spi.PersistenceProvider
>         </capability>
>         <bundle dependency="true" 
> start-level="30">mvn:org.apache.felix/org.apache.felix.coordinator/1.0.2</bundle>
>         <bundle 
> start-level="30">mvn:org.apache.aries.jpa.javax.persistence/javax.persistence_2.1/${aries.jpa.version}</bundle>
>         <bundle 
> start-level="30">mvn:org.apache.aries.jpa/org.apache.aries.jpa.api/${aries.jpa.version}</bundle>
>         <bundle 
> start-level="30">mvn:org.apache.aries.jpa/org.apache.aries.jpa.container/${aries.jpa.version}</bundle>
>         <bundle 
> start-level="30">mvn:org.apache.aries.jpa/org.apache.aries.jpa.support/${aries.jpa.version}</bundle>
>         <bundle 
> start-level="30">mvn:org.apache.aries.jpa/org.apache.aries.jpa.blueprint/${aries.jpa.version}</bundle>
>         <!-- Hibernate ORM -->
>         <bundle>mvn:org.jboss.logging/jboss-logging/3.4.1.Final</bundle>
>         
> <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.antlr/2.7.7_5</bundle>
>         <bundle>mvn:org.javassist/javassist/3.27.0-GA</bundle>
>         <bundle>mvn:net.bytebuddy/byte-buddy/1.10.17</bundle>
>         
> <bundle>mvn:org.jboss.spec.javax.transaction/jboss-transaction-api_1.2_spec/1.1.1.Final</bundle>
>         <bundle>mvn:org.jboss/jandex/2.1.3.Final</bundle>
>         <bundle>mvn:com.fasterxml/classmate/1.5.1</bundle>
>         
> <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j/2.1.3_1</bundle>
>         
> <bundle>mvn:org.hibernate.common/hibernate-commons-annotations/5.1.2.Final</bundle>
>         
> <bundle>mvn:org.hibernate/hibernate-core/${hibernate.orm.version}</bundle>
>         
> <bundle>mvn:org.hibernate/hibernate-osgi/${hibernate.orm.version}</bundle>
>         <capability>
>             
> osgi.service;objectClass=javax.persistence.spi.PersistenceProvider;effective:=active;javax.persistence.provider=org.hibernate.jpa.HibernatePersistenceProvider
>         </capability>
>     </feature>
>
>
> -----Oorspronkelijk bericht-----
> Van: Ephemeris Lappis <[email protected]>
> Verzonden: woensdag 12 april 2023 09:33
> Aan: [email protected]
> Onderwerp: Re: Karaf 4.4.3 / Unstable transaction features/services 
> installation
>
>  CAUTION: This email originated from outside of Gaston Schul. Do not click 
> links or open attachments unless you recognize the sender and know the 
> content is safe.
>
>
> Hello Maurice.
>
> I attach a description of our features stack, starting with low level 
> resource management, then framework and common features, and finally an 
> application feature example.
>
> The transaction feature is pulled by a common "foo-base", and used in some of 
> our application bundles that need both JMS and JDBC commits.
> The blueprint code is something like that :
>
>     <reference
>         id="barJMS"
>         interface="javax.jms.ConnectionFactory"
>         filter="(osgi.jndi.service.name=jms/bar)" />
>     <reference
>         id="barDS"
>         interface="javax.sql.DataSource"
>         filter="(osgi.jndi.service.name=jdbc/bar)" />
>
>     <reference
>         id="transactionManager"
>         interface="org.springframework.transaction.PlatformTransactionManager"
> />
>
>     <bean class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>         <argument ref="transactionManager" />
>     </bean>
>
> Any comment is welcome ;) !
>
> Thanks.
>
> Regards.
>
> Le mar. 11 avr. 2023 à 20:03, Maurice Betzel <[email protected]> a 
> écrit :
> >
> > Hi, I do remember having a similar issue years back and I feel your pain 
> > but I cannot remember what I did to cure the issue.
> > What do your custom features look like so I can compare them.
> >
> > -----Oorspronkelijk bericht-----
> > Van: Ephemeris Lappis <[email protected]>
> > Verzonden: dinsdag 11 april 2023 13:06
> > Aan: [email protected]
> > Onderwerp: Karaf 4.4.3 / Unstable transaction features/services
> > installation
> >
> >  CAUTION: This email originated from outside of Gaston Schul. Do not click 
> > links or open attachments unless you recognize the sender and know the 
> > content is safe.
> >
> >
> > Hello.
> >
> > I've already posted some similar questions some weeks ago about some issues 
> > we had with our features deployment, but I didn't get any explanation or 
> > solution. I will try again before creating a ticket for an issue that 
> > perhaps is not a bug...
> >
> > Our "low level" karaf features install commons services like :
> > - pax-jms (with ActiveMQ client and a configuration file)
> > - pax-jdbc (with PostgreSQL driver and a configuration file)
> > - transaction
> >
> > Then we install common Camel features and our applications features.
> >
> > If I'm not wrong, the feature transaction has the following dependencies :
> >     -> feature transaction-manager-geronimo
> >         -> feature pax-transx-tm-geronimo
> >             -> starts bundle
> > mvn:org.ops4j.pax.transx/pax-transx-tm-geronimo/0.5.3
> >
> > This bundle exposes the service "PlatformTransactionmanager" that we need 
> > to create transaction policies in some of our application's bundles.
> >
> > When we install all the features on a clean Karaf, all the services
> > are started, and the dependency on the PlatformTransactionManager
> > (PTM) is resolved as expected.
> >
> > in list of services we have :
> >
> > pax-transx-tm-geronimo (126) provides:
> > --------------------------------------
> > [org.osgi.service.cm.ManagedService]
> > [javax.transaction.TransactionManager,
> > javax.transaction.TransactionSynchronizationRegistry,
> > javax.transaction.UserTransaction,
> > org.apache.geronimo.transaction.manager.RecoverableTransactionManager,
> > org.springframework.transaction.PlatformTransactionManager]
> > [org.ops4j.pax.transx.tm.TransactionManager]
> >
> > But if we stop the Karaf, and start it again, the PTM doesn't start, and 
> > the dependent bundles fail. The services list doesn't include the PTM 
> > anymore :
> >
> > pax-transx-tm-geronimo (126) provides:
> >
> > --------------------------------------
> >
> >   [org.osgi.service.cm.ManagedService]
> >
> > [javax.transaction.TransactionManager,
> > javax.transaction.TransactionSynchronizationRegistry,
> > javax.transaction.UserTransaction,
> > org.apache.geronimo.transaction.manager.RecoverableTransactionManager]
> > [org.ops4j.pax.transx.tm.TransactionManager]
> >
> > I discovered that using "feature:refresh" does something that restarts the 
> > missing service. Then stopping and starting Karaf seems to have no impact.
> >
> > I don't understand why the Karaf feature installation works the first time, 
> > but doesn't let the system in a stable state, and what the refresh does to 
> > get it working again, since no change has been applied...
> >
> > Thanks in advance for any ideas.
> >
> > Regards.
> > Al onze verrichtingen geschieden op basis van de Algemene voorwaarden der 
> > Expediteurs van België, gepubliceerd in de bijlage tot het Belgisch 
> > Staatsblad dd. 24 juni 2005 onder nr. 0090237. De tekst van deze 
> > voorwaarden wordt op uw verzoek gratis toegezonden.
> > All our transactions are subject to the General Conditions of the Belgian 
> > Forwarders Association which have been published under nr. 0090237 in the 
> > "Bijlage tot het Belgisch Staatsblad" dated June 24th, 2005, and is 
> > available free of charge upon request.
> > Toutes nos opérations se font sur base des Conditions Générales des 
> > Expéditeurs de Belgique. Le texte en a été publié dans l' Annexe au 
> > Moniteur Belge du 24 juin 2005 sous le n° 0090237. Ce texte sera vous 
> > envoyé gratuitment sur demande.
> > Email confidentiality notice:
> > This email and any files transmitted with it are confidential and intended 
> > only for the use of the recipient. If you have received this email in error 
> > please notify its sender.
> >
> Al onze verrichtingen geschieden op basis van de Algemene voorwaarden der 
> Expediteurs van België, gepubliceerd in de bijlage tot het Belgisch 
> Staatsblad dd. 24 juni 2005 onder nr. 0090237. De tekst van deze voorwaarden 
> wordt op uw verzoek gratis toegezonden.
> All our transactions are subject to the General Conditions of the Belgian 
> Forwarders Association which have been published under nr. 0090237 in the 
> "Bijlage tot het Belgisch Staatsblad" dated June 24th, 2005, and is available 
> free of charge upon request.
> Toutes nos opérations se font sur base des Conditions Générales des 
> Expéditeurs de Belgique. Le texte en a été publié dans l' Annexe au Moniteur 
> Belge du 24 juin 2005 sous le n° 0090237. Ce texte sera vous envoyé 
> gratuitment sur demande.
> Email confidentiality notice:
> This email and any files transmitted with it are confidential and intended 
> only for the use of the recipient. If you have received this email in error 
> please notify its sender.
>

Attachment: TransactionManagerService.java
Description: Binary data

Reply via email to