You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jl...@apache.org on 2020/11/05 11:26:07 UTC
[tomee-tck] branch jakartaee9-tck updated: Push better javatest
classpath import webdeployer classes because the default jar in maven is
not jakartized
This is an automated email from the ASF dual-hosted git repository.
jlmonteiro pushed a commit to branch jakartaee9-tck
in repository https://gitbox.apache.org/repos/asf/tomee-tck.git
The following commit(s) were added to refs/heads/jakartaee9-tck by this push:
new 856d497 Push better javatest classpath import webdeployer classes because the default jar in maven is not jakartized
856d497 is described below
commit 856d497c8ed2555415bde6e5e64e6f0d34f68d12
Author: Jean-Louis Monteiro <je...@gmail.com>
AuthorDate: Thu Nov 5 11:55:36 2020 +0100
Push better javatest classpath
import webdeployer classes because the default jar in maven is not jakartized
---
pom.xml | 92 +++++++-
.../java/catalina/deployer/WebappDeployer.java | 244 +++++++++++++++++++++
.../catalina/facade/ExceptionManagerFacade.java | 25 +++
.../facade/ExceptionManagerFacadeBean.java | 33 +++
.../openejb/tck/commands/CommandSupport.groovy | 3 +-
5 files changed, 383 insertions(+), 14 deletions(-)
diff --git a/pom.xml b/pom.xml
index 5d30eff..1620169 100644
--- a/pom.xml
+++ b/pom.xml
@@ -91,12 +91,22 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.maven-dependency-plugin>2.9</version.maven-dependency-plugin>
- <version.activemq>5.15.12</version.activemq>
+ <version.activemq>5.16.0</version.activemq>
<version.gmaven-plugin>1.5</version.gmaven-plugin>
</properties>
<dependencies>
+ <!-- This is just so we can compile the WebappDeployer in this project
+ This jar is not required in tomee because we pull the transformed version and therefor
+ the api is already converted - but we can't reference it in Maven
+ -->
+ <dependency>
+ <groupId>jakarta.ejb</groupId>
+ <artifactId>jakarta.ejb-api</artifactId>
+ <version>4.0.0-RC2</version>
+ </dependency>
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_1.1_spec</artifactId>
@@ -243,6 +253,12 @@
</dependency>
<dependency>
<groupId>${openejb.groupId}</groupId>
+ <artifactId>tomee-catalina</artifactId>
+ <type>jar</type>
+ <version>${tomee.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${openejb.groupId}</groupId>
<artifactId>tomee-security</artifactId>
<type>jar</type>
<version>${tomee.version}</version>
@@ -279,12 +295,6 @@
</dependency>
<dependency>
- <groupId>${openejb.groupId}</groupId>
- <artifactId>webdeployer</artifactId>
- <version>${openejb.version}</version>
- </dependency>
-
- <dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-websocket</artifactId>
<version>${tomcat.version}</version>
@@ -805,7 +815,7 @@
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<excludeTransitive>true</excludeTransitive>
- <includeArtifactIds>hawtbuf,geronimo-jms_1.1_spec,activemq-client,tsharness,tssv,cts,whitebox,dbprocedures,geronimo-mail,derby,derbynet,derbyclient,webdeployer</includeArtifactIds>
+ <includeArtifactIds>hawtbuf,geronimo-jms_1.1_spec,activemq-client,tsharness,tssv,cts,whitebox,dbprocedures,geronimo-mail,derby,derbynet,derbyclient</includeArtifactIds>
</configuration>
</execution>
@@ -821,7 +831,7 @@
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<excludeTransitive>true</excludeTransitive>
- <includeArtifactIds>activemq-client,tsharness,tssv,cts,whitebox,dbprocedures,geronimo-mail,openejb-derbynet,derby,derbynet,derbyclient,webdeployer</includeArtifactIds>
+ <includeArtifactIds>tsharness,tssv,cts,whitebox,dbprocedures,geronimo-mail,openejb-derbynet,derby,derbynet,derbyclient</includeArtifactIds>
</configuration>
</execution>
</executions>
@@ -846,6 +856,63 @@
<target>
<copy todir="${project.build.directory}/lib">
<fileset dir="${openejb.home}/lib">
+
+ <!-- we essentially take everything from openejb-lite dependency tree - probably too much but fine to start -->
+
+ <include name="javaee-api*.jar"/>
+
+ <include name="openejb-core*.jar"/>
+ <include name="mbean-annotation-api*.jar"/>
+ <include name="openejb-jpa-integration*.jar"/>
+ <include name="commons-lang3*.jar"/>
+ <include name="openejb-api*.jar"/>
+ <include name="openejb-loader*.jar"/>
+ <include name="openejb-javaagent*.jar"/>
+ <include name="openejb-jee*.jar"/>
+ <include name="jaxb-runtime*.jar"/>
+ <include name="jakarta.xml.bind-api*.jar"/>
+ <include name="jakarta.activation*.jar"/>
+ <include name="txw2*.jar"/>
+ <include name="istack-commons*.jar"/>
+ <include name="stax-ex*.jar"/>
+ <include name="FastInfoset*.jar"/>
+ <include name="openejb-jee-accessors*.jar"/>
+ <include name="sxc-jaxb*.jar"/>
+ <include name="sxc-runtime*.jar"/>
+ <include name="commons-cli*.jar"/>
+ <include name="commons-collections*.jar"/>
+ <include name="activemq-jdbc*.jar"/>
+ <include name="geronimo-connector*.jar"/>
+ <include name="geronimo-j2ee*.jar"/>
+ <include name="geronimo-transaction*.jar"/>
+ <include name="howl*.jar"/>
+ <include name="jackson-databind*.jar"/>
+ <include name="jackson-annotations*.jar"/>
+ <include name="jackson-core*.jar"/>
+ <include name="geronimo-javamail*.jar"/>
+ <include name="xbean-asm*.jar"/>
+ <include name="xbean-finder*.jar"/>
+ <include name="xbean-reflect*.jar"/>
+ <include name="xbean-naming*.jar"/>
+ <include name="xbean-bundleutils*.jar"/>
+ <include name="hsqldb*.jar"/>
+ <include name="commons-dbcp2*.jar"/>
+ <include name="commons-pool2*.jar"/>
+ <include name="swizzle*.jar"/>
+ <include name="commons-logging*.jar"/>
+ <include name="quartz-openejb*.jar"/>
+ <include name="slf4j-api*.jar"/>
+ <include name="openwebbeans-impl*.jar"/>
+ <include name="openwebbeans-spi*.jar"/>
+ <include name="openwebbeans-ejb*.jar"/>
+ <include name="openwebbeans-ee*.jar"/>
+ <include name="openwebbeans-ee-common*.jar"/>
+ <include name="openwebbeans-web*.jar"/>
+ <include name="openwebbeans-el22*.jar"/>
+ <include name="openjpa*.jar"/>
+ <include name="serp*.jar"/>
+ <include name="bval-jsr*.jar"/>
+
<include name="tomcat-websocket*.jar"/>
<include name="tomcat-util*.jar"/>
<include name="tomcat-juli*.jar"/>
@@ -855,10 +922,11 @@
<include name="websocket-api*.jar"/>
<include name="jsp-api*.jar"/>
<include name="el-api*.jar"/>
- <include name="javaee-api*.jar"/>
+ <include name="servlet-api*.jar"/>
<include name="tomee-security*.jar"/>
- <include name="openejb-core*.jar"/>
- <include name="openejb-derbynet*.jar"/>
+
+ <include name="geronimo-mail-*.jar"/>
+
<exclude name="openejb-core-eclipselink*.jar" />
</fileset>
</copy>
diff --git a/src/main/java/catalina/deployer/WebappDeployer.java b/src/main/java/catalina/deployer/WebappDeployer.java
new file mode 100644
index 0000000..307e875
--- /dev/null
+++ b/src/main/java/catalina/deployer/WebappDeployer.java
@@ -0,0 +1,244 @@
+/*
+ * 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 catalina.deployer;
+
+import org.apache.catalina.Container;
+import org.apache.catalina.Engine;
+import org.apache.catalina.Service;
+import org.apache.catalina.core.StandardHost;
+import org.apache.catalina.core.StandardServer;
+import org.apache.catalina.util.ContextName;
+import org.apache.openejb.NoSuchApplicationException;
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.UndeployException;
+import org.apache.openejb.assembler.Deployer;
+import org.apache.openejb.assembler.classic.AppInfo;
+import org.apache.openejb.assembler.classic.Assembler;
+import org.apache.openejb.assembler.classic.DeploymentExceptionManager;
+import org.apache.openejb.assembler.classic.WebAppBuilder;
+import org.apache.openejb.loader.IO;
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.tomcat.util.modeler.Registry;
+import org.apache.tomee.catalina.TomEERuntimeException;
+import org.apache.tomee.catalina.TomcatWebAppBuilder;
+import org.apache.tomee.loader.TomcatHelper;
+
+import jakarta.ejb.Lock;
+import jakarta.ejb.LockType;
+import jakarta.ejb.Remote;
+import jakarta.ejb.Singleton;
+import jakarta.ejb.TransactionManagement;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import java.io.File;
+import java.util.Collection;
+import java.util.Properties;
+
+import static jakarta.ejb.TransactionManagementType.BEAN;
+
+@Lock(LockType.READ)
+@Singleton(name = "openejb/WebappDeployer")
+@Remote(Deployer.class)
+@TransactionManagement(BEAN)
+public class WebappDeployer implements Deployer {
+
+ private static final String WEBAPPS = "webapps";
+ private static final String OPENEJB_HOME = "openejb.home";
+ private final TomcatWebAppBuilder webappBuilder;
+ private final Assembler assembler;
+ private final MBeanServer mBeanServer;
+
+ public WebappDeployer() {
+ assembler = (Assembler) SystemInstance.get().getComponent(org.apache.openejb.spi.Assembler.class);
+ webappBuilder = (TomcatWebAppBuilder) SystemInstance.get().getComponent(WebAppBuilder.class);
+ mBeanServer = Registry.getRegistry(null, null).getMBeanServer();
+ }
+
+ @Override
+ public String getUniqueFile() {
+ throw new TomEERuntimeException("This method is not used");
+ }
+
+ @Override
+ public Collection<AppInfo> getDeployedApps() {
+ return assembler.getDeployedApplications();
+ }
+
+ @Override
+ public AppInfo deploy(final String location) throws OpenEJBException {
+ return deploy(location, null);
+ }
+
+ @Override
+ public AppInfo deploy(final Properties properties) throws OpenEJBException {
+ return deploy(null, properties);
+ }
+
+ @Override
+ public AppInfo deploy(String location, Properties properties) throws OpenEJBException {
+ try {
+ if (location == null && properties == null) {
+ throw new NullPointerException("location and properties are null");
+ }
+ if (location == null) {
+ location = properties.getProperty(FILENAME);
+ }
+
+ final File source = new File(location);
+ final File destination = new File(
+ System.getProperty(OPENEJB_HOME) + File.separator + WEBAPPS + File.separator + source.getName());
+ IO.copy(source, destination);
+
+ String destinationWithoutExtension = destination.getAbsolutePath();
+ String destinationFilenameWithoutExtension = destination.getName();
+
+ if (destination.getName().contains(".")) {
+ destinationWithoutExtension = destinationWithoutExtension.substring(0, destinationWithoutExtension.lastIndexOf('.'));
+ destinationFilenameWithoutExtension = destinationFilenameWithoutExtension.substring(0, destinationFilenameWithoutExtension.lastIndexOf('.'));
+ }
+
+ if (destination.getName().toLowerCase().endsWith(".war")) {
+ checkWebapp(destinationFilenameWithoutExtension);
+ } else {
+ check();
+ }
+
+ final AppInfo info = findAppInfo(destination.getAbsolutePath(), destinationWithoutExtension);
+ if (info == null) {
+ throw new NullPointerException("appinfo not found");
+ }
+
+ final DeploymentExceptionManager dem = SystemInstance.get().getComponent(DeploymentExceptionManager.class);
+ if (dem.hasDeploymentFailed()) {
+ final Exception tre = dem.getLastException();
+ // we don't need this exception anymore
+ dem.clearLastException(info);
+ throw tre;
+ }
+
+ return info;
+ } catch (Exception e) {
+ throw new OpenEJBException(e);
+ }
+ }
+
+ private AppInfo findAppInfo(final String... paths) {
+ final Collection<AppInfo> deployedApps = getDeployedApps();
+ for (final AppInfo appInfo : deployedApps) {
+ for (final String path : paths) {
+ if (appInfo.path.equals(path)) {
+ return appInfo;
+ }
+ }
+ }
+ return null;
+ }
+
+ private void check() {
+ final StandardServer server = TomcatHelper.getServer();
+ for (final Service service : server.findServices()) {
+ if (service.getContainer() instanceof Engine) {
+ final Engine engine = (Engine) service.getContainer();
+ for (final Container engineChild : engine.findChildren()) {
+ if (engineChild instanceof StandardHost) {
+ final StandardHost host = (StandardHost) engineChild;
+ webappBuilder.checkHost(host);
+ }
+ }
+ }
+ }
+ }
+
+ private void checkWebapp(final String webappName) {
+ try {
+ final ContextName cn = new ContextName(webappName, true);
+
+ final String name = "Catalina:type=Deployer,host=localhost";
+ final ObjectName oname = new ObjectName(name);
+
+ final String[] params = {cn.getName() };
+ final String[] signature = {"java.lang.String" };
+ mBeanServer.invoke(oname, "check", params, signature);
+ } catch (Exception e) {
+ //Ignore
+ }
+ }
+
+ @Override
+ public void undeploy(final String moduleId) throws UndeployException, NoSuchApplicationException {
+ try {
+ final AppInfo appInfo = findAppInfo(moduleId);
+ if (appInfo != null) {
+ webappBuilder.undeployWebApps(appInfo);
+ }
+
+ assembler.destroyApplication(moduleId);
+
+ final File moduleFile = new File(moduleId);
+
+ if (moduleFile.getName().contains(".")) {
+ // delete matching directory
+ final File dir = new File(moduleFile.getAbsolutePath().substring(0, moduleFile.getAbsolutePath().lastIndexOf('.')));
+ if (dir.exists() && dir.isDirectory()) {
+ delete(dir);
+ }
+ } else {
+ delete(new File(moduleFile + ".war"));
+ delete(new File(moduleFile + ".ear"));
+ delete(new File(moduleFile + ".rar"));
+ }
+
+ delete(moduleFile);
+
+ } catch (Exception e) {
+ throw new UndeployException(e);
+ }
+ }
+
+ @Override
+ public void reload(final String s) {
+ throw new UnsupportedOperationException();
+ }
+
+ private void delete(final File f) {
+ if (f == null || (!f.exists())) {
+ return;
+ }
+
+ if (f.isFile()) {
+ if(!f.delete()){
+ f.deleteOnExit();
+ }
+ return;
+ }
+
+ if (f.isDirectory()) {
+ final File[] listFiles = f.listFiles();
+ if (listFiles != null) {
+ for (final File file : listFiles) {
+ if (file.getName().equals(".") || file.getName().equals("..")) continue;
+ delete(file);
+ }
+ }
+
+ if(!f.delete()){
+ f.deleteOnExit();
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/catalina/facade/ExceptionManagerFacade.java b/src/main/java/catalina/facade/ExceptionManagerFacade.java
new file mode 100644
index 0000000..a67212e
--- /dev/null
+++ b/src/main/java/catalina/facade/ExceptionManagerFacade.java
@@ -0,0 +1,25 @@
+/**
+ * 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 catalina.facade;
+
+import jakarta.ejb.Remote;
+
+@Remote
+public interface ExceptionManagerFacade {
+ Exception exception();
+}
diff --git a/src/main/java/catalina/facade/ExceptionManagerFacadeBean.java b/src/main/java/catalina/facade/ExceptionManagerFacadeBean.java
new file mode 100644
index 0000000..9a33c25
--- /dev/null
+++ b/src/main/java/catalina/facade/ExceptionManagerFacadeBean.java
@@ -0,0 +1,33 @@
+/**
+ * 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 catalina.facade;
+
+import org.apache.openejb.assembler.classic.DeploymentExceptionManager;
+import org.apache.openejb.loader.SystemInstance;
+
+import jakarta.ejb.Singleton;
+import jakarta.ejb.TransactionManagement;
+import jakarta.ejb.TransactionManagementType;
+
+@Singleton(name = "openejb/ExceptionManagerFacade")
+@TransactionManagement(TransactionManagementType.BEAN)
+public class ExceptionManagerFacadeBean implements ExceptionManagerFacade {
+ public Exception exception() {
+ return SystemInstance.get().getComponent(DeploymentExceptionManager.class).getLastException();
+ }
+}
diff --git a/src/test/script/openejb/tck/commands/CommandSupport.groovy b/src/test/script/openejb/tck/commands/CommandSupport.groovy
index a7a8b8e..9032182 100644
--- a/src/test/script/openejb/tck/commands/CommandSupport.groovy
+++ b/src/test/script/openejb/tck/commands/CommandSupport.groovy
@@ -268,8 +268,7 @@ abstract class CommandSupport {
builder.directory = "${project.build.directory}"
builder.append("openejb-tck-*.jar")
builder.directory = "${project.build.directory}/lib"
- builder.append("javaee-api*.jar")
- builder.append("openejb-core*.jar")
+ builder.appendAll("*.jar")
builder.directory = "${javaeetckHome}/lib"
builder.append("javatest.jar")
builder.append("tsharness.jar")