I ran into similar problem with passing SSL enablement properties to the
connection properties.

See https://issues.apache.org/jira/browse/OPENJPA-2516 for more details.

I submitted and committed a patch such that I can get around the problem
with SSL connection. This may be enhanced to get what you want.

Albert.

On Wed, May 17, 2017 at 7:40 PM, Craig Russell <[email protected]> wrote:

> Hi Strub,
>
> > On May 16, 2017, at 10:58 PM, Mark Struberg <[email protected]>
> wrote:
> >
> > Hi Craig!
> >
> > Those are additional properties which are _not_ passed in to
> EntityManagerFactore.createEM(String, Map) ?
>
> What I'm trying to do is to pass extra properties to the underlying
> connection which is normally opaque to the user. The connection url, user,
> and password have official property names in the map. What I'm trying to do
> is to pass an additional property to the jdbc driver manager.
>
> I'm thinking that there must be a way to tell openjpa that a key should be
> stripped and the result passed to the jdbc driver manager as a property.
>
> For example, key: openjpa.ConnectionExtra.useSSL, value: false
>
> This should be passed to the jdbc driver manager as a property
> "useSSL":"false".
> >
> > From the stacktrace it looks like you run some unit test, right?
> > Do you do this via Maven or your IDE?
>
> I do this via Maven and there's another way to run the tests that is
> managed by explicit -Dopenjpa.ConnectionURL=jdbc:mysql://localhost:13021/test
> and that works fine. But I also want to know how to use e.g.
> -Dopenjpa.ConnectionExtra.useSSL=false
> >
> > The -D you set should imo work. We use the same within OpenJPA itself.
> > But it might happen that it doesn't get propagated to your java process?
>
> I just need to know the key prefix of the property or if there is some
> other way to pass connection properties.
> >
> > Can you probably check your System.properties in the debugger, just to
> see whether this properly gets propagated?
>
> The existing "known" properties work fine. I'm looking for an extra
> property that openjpa doesn't know anything about.
>
> Thanks,
>
> Craig
> >
> >
> > If you run it via Maven than you might probably tell the
> maven-surefire-plugin to set it.
> >
> > <plugin>
> >    <groupId>org.apache.maven.plugins</groupId>
> >    <artifactId>maven-surefire-plugin</artifactId>
> >    <version>${maven.surefire.version}</version>
> >    <configuration>
> >        <systemProperties>
> >          <property>
> >              <name>openjpa.ConnectionURL</name>
> >              <value>${connection.url}</value>
> >          </property>
> > ...
> >
> > LieGrue,
> > strub
> >
> >
> >> Am 17.05.2017 um 02:51 schrieb Craig Russell <[email protected]>:
> >>
> >> Hi,
> >>
> >> I've got an implementation of a plugin Broker that uses an underlying
> jdbc connection via the dbcp implementation.
> >>
> >> I need to pass a property to the DriverManager.getConnection(String
> url, Properties props) method.
> >>
> >> I've looked for how a special property can be configured and I'm stuck.
> I'm passing the URL via a variable on the command line.
> >> -Dopenjpa.ConnectionURL="jdbc:mysql://localhost:13021/test" Maybe
> there is a way to pass extra connection properties either via command line
> or via the broker?
> >>
> >> Any ideas?
> >>
> >> Thanks,
> >>
> >> Craig
> >>
> >> <openjpa-2.2.2-r422266:1468616 nonfatal general error>
> org.apache.openjpa.persistence.PersistenceException: There were errors
> initializing your configuration: <openjpa-2.2.2-r422266:1468616 fatal user
> error> org.apache.openjpa.util.UserException: A connection could not be
> obtained for driver class "com.mysql.jdbc.Driver" and URL
> "jdbc:mysql://localhost:13021/test".  You may have specified an invalid
> URL.
> >>      at org.apache.openjpa.jdbc.schema.DataSourceFactory.
> newConnectException(DataSourceFactory.java:255)
> >>      at org.apache.openjpa.jdbc.schema.DataSourceFactory.
> installDBDictionary(DataSourceFactory.java:241)
> >>      at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.
> getConnectionFactory(JDBCConfigurationImpl.java:733)
> >>      at sun.reflect.GeneratedMethodAccessor25.invoke(Unknown Source)
> >>      at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:43)
> >>      at java.lang.reflect.Method.invoke(Method.java:606)
> >>      at org.apache.openjpa.lib.conf.ConfigurationImpl.instantiateAll(
> ConfigurationImpl.java:306)
> >>      at org.apache.openjpa.conf.OpenJPAConfigurationImpl.
> instantiateAll(OpenJPAConfigurationImpl.java:1670)
> >>      at org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(
> AbstractBrokerFactory.java:652)
> >>      at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(
> AbstractBrokerFactory.java:203)
> >>      at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(
> DelegatingBrokerFactory.java:156)
> >>      at org.apache.openjpa.persistence.EntityManagerFactoryImpl.
> createEntityManager(EntityManagerFactoryImpl.java:227)
> >>      at org.apache.openjpa.persistence.EntityManagerFactoryImpl.
> createEntityManager(EntityManagerFactoryImpl.java:154)
> >>      at org.apache.openjpa.persistence.EntityManagerFactoryImpl.
> createEntityManager(EntityManagerFactoryImpl.java:60)
> >>      at com.mysql.clusterj.jpatest.SingleEMTestCase.setUp(
> SingleEMTestCase.java:42)
> >>      at com.mysql.clusterj.jpatest.SingleEMFTestCase.setUp(
> SingleEMFTestCase.java:55)
> >>      at com.mysql.clusterj.jpatest.SingleEMTestCase.setUp(
> SingleEMTestCase.java:35)
> >>      at junit.framework.TestCase.run(TestCase.java:52)
> >>      at com.mysql.clusterj.jpatest.PersistenceTestCase.run(
> PersistenceTestCase.java:104)
> >>      at junit.framework.TestSuite.run(TestSuite.java:125)
> >>      at junit.textui.TestRunner.run(TestRunner.java:46)
> >>      at testsuite.clusterj.AllTests.main(AllTests.java:150)
> >> Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create
> PoolableConnectionFactory (Communications link failure
> >>
> >> The last packet successfully received from the server was 206
> milliseconds ago.  The last packet sent successfully to the server was 199
> milliseconds ago.)
> >>      at org.apache.commons.dbcp.BasicDataSource.
> createPoolableConnectionFactory(BasicDataSource.java:1549)
> >>      at org.apache.commons.dbcp.BasicDataSource.createDataSource(
> BasicDataSource.java:1388)
> >>      at org.apache.commons.dbcp.BasicDataSource.getConnection(
> BasicDataSource.java:1044)
> >>      at org.apache.openjpa.jdbc.schema.DBCPDriverDataSource.
> getDBCPConnection(DBCPDriverDataSource.java:74)
> >>      at org.apache.openjpa.jdbc.schema.AutoDriverDataSource.
> getConnection(AutoDriverDataSource.java:42)
> >>      at org.apache.openjpa.jdbc.schema.SimpleDriverDataSource.
> getConnection(SimpleDriverDataSource.java:76)
> >>      at org.apache.openjpa.lib.jdbc.DelegatingDataSource.getConnection(
> DelegatingDataSource.java:118)
> >>      at org.apache.openjpa.lib.jdbc.DecoratingDataSource.getConnection(
> DecoratingDataSource.java:93)
> >>      at org.apache.openjpa.jdbc.schema.DataSourceFactory.
> installDBDictionary(DataSourceFactory.java:233)
> >>      ... 20 more
> >> Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
> Communications link failure
> >>
> >> The last packet successfully received from the server was 206
> milliseconds ago.  The last packet sent successfully to the server was 199
> milliseconds ago.
> >>      at sun.reflect.GeneratedConstructorAccessor46.newInstance(Unknown
> Source)
> >>      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
> DelegatingConstructorAccessorImpl.java:45)
> >>      at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
> >>      at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
> >>      at com.mysql.jdbc.SQLError.createCommunicationsException(
> SQLError.java:989)
> >>      at com.mysql.jdbc.ExportControlled.transformSocketToSSLSocket(
> ExportControlled.java:175)
> >>      at com.mysql.jdbc.MysqlIO.negotiateSSLConnection(
> MysqlIO.java:4901)
> >>      at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableA
> uthentication(MysqlIO.java:1659)
> >>      at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1226)
> >>      at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.
> java:2194)
> >>      at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(
> ConnectionImpl.java:2225)
> >>      at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.
> java:2024)
> >>      at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:779)
> >>      at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
> >>      at sun.reflect.GeneratedConstructorAccessor38.newInstance(Unknown
> Source)
> >>      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
> DelegatingConstructorAccessorImpl.java:45)
> >>      at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
> >>      at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
> >>      at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.
> java:389)
> >>      at com.mysql.jdbc.NonRegisteringDriver.connect(
> NonRegisteringDriver.java:330)
> >>      at org.apache.commons.dbcp.DriverConnectionFactory.
> createConnection(DriverConnectionFactory.java:38)
> >>      at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(
> PoolableConnectionFactory.java:582)
> >>      at org.apache.commons.dbcp.BasicDataSource.
> validateConnectionFactory(BasicDataSource.java:1556)
> >>      at org.apache.commons.dbcp.BasicDataSource.
> createPoolableConnectionFactory(BasicDataSource.java:1545)
> >>      ... 28 more
> >> Caused by: javax.net.ssl.SSLException: Server selected improper
> ciphersuite SSL_RSA_WITH_RC4_128_MD5
> >>      at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
> >>      at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1916)
> >>      at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:279)
> >>      at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:269)
> >>      at sun.security.ssl.ClientHandshaker.serverHello(
> ClientHandshaker.java:531)
> >>      at sun.security.ssl.ClientHandshaker.processMessage(
> ClientHandshaker.java:203)
> >>      at sun.security.ssl.Handshaker.processLoop(Handshaker.java:913)
> >>      at sun.security.ssl.Handshaker.process_record(Handshaker.java:849)
> >>      at sun.security.ssl.SSLSocketImpl.readRecord(
> SSLSocketImpl.java:1035)
> >>      at sun.security.ssl.SSLSocketImpl.performInitialHandshake(
> SSLSocketImpl.java:1344)
> >>      at sun.security.ssl.SSLSocketImpl.startHandshake(
> SSLSocketImpl.java:1371)
> >>      at sun.security.ssl.SSLSocketImpl.startHandshake(
> SSLSocketImpl.java:1355)
> >>      at com.mysql.jdbc.ExportControlled.transformSocketToSSLSocket(
> ExportControlled.java:160)
> >>      ... 46 more
> >>
> >>      at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(
> AbstractBrokerFactory.java:218)
> >>      at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(
> DelegatingBrokerFactory.java:156)
> >>      at org.apache.openjpa.persistence.EntityManagerFactoryImpl.
> createEntityManager(EntityManagerFactoryImpl.java:227)
> >>      at org.apache.openjpa.persistence.EntityManagerFactoryImpl.
> createEntityManager(EntityManagerFactoryImpl.java:154)
> >>      at org.apache.openjpa.persistence.EntityManagerFactoryImpl.
> createEntityManager(EntityManagerFactoryImpl.java:60)
> >>      at com.mysql.clusterj.jpatest.SingleEMTestCase.setUp(
> SingleEMTestCase.java:42)
> >>      at com.mysql.clusterj.jpatest.SingleEMFTestCase.setUp(
> SingleEMFTestCase.java:55)
> >>      at com.mysql.clusterj.jpatest.SingleEMTestCase.setUp(
> SingleEMTestCase.java:35)
> >>      at junit.framework.TestCase.run(TestCase.java:52)
> >>      at com.mysql.clusterj.jpatest.PersistenceTestCase.run(
> PersistenceTestCase.java:104)
> >>      at junit.framework.TestSuite.run(TestSuite.java:125)
> >>      at junit.textui.TestRunner.run(TestRunner.java:46)
> >>      at testsuite.clusterj.AllTests.main(AllTests.java:150)
> >> Craig L Russell
> >> [email protected]
> >>
> >
>
> Craig L Russell
> Secretary, Apache Software Foundation
> [email protected] http://db.apache.org/jdo
>
>


-- 
Albert Lee.

Reply via email to