You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2015/07/16 21:32:20 UTC

[1/3] tomee git commit: skip java.endorsed.dirs with java 9

Repository: tomee
Updated Branches:
  refs/heads/master adbfcd238 -> 3b2042712


skip java.endorsed.dirs with java 9


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/9bc46357
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/9bc46357
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/9bc46357

Branch: refs/heads/master
Commit: 9bc46357908383a7707373d4ad72660b787ceb68
Parents: adbfcd2
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Thu Jul 16 20:45:23 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Thu Jul 16 20:45:23 2015 +0200

----------------------------------------------------------------------
 .../src/main/java/org/apache/openejb/config/RemoteServer.java      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/9bc46357/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java b/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
index 21c81ea..7ca43ae 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
@@ -284,7 +284,7 @@ public class RemoteServer {
                     if (!addedArgs.containsKey("-Djava.io.tmpdir")) {
                         argsList.add("-Djava.io.tmpdir=" + temp.getAbsolutePath());
                     }
-                    if (!addedArgs.containsKey("-Djava.endorsed.dirs")) {
+                    if (!javaVersion.startsWith("1.9") && !addedArgs.containsKey("-Djava.endorsed.dirs")) {
                         argsList.add("-Djava.endorsed.dirs=" + endorsed.getAbsolutePath());
                     }
                     if (!addedArgs.containsKey("-Dcatalina.base")) {


[2/3] tomee git commit: allowing to load jdbc driver with creationg loader in tomcat-jdbc

Posted by rm...@apache.org.
allowing to load jdbc driver with creationg loader in tomcat-jdbc


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/71462349
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/71462349
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/71462349

Branch: refs/heads/master
Commit: 71462349bd0fb5957e9eed3fb927abdd1f8403dd
Parents: 9bc4635
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Thu Jul 16 21:21:53 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Thu Jul 16 21:21:53 2015 +0200

----------------------------------------------------------------------
 examples/datasource-versioning/pom.xml          | 12 ++++++++++
 .../tomee/jdbc/TomEEDataSourceCreator.java      | 25 +++++++++++++-------
 2 files changed, 29 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/71462349/examples/datasource-versioning/pom.xml
----------------------------------------------------------------------
diff --git a/examples/datasource-versioning/pom.xml b/examples/datasource-versioning/pom.xml
index 7ce7f32..fe6caf9 100644
--- a/examples/datasource-versioning/pom.xml
+++ b/examples/datasource-versioning/pom.xml
@@ -161,6 +161,18 @@
       <version>7.0.0-SNAPSHOT</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.tomcat</groupId>
+      <artifactId>tomcat-jdbc</artifactId>
+      <version>8.0.24</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tomee</groupId>
+      <artifactId>tomee-jdbc</artifactId>
+      <version>7.0.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <!--
   This section allows you to configure where to publish libraries for sharing.

http://git-wip-us.apache.org/repos/asf/tomee/blob/71462349/tomee/tomee-jdbc/src/main/java/org/apache/tomee/jdbc/TomEEDataSourceCreator.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-jdbc/src/main/java/org/apache/tomee/jdbc/TomEEDataSourceCreator.java b/tomee/tomee-jdbc/src/main/java/org/apache/tomee/jdbc/TomEEDataSourceCreator.java
index 39ecf26..6c6c363 100644
--- a/tomee/tomee-jdbc/src/main/java/org/apache/tomee/jdbc/TomEEDataSourceCreator.java
+++ b/tomee/tomee-jdbc/src/main/java/org/apache/tomee/jdbc/TomEEDataSourceCreator.java
@@ -38,10 +38,6 @@ import org.apache.tomcat.jdbc.pool.PoolConfiguration;
 import org.apache.tomcat.jdbc.pool.PoolProperties;
 import org.apache.tomcat.jdbc.pool.PooledConnection;
 
-import javax.management.ObjectName;
-import javax.sql.CommonDataSource;
-import javax.sql.DataSource;
-import javax.sql.XADataSource;
 import java.io.ObjectStreamException;
 import java.io.Serializable;
 import java.lang.reflect.InvocationHandler;
@@ -51,6 +47,10 @@ import java.sql.SQLException;
 import java.util.Map;
 import java.util.Properties;
 import java.util.concurrent.TimeUnit;
+import javax.management.ObjectName;
+import javax.sql.CommonDataSource;
+import javax.sql.DataSource;
+import javax.sql.XADataSource;
 
 public class TomEEDataSourceCreator extends PoolDataSourceCreator {
     private static final Logger LOGGER = Logger.getInstance(LogCategory.OPENEJB, TomEEDataSourceCreator.class);
@@ -245,7 +245,7 @@ public class TomEEDataSourceCreator extends PoolDataSourceCreator {
             if (pool != null) {
                 return pool;
             } else {
-                pool = new TomEEConnectionPool(poolProperties); // to force to init the driver with TCCL
+                pool = new TomEEConnectionPool(poolProperties, Thread.currentThread().getContextClassLoader()); // to force to init the driver with TCCL
                 return pool;
             }
         }
@@ -313,7 +313,7 @@ public class TomEEDataSourceCreator extends PoolDataSourceCreator {
         private final PoolConfiguration delegate;
 
         public ReadOnlyConnectionpool(final PoolConfiguration pool) {
-            delegate = pool;
+            this.delegate = pool;
         }
 
         @Override
@@ -330,8 +330,11 @@ public class TomEEDataSourceCreator extends PoolDataSourceCreator {
     }
 
     private static class TomEEConnectionPool extends ConnectionPool {
-        public TomEEConnectionPool(final PoolConfiguration poolProperties) throws SQLException {
+        private final ClassLoader creationLoader;
+
+        public TomEEConnectionPool(final PoolConfiguration poolProperties, final ClassLoader creationLoader) throws SQLException {
             super(poolProperties);
+            this.creationLoader = creationLoader;
         }
 
         @Override
@@ -345,7 +348,13 @@ public class TomEEDataSourceCreator extends PoolDataSourceCreator {
                 }
                 try {
                     Reflections.set(con, "driver", Class.forName(getPoolProperties().getDriverClassName(), true, cl).newInstance());
-                } catch (final java.lang.Exception cn) {
+                } catch (final ClassNotFoundException cnfe) {
+                    try { // custom resource classloader
+                        Reflections.set(con, "driver", Class.forName(getPoolProperties().getDriverClassName(), true, creationLoader).newInstance());
+                    } catch (final Exception e) {
+                        // will fail later, no worry
+                    }
+                } catch (final Exception cn) {
                     // will fail later, no worry
                 }
             }


[3/3] tomee git commit: fixing few tests - surely linked to tomcat upgrade

Posted by rm...@apache.org.
fixing few tests - surely linked to tomcat upgrade


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/3b204271
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/3b204271
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/3b204271

Branch: refs/heads/master
Commit: 3b2042712b22839ec81147bd605c1cf85a0b856e
Parents: 7146234
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Thu Jul 16 21:32:07 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Thu Jul 16 21:32:07 2015 +0200

----------------------------------------------------------------------
 .../tests/jaxws/EarClassLoaderTest.java         |   3 +-
 .../jaxws/LoadJodaFromTheWebAppResource.java    |   2 +-
 .../AlternateDriverJarEmbeddedDemo.java         | 124 +++++++++++++++++++
 .../org/superbiz/AlternateDriverJarTest.java    | 124 -------------------
 4 files changed, 127 insertions(+), 126 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/3b204271/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxws-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/EarClassLoaderTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxws-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/EarClassLoaderTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxws-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/EarClassLoaderTest.java
index 607d2c2..c875bff 100644
--- a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxws-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/EarClassLoaderTest.java
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxws-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/EarClassLoaderTest.java
@@ -34,6 +34,7 @@ import java.io.IOException;
 import java.net.URL;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 @RunWith(Arquillian.class)
 public class EarClassLoaderTest {
@@ -59,6 +60,6 @@ public class EarClassLoaderTest {
 
     @Test
     public void checkIfWasCorretlyLoaded() throws IOException { // when writing this test we ship joda-time 2.2
-        assertEquals("2.5", IO.slurp(new URL(url.toExternalForm() + (url.getPath().isEmpty() ? "/broken-web/" : "") + "joda")));
+        assertTrue(IO.slurp(new URL(url.toExternalForm() + (url.getPath().isEmpty() ? "/broken-web/" : "") + "joda")).endsWith("joda-time-2.5.jar"));
     }
 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/3b204271/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxws-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/LoadJodaFromTheWebAppResource.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxws-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/LoadJodaFromTheWebAppResource.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxws-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/LoadJodaFromTheWebAppResource.java
index bfac42c..3bc2338 100644
--- a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxws-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/LoadJodaFromTheWebAppResource.java
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxws-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/LoadJodaFromTheWebAppResource.java
@@ -28,7 +28,7 @@ public class LoadJodaFromTheWebAppResource {
     @GET
     public String worked() {
         LocalDateTime.now().toString(); // just trigger loading if not already done during scanning
-        return LocalDateTime.class.getPackage().getImplementationVersion();
+        return LocalDateTime.class.getProtectionDomain().getCodeSource().getLocation().toExternalForm();
     }
 
     public LocalDateTime triggerLoadingDuringScanning() {

http://git-wip-us.apache.org/repos/asf/tomee/blob/3b204271/examples/datasource-versioning/src/test/java/org/superbiz/AlternateDriverJarEmbeddedDemo.java
----------------------------------------------------------------------
diff --git a/examples/datasource-versioning/src/test/java/org/superbiz/AlternateDriverJarEmbeddedDemo.java b/examples/datasource-versioning/src/test/java/org/superbiz/AlternateDriverJarEmbeddedDemo.java
new file mode 100644
index 0000000..1088bd0
--- /dev/null
+++ b/examples/datasource-versioning/src/test/java/org/superbiz/AlternateDriverJarEmbeddedDemo.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz;
+
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.SingletonBean;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.testing.Configuration;
+import org.apache.openejb.testing.Module;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.LocalBean;
+import javax.ejb.Singleton;
+import javax.sql.DataSource;
+import java.io.File;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.util.Properties;
+
+@RunWith(ApplicationComposer.class)
+public class AlternateDriverJarEmbeddedDemo { // using AppComposer and Arquillian in the same build needs more config, not the purpose of this sample
+
+    private static final String USER = "SA";
+    private static final String PASSWORD = "";
+
+    @Configuration
+    public Properties config() {
+
+        final File drivers = new File(new File("target"), "drivers").getAbsoluteFile();
+
+        final Properties p = new Properties();
+        p.put("openejb.jdbc.datasource-creator", "dbcp-alternative");
+
+        File file = new File(drivers, "derby-10.10.1.1.jar");
+        Assert.assertTrue("Failed to find: " + file, file.exists());
+
+        p.put("JdbcOne", "new://Resource?type=DataSource&classpath="
+                + file.getAbsolutePath().replace("\\", "/"));
+        p.put("JdbcOne.JdbcDriver", "org.apache.derby.jdbc.EmbeddedDriver");
+        p.put("JdbcOne.JdbcUrl", "jdbc:derby:memory:JdbcOne;create=true");
+        p.put("JdbcOne.UserName", USER);
+        p.put("JdbcOne.Password", PASSWORD);
+        p.put("JdbcOne.JtaManaged", "false");
+
+        file = new File(drivers, "derby-10.9.1.0.jar");
+        Assert.assertTrue("Failed to find: " + file, file.exists());
+
+        p.put("JdbcTwo", "new://Resource?type=DataSource&classpath="
+                + file.getAbsolutePath().replace("\\", "/"));
+        p.put("JdbcTwo.JdbcDriver", "org.apache.derby.jdbc.EmbeddedDriver");
+        p.put("JdbcTwo.JdbcUrl", "jdbc:derby:memory:JdbcTwo;create=true");
+        p.put("JdbcTwo.UserName", USER);
+        p.put("JdbcTwo.Password", PASSWORD);
+        p.put("JdbcTwo.JtaManaged", "false");
+        return p;
+    }
+
+    @Module
+    public EjbJar app() throws Exception {
+        return new EjbJar()
+                .enterpriseBean(new SingletonBean(JdbcOne.class).localBean())
+                .enterpriseBean(new SingletonBean(JdbcTwo.class).localBean());
+    }
+
+    @EJB
+    private JdbcOne one;
+
+    @EJB
+    private JdbcTwo two;
+
+    @Test
+    public void testBoth() throws Exception {
+        Assert.assertEquals("Should be using 10.10.1.1 - (1458268)", "10.10.1.1 - (1458268)", one.getDriverVersion());
+        Assert.assertEquals("Should be using 10.9.1.0 - (1344872)", "10.9.1.0 - (1344872)", two.getDriverVersion());
+    }
+
+    @LocalBean
+    @Singleton
+    public static class JdbcOne {
+
+        @Resource(name = "JdbcOne")
+        private DataSource ds;
+
+        public String getDriverVersion() throws Exception {
+
+            final Connection con = ds.getConnection();
+            final DatabaseMetaData md = con.getMetaData();
+            return md.getDriverVersion();
+        }
+    }
+
+    @LocalBean
+    @Singleton
+    public static class JdbcTwo {
+
+        @Resource(name = "JdbcTwo")
+        private DataSource ds;
+
+        public String getDriverVersion() throws Exception {
+
+            final Connection con = ds.getConnection();
+            final DatabaseMetaData md = con.getMetaData();
+            return md.getDriverVersion();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/3b204271/examples/datasource-versioning/src/test/java/org/superbiz/AlternateDriverJarTest.java
----------------------------------------------------------------------
diff --git a/examples/datasource-versioning/src/test/java/org/superbiz/AlternateDriverJarTest.java b/examples/datasource-versioning/src/test/java/org/superbiz/AlternateDriverJarTest.java
deleted file mode 100644
index 32fa5d6..0000000
--- a/examples/datasource-versioning/src/test/java/org/superbiz/AlternateDriverJarTest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.superbiz;
-
-import org.apache.openejb.jee.EjbJar;
-import org.apache.openejb.jee.SingletonBean;
-import org.apache.openejb.junit.ApplicationComposer;
-import org.apache.openejb.testing.Configuration;
-import org.apache.openejb.testing.Module;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import javax.annotation.Resource;
-import javax.ejb.EJB;
-import javax.ejb.LocalBean;
-import javax.ejb.Singleton;
-import javax.sql.DataSource;
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.util.Properties;
-
-@RunWith(ApplicationComposer.class)
-public class AlternateDriverJarTest {
-
-    private static final String USER = "SA";
-    private static final String PASSWORD = "";
-
-    @Configuration
-    public Properties config() {
-
-        final File drivers = new File(new File("target"), "drivers").getAbsoluteFile();
-
-        final Properties p = new Properties();
-        p.put("openejb.jdbc.datasource-creator", "dbcp-alternative");
-
-        File file = new File(drivers, "derby-10.10.1.1.jar");
-        Assert.assertTrue("Failed to find: " + file, file.exists());
-
-        p.put("JdbcOne", "new://Resource?type=DataSource&classpath="
-                + file.getAbsolutePath().replace("\\", "/"));
-        p.put("JdbcOne.JdbcDriver", "org.apache.derby.jdbc.EmbeddedDriver");
-        p.put("JdbcOne.JdbcUrl", "jdbc:derby:memory:JdbcOne;create=true");
-        p.put("JdbcOne.UserName", USER);
-        p.put("JdbcOne.Password", PASSWORD);
-        p.put("JdbcOne.JtaManaged", "false");
-
-        file = new File(drivers, "derby-10.9.1.0.jar");
-        Assert.assertTrue("Failed to find: " + file, file.exists());
-
-        p.put("JdbcTwo", "new://Resource?type=DataSource&classpath="
-                + file.getAbsolutePath().replace("\\", "/"));
-        p.put("JdbcTwo.JdbcDriver", "org.apache.derby.jdbc.EmbeddedDriver");
-        p.put("JdbcTwo.JdbcUrl", "jdbc:derby:memory:JdbcTwo;create=true");
-        p.put("JdbcTwo.UserName", USER);
-        p.put("JdbcTwo.Password", PASSWORD);
-        p.put("JdbcTwo.JtaManaged", "false");
-        return p;
-    }
-
-    @Module
-    public EjbJar app() throws Exception {
-        return new EjbJar()
-                .enterpriseBean(new SingletonBean(JdbcOne.class).localBean())
-                .enterpriseBean(new SingletonBean(JdbcTwo.class).localBean());
-    }
-
-    @EJB
-    private JdbcOne one;
-
-    @EJB
-    private JdbcTwo two;
-
-    @Test
-    public void testBoth() throws Exception {
-        Assert.assertEquals("Should be using 10.10.1.1 - (1458268)", "10.10.1.1 - (1458268)", one.getDriverVersion());
-        Assert.assertEquals("Should be using 10.9.1.0 - (1344872)", "10.9.1.0 - (1344872)", two.getDriverVersion());
-    }
-
-    @LocalBean
-    @Singleton
-    public static class JdbcOne {
-
-        @Resource(name = "JdbcOne")
-        private DataSource ds;
-
-        public String getDriverVersion() throws Exception {
-
-            final Connection con = ds.getConnection();
-            final DatabaseMetaData md = con.getMetaData();
-            return md.getDriverVersion();
-        }
-    }
-
-    @LocalBean
-    @Singleton
-    public static class JdbcTwo {
-
-        @Resource(name = "JdbcTwo")
-        private DataSource ds;
-
-        public String getDriverVersion() throws Exception {
-
-            final Connection con = ds.getConnection();
-            final DatabaseMetaData md = con.getMetaData();
-            return md.getDriverVersion();
-        }
-    }
-}