[OPS4J JDBC] javax.persistence.TransactionRequiredException: no transaction is in progress on local TX

2017-08-23 Thread Maurice Betzel
Dear community, i think i have a issue wiring up Spring(Blueprint) / 
Hibernate / JPA / OPS4J JDBC / Camel, using:


   1. Karaf 4.0.8 (Felix)
   2. Servicemix Spring 3.2.17
   3. Aries JPA 2.3.0
   4. Hibernate 4.3.6
   5. OPS4J Pax JDBC 0.9.0
   6. Camel 2.16.5
   
The problem occurs when running a camel route using transaction demarcation 
on it giving a javax.persistence.TransactionRequiredException: no 
transaction is in progress.


Persistence unit



org.hibernate.jpa.HibernatePersistenceProvider

osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=pydio2xbound-mssql)
de.hmm.medit.esb.xbound.pydio2xbound.some.classes
true










DAO context:



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/v2.0.0;
   xmlns:tx="http://aries.apache.org/xmlns/transactions/v2.0.0;
   xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 
https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
   http://aries.apache.org/xmlns/jpa/v2.0.0 
http://aries.apache.org/schemas/jpa/jpa_200.xsd;>










DAO service:


public class Dao implements DaoService {

@PersistenceContext(unitName = UNIT_NAME_MSSQL)
EntityManager entityManagerMSSQL;

@Transactional(Transactional.TxType.REQUIRED)
@Override
public void persist(AuftragsDatei auftragsDatei) {
entityManagerMSSQL.persist(auftragsDatei);
...etc...


OPS4J Persistence config file:


dataSourceName=pydio2xbound-mssql
databaseName=pydio2xbound
osgi.jdbc.driver.name=mssql-pool
url=jdbc:sqlserver://127.0.0.1:1433
user=root
password=
jdbc.pool.maxTotal=4
#jdbc.factory.defaultAutoCommit=false


Karaf list datasource:


^karaf@root>service:list DataSource
[javax.sql.DataSource]
--
 databaseName = pydio2xbound
 dataSourceName = pydio2xbound-mssql
 felix.fileinstall.filename = 
file:/E:/Development/karaf/medit-esb-1.3.1-SNAPSHOT/etc/org.ops4j.datasource-xbound.pydio2xbound.mssql.persistence.cfg
 jdbc.pool.maxTotal = 4
 osgi.jdbc.driver.name = mssql-pool
 osgi.jndi.service.name = pydio2xbound-mssql
 password = *
 service.bundleid = 252
 service.factoryPid = org.ops4j.datasource
 service.id = 271
 service.pid = org.ops4j.datasource.0025c61e-c8d5-451f-91e5-f1258d806ce5
 service.scope = singleton
 url = jdbc:sqlserver://127.0.0.1:1433
 user = root
Provided by :
 OPS4J Pax JDBC Config (252)
Used by:
 Apache Aries JPA container (236)


Spring / Camel context:















http://camel.apache.org/schema/blueprint;>






GET



cxfrs:bean:dynamicClient?address=${in.header.CamelHttpUri}



${body}


 ${body.auftragsDatei}


<...some more routing...>




Complete stacktrace:


2017-08-23 16:43:00,070 | DEBUG | 4 - timer://rest | 
> aggregation  | 48 - org.apache.camel.camel-core - 
> 2.16.5 | Processing file : 
> https://transfer.zhp-online.de/pydio/api/v2/io/my-files/excel/Auftrags%2520daten_20170504-8.csv
> 2017-08-23 16:43:00,070 | DEBUG | 4 - timer://rest | 
> DataSourceTransactionManager | 157 - 
> org.apache.servicemix.bundles.spring-tx - 3.2.17.RELEASE_1 | Creating new 
> transaction with name [null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
> 2017-08-23 16:43:00,070 | DEBUG | 4 - timer://rest | 
> DataSourceTransactionManager | 157 - 
> org.apache.servicemix.bundles.spring-tx - 3.2.17.RELEASE_1 | Acquired 
> Connection [1735559577, 
> URL=jdbc:sqlserver://127.0.0.1:1433;authenticationScheme=nativeAuthentication;xopenStates=false;sendTimeAsDatetime=true;trustServerCertificate=false;sendStringParametersAsUnicode=true;selectMethod=direct;responseBuffering=adaptive;packetSize=8000;multiSubnetFailover=false;loginTimeout=15;lockTimeout=-1;lastUpdateCount=true;encrypt=false;disableStatementPooling=true;databaseName=pydio2xbound;applicationName=Microsoft
>  
> JDBC Driver for SQL Server;applicationIntent=readwrite;, UserName=root, 
> Microsoft JDBC Driver 4.1 for SQL Server] for JDBC transaction
> 2017-08-23 16:43:00,070 | DEBUG | 4 - timer://rest | 
> DataSourceTransactionManager | 157 - 
> org.apache.servicemix.bundles.spring-tx - 3.2.17.RELEASE_1 | Switching JDBC 
> Connection [1735559577, 
> URL=jdbc:sqlserver://127.0.0.1:1433;authenticationScheme=nativeAuthentication;xopenStates=false;sendTimeAsDatetime=true;trustServerCertificate=false;sendStringParametersAsUnicode=true;selectMethod=direct;responseBuffering=adaptive;packetSize=8000;multiSubnetFailover=false;loginTimeout=15;lockTimeout=-1;lastUpdateCount=true;encrypt=false;disableStatementPooling=true;databaseName=pydio2xbound;applicationName=Microsoft
>  
> JDBC Driver for SQL Server;applicationIntent=readwrite;, UserName=root, 
> Microsoft JDBC Driver 4.1 for SQL Server] to manual commit
> 2017-08-23 

TransxXaPooledDataSourceFactory multiple Datasources

2017-08-23 Thread Kleber Ayala
Hi there,

I'm using your new* pax-jdbc-pool-transx* bundle on Karaf, 
works fine, but if you have multiple datasources there is an error "*Attempt 
to register second resource with name XADataSourceMCF*"  because  the 
DatasourceBulder don't register a name for each datasource.

 DataSource mds = ManagedDataSourceBuilder.builder();


If I change your  code including a name, works perfectly:


String name=props.getProperty("dataSourceName");

DataSource mds = ManagedDataSourceBuilder.builder().name(name)







2017-08-23T09:06:57,458 | ERROR | features-1-thread-1 | 
TransxXaPooledDataSourceFactory  | 101 - org.ops4j.pax.jdbc.pool.transx - 
1.2.0.SNAPSHOT | Error creating pooled datasourceAttempt to register second 
resource with name XADataSourceMCF
java.lang.IllegalStateException: Attempt to register second resource with 
name XADataSourceMCF
at 
com.atomikos.icatch.config.Configuration.addResource(Configuration.java:245) 
~[?:?]
at 
org.ops4j.pax.transx.tm.impl.atomikos.TransactionManagerWrapper.registerResource(TransactionManagerWrapper.java:62)
 
~[?:?]
at 
org.ops4j.pax.transx.connector.impl.GenericConnectionManager.(GenericConnectionManager.java:140)
 
~[?:?]
at 
org.ops4j.pax.transx.connector.ConnectionManagerBuilder.build(ConnectionManagerBuilder.java:161)
 
~[?:?]
at 
org.ops4j.pax.transx.jdbc.ManagedDataSourceBuilder.build(ManagedDataSourceBuilder.java:178)
 
~[?:?]
at 
org.ops4j.pax.jdbc.pool.transx.impl.TransxXaPooledDataSourceFactory.create(TransxXaPooledDataSourceFactory.java:59)
 
~[?:?]
at 
org.ops4j.pax.jdbc.config.impl.PoolingWrapper.createDataSource(PoolingWrapper.java:42)
 
~[?:?]
at 
org.ops4j.pax.jdbc.config.impl.DataSourceRegistration.createDs(DataSourceRegistration.java:134)
 
~[?:?]

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Pax exam. Proposal to allow catch Exception in checkstyle rules

2017-08-23 Thread Christian Schneider

Currently the checkstyle rules forbid to catch Exception.

I propose to change this as catching Exception is sometimes very useful 
when for example a called method throws Exception or we simply want to 
map to RuntimeException to avoid having throws Exception in every caller.


Christian

--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com

--
--
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups "OPS4J" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.