From b17c522f7c26bdc465596282c89c3710823c275a Mon Sep 17 00:00:00 2001 From: Emmanuel Bruno <emmanuel.bruno@univ-tln.fr> Date: Fri, 3 Dec 2021 11:54:57 +0100 Subject: [PATCH] first ear. --- docker/Dockerfile | 8 +- docker/payara/Dockerfile | 8 +- ear/pom.xml | 95 +++++++++++++++++++ .../src/main/application}/insert.sql | 0 .../src/main/application}/log4j.properties | 0 .../src/main/application}/persistence.xml | 1 + entites/src/main/resources/META-INF/beans.xml | 5 + jsf/pom.xml | 7 ++ .../main/resources/META-INF/persistence.xml | 19 ---- pom.xml | 15 ++- .../samples/jee91/rs/JAXRSConfiguration.java | 2 +- restApp/src/main/resources/insert.sql | 4 - {wsApp => websocketApp}/pom.xml | 0 .../bruno/samples/jee91/ws/WSServer.java | 0 .../fr/univtln/bruno/samples/SampleTest.java | 0 {wsClient => websocketClient}/pom.xml | 0 .../samples/jee91/wsclient/WsClient.java | 0 .../src/main/resources}/log4j.properties | 0 .../main/resources/META-INF/persistence.xml | 9 -- wsClient/src/main/resources/log4j.properties | 17 ---- 20 files changed, 129 insertions(+), 61 deletions(-) create mode 100644 ear/pom.xml rename {jsf/src/main/resources => ear/src/main/application}/insert.sql (100%) rename {jsf/src/main/resources/META-INF => ear/src/main/application}/log4j.properties (100%) rename {restApp/src/main/resources/META-INF => ear/src/main/application}/persistence.xml (92%) delete mode 100644 jsf/src/main/resources/META-INF/persistence.xml delete mode 100644 restApp/src/main/resources/insert.sql rename {wsApp => websocketApp}/pom.xml (100%) rename {wsApp => websocketApp}/src/main/java/fr/univtln/bruno/samples/jee91/ws/WSServer.java (100%) rename {wsApp => websocketApp}/src/test/java/fr/univtln/bruno/samples/SampleTest.java (100%) rename {wsClient => websocketClient}/pom.xml (100%) rename {wsClient => websocketClient}/src/main/java/fr/univtln/bruno/samples/jee91/wsclient/WsClient.java (100%) rename {wsApp/src/main/resources/META-INF => websocketClient/src/main/resources}/log4j.properties (100%) delete mode 100644 wsApp/src/main/resources/META-INF/persistence.xml delete mode 100644 wsClient/src/main/resources/log4j.properties diff --git a/docker/Dockerfile b/docker/Dockerfile index b187295..d2dc7d6 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -9,8 +9,8 @@ RUN --mount=type=cache,id=mvncache,target=/root/.m2/repository,rw \ ### Then we add the builded war to a JEE server. -#FROM payara/server-full:5.2021.9-jdk11 as server -FROM brunoe/payara:jdk11-6 as server +FROM payara/server-full:5.2021.9-jdk11 as server +#FROM brunoe/payara:jdk11-6 as server ARG STORE_PASSWORD=changeit ## Download the JDBC driver @@ -43,5 +43,7 @@ FROM server as production # $DEPLOY_DIR #COPY --from=build /app/wsApp/target/*.war \ # $DEPLOY_DIR -COPY --from=build /app/jsf/target/*.war \ +#COPY --from=build /app/jsf/target/*.war \ +# $DEPLOY_DIR +COPY --from=build /app/ear/target/*.ear \ $DEPLOY_DIR \ No newline at end of file diff --git a/docker/payara/Dockerfile b/docker/payara/Dockerfile index 0566587..c0415ed 100644 --- a/docker/payara/Dockerfile +++ b/docker/payara/Dockerfile @@ -8,13 +8,15 @@ FROM eclipse-temurin:11-jdk # 8181: https EXPOSE 4848 9009 8080 8181 -# Payara version (5.183+) #ARG PAYARA_VERSION=5.2021.9 -ARG PAYARA_VERSION=6.2021.1.Alpha1 -ARG PAYARA_PKG=https://search.maven.org/remotecontent?filepath=fish/payara/distributions/payara/${PAYARA_VERSION}/payara-${PAYARA_VERSION}.zip #ARG PAYARA_SHA1=81c43f3c537ec74a813b48172758866615e1e792 + +ARG PAYARA_VERSION=6.2021.1.Alpha1 ARG PAYARA_SHA1=0262f8af7e52b318109ed43f8a31a1e93f111bbf +ARG PAYARA_PKG=https://search.maven.org/remotecontent?filepath=fish/payara/distributions/payara/${PAYARA_VERSION}/payara-${PAYARA_VERSION}.zip + + ARG TINI_VERSION=v0.19.0 # Initialize the configurable environment variables diff --git a/ear/pom.xml b/ear/pom.xml new file mode 100644 index 0000000..d656870 --- /dev/null +++ b/ear/pom.xml @@ -0,0 +1,95 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>jee9.1</artifactId> + <groupId>fr.univtln.bruno.samples.jee91</groupId> + <version>1.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>ear</artifactId> + <packaging>ear</packaging> + + <dependencies> + <dependency> + <groupId>jakarta.platform</groupId> + <artifactId>jakarta.jakartaee-api</artifactId> + </dependency> + <dependency> + <groupId>fr.univtln.bruno.samples.jee91</groupId> + <artifactId>restApp</artifactId> + <version>1.0-SNAPSHOT</version> + <type>war</type> + </dependency> + <dependency> + <groupId>fr.univtln.bruno.samples.jee91</groupId> + <artifactId>wsApp</artifactId> + <version>1.0-SNAPSHOT</version> + <type>war</type> + </dependency> + <dependency> + <groupId>fr.univtln.bruno.samples.jee91</groupId> + <artifactId>jsf</artifactId> + <version>1.0-SNAPSHOT</version> + <type>war</type> + </dependency> + <dependency> + <groupId>fr.univtln.bruno.samples.jee91</groupId> + <artifactId>business</artifactId> + <version>1.0-SNAPSHOT</version> + <type>ejb</type> + </dependency> + + <dependency> + <groupId>fr.univtln.bruno.samples.jee91</groupId> + <artifactId>dao</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + </dependencies> + + <build> + <finalName>personManager</finalName> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-ear-plugin</artifactId> + <version>3.2.0</version> + <configuration> + <displayName>Person manager</displayName> + <!-- If I want maven to generate the application.xml, set this to true --> + <generateApplicationXml>true</generateApplicationXml> + <defaultLibBundleDir>lib/</defaultLibBundleDir> + <skinnyWars>true</skinnyWars> + <modules> + <webModule> + <groupId>fr.univtln.bruno.samples.jee91</groupId> + <artifactId>restApp</artifactId> + <bundleFileName>restApp.war</bundleFileName> + <contextRoot>/rest</contextRoot> + </webModule> + <webModule> + <groupId>fr.univtln.bruno.samples.jee91</groupId> + <artifactId>jsf</artifactId> + <bundleFileName>jsf.war</bundleFileName> + <contextRoot>/jsf</contextRoot> + </webModule> + <webModule> + <groupId>fr.univtln.bruno.samples.jee91</groupId> + <artifactId>wsApp</artifactId> + <bundleFileName>wsApp.war</bundleFileName> + <contextRoot>/ws</contextRoot> + </webModule> + <ejbModule> + <groupId>fr.univtln.bruno.samples.jee91</groupId> + <artifactId>business</artifactId> + <bundleFileName>business.jar</bundleFileName> + </ejbModule> + </modules> + </configuration> + </plugin> + </plugins> + </build> + + +</project> \ No newline at end of file diff --git a/jsf/src/main/resources/insert.sql b/ear/src/main/application/insert.sql similarity index 100% rename from jsf/src/main/resources/insert.sql rename to ear/src/main/application/insert.sql diff --git a/jsf/src/main/resources/META-INF/log4j.properties b/ear/src/main/application/log4j.properties similarity index 100% rename from jsf/src/main/resources/META-INF/log4j.properties rename to ear/src/main/application/log4j.properties diff --git a/restApp/src/main/resources/META-INF/persistence.xml b/ear/src/main/application/persistence.xml similarity index 92% rename from restApp/src/main/resources/META-INF/persistence.xml rename to ear/src/main/application/persistence.xml index 18fe3ba..98e834c 100644 --- a/restApp/src/main/resources/META-INF/persistence.xml +++ b/ear/src/main/application/persistence.xml @@ -5,6 +5,7 @@ version="3.0"> <persistence-unit name="myappPU" transaction-type="JTA"> <jta-data-source>jdbc/my-h2-pool</jta-data-source> + <jar-file>lib/fr.univtln.bruno.samples.jee91-entites-1.0-SNAPSHOT.jar</jar-file> <class>fr.univtln.bruno.samples.jee91.dao.Person</class> <properties> diff --git a/entites/src/main/resources/META-INF/beans.xml b/entites/src/main/resources/META-INF/beans.xml index e69de29..efd69bc 100644 --- a/entites/src/main/resources/META-INF/beans.xml +++ b/entites/src/main/resources/META-INF/beans.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<beans xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_3_0.xsd" + bean-discovery-mode="all"> +</beans> \ No newline at end of file diff --git a/jsf/pom.xml b/jsf/pom.xml index d5f2855..ae4730c 100644 --- a/jsf/pom.xml +++ b/jsf/pom.xml @@ -67,6 +67,13 @@ <artifactId>all-themes</artifactId> <version>${all-themes.version}</version> </dependency--> + + <dependency> + <groupId>org.glassfish</groupId> + <artifactId>jakarta.faces</artifactId> + <version>3.0.1</version> + </dependency> + </dependencies> <build> diff --git a/jsf/src/main/resources/META-INF/persistence.xml b/jsf/src/main/resources/META-INF/persistence.xml deleted file mode 100644 index e900259..0000000 --- a/jsf/src/main/resources/META-INF/persistence.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<persistence xmlns="https://jakarta.ee/xml/ns/persistence" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd" - version="3.0"> - <persistence-unit name="myappPU" transaction-type="JTA"> - <jta-data-source>jdbc/my-h2-pool</jta-data-source> - <class>fr.univtln.bruno.samples.jee91.dao.Person</class> - <validation-mode>CALLBACK</validation-mode> - <properties> - <property name="jakarta.persistence.schema-generation.database.action" value="drop-and-create" /> - <property name="jakarta.persistence.schema-generation.scripts.action" value="drop-and-create" /> - <property name="jakarta.persistence.schema-generation.scripts.create-target" value="sampleCreate.ddl" /> - <property name="jakarta.persistence.schema-generation.scripts.drop-target" value="sampleDrop.ddl" /> - - <property name="jakarta.persistence.sql-load-script-source" value="insert.sql" /> - </properties> - </persistence-unit> -</persistence> \ No newline at end of file diff --git a/pom.xml b/pom.xml index 7b34419..03aa942 100644 --- a/pom.xml +++ b/pom.xml @@ -8,14 +8,19 @@ <modules> + <module>utils</module> + + <module>entites</module> + <module>dao</module> + <module>business</module> <module>restApp</module> - <module>wsApp</module> - <module>dao</module> - <module>wsClient</module> - <module>entites</module> - <module>utils</module> + <module>websocketApp</module> <module>jsf</module> + <module>ear</module> + + <module>websocketClient</module> + </modules> <packaging>pom</packaging> diff --git a/restApp/src/main/java/fr/univtln/bruno/samples/jee91/rs/JAXRSConfiguration.java b/restApp/src/main/java/fr/univtln/bruno/samples/jee91/rs/JAXRSConfiguration.java index ece5bca..5e8e933 100644 --- a/restApp/src/main/java/fr/univtln/bruno/samples/jee91/rs/JAXRSConfiguration.java +++ b/restApp/src/main/java/fr/univtln/bruno/samples/jee91/rs/JAXRSConfiguration.java @@ -4,7 +4,7 @@ package fr.univtln.bruno.samples.jee91.rs; import jakarta.ws.rs.ApplicationPath; import jakarta.ws.rs.core.Application; -@ApplicationPath("resources") +@ApplicationPath("/") public class JAXRSConfiguration extends Application { } \ No newline at end of file diff --git a/restApp/src/main/resources/insert.sql b/restApp/src/main/resources/insert.sql deleted file mode 100644 index e74e7ff..0000000 --- a/restApp/src/main/resources/insert.sql +++ /dev/null @@ -1,4 +0,0 @@ -INSERT INTO "public"."person" ("name", "uuid") VALUES ('Yves', 'ACED00057372000E6A6176612E7574696C2E55554944BC9903F7986D852F0200024A000C6C65617374536967426974734A000B6D6F7374536967426974737870B25A000916801FE374FCFAC5DCF94C11'); -INSERT INTO "public"."person" ("name", "uuid") VALUES ('Pierre', 'ACED00057372000E6A6176612E7574696C2E55554944BC9903F7986D852F0200024A000C6C65617374536967426974734A000B6D6F7374536967426974737870B8F28F7D3945291756DAC7325DF44938'); -INSERT INTO "public"."person" ("name", "uuid") VALUES ('Marie', 'ACED00057372000E6A6176612E7574696C2E55554944BC9903F7986D852F0200024A000C6C65617374536967426974734A000B6D6F73745369674269747378709AA3211A9B897403843C82366C6B450E'); -INSERT INTO "public"."person" ("name", "uuid") VALUES ('Jeanne', 'ACED00057372000E6A6176612E7574696C2E55554944BC9903F7986D852F0200024A000C6C65617374536967426974734A000B6D6F7374536967426974737870BC1580AEB48C0F0C0B3C82E884AA4C3C'); \ No newline at end of file diff --git a/wsApp/pom.xml b/websocketApp/pom.xml similarity index 100% rename from wsApp/pom.xml rename to websocketApp/pom.xml diff --git a/wsApp/src/main/java/fr/univtln/bruno/samples/jee91/ws/WSServer.java b/websocketApp/src/main/java/fr/univtln/bruno/samples/jee91/ws/WSServer.java similarity index 100% rename from wsApp/src/main/java/fr/univtln/bruno/samples/jee91/ws/WSServer.java rename to websocketApp/src/main/java/fr/univtln/bruno/samples/jee91/ws/WSServer.java diff --git a/wsApp/src/test/java/fr/univtln/bruno/samples/SampleTest.java b/websocketApp/src/test/java/fr/univtln/bruno/samples/SampleTest.java similarity index 100% rename from wsApp/src/test/java/fr/univtln/bruno/samples/SampleTest.java rename to websocketApp/src/test/java/fr/univtln/bruno/samples/SampleTest.java diff --git a/wsClient/pom.xml b/websocketClient/pom.xml similarity index 100% rename from wsClient/pom.xml rename to websocketClient/pom.xml diff --git a/wsClient/src/main/java/fr/univtln/bruno/samples/jee91/wsclient/WsClient.java b/websocketClient/src/main/java/fr/univtln/bruno/samples/jee91/wsclient/WsClient.java similarity index 100% rename from wsClient/src/main/java/fr/univtln/bruno/samples/jee91/wsclient/WsClient.java rename to websocketClient/src/main/java/fr/univtln/bruno/samples/jee91/wsclient/WsClient.java diff --git a/wsApp/src/main/resources/META-INF/log4j.properties b/websocketClient/src/main/resources/log4j.properties similarity index 100% rename from wsApp/src/main/resources/META-INF/log4j.properties rename to websocketClient/src/main/resources/log4j.properties diff --git a/wsApp/src/main/resources/META-INF/persistence.xml b/wsApp/src/main/resources/META-INF/persistence.xml deleted file mode 100644 index 2cc7997..0000000 --- a/wsApp/src/main/resources/META-INF/persistence.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<persistence xmlns="https://jakarta.ee/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd" - version="3.0"> - <persistence-unit name="myappPU" transaction-type="JTA"> - <jta-data-source>jdbc/my-h2-pool</jta-data-source> - <class>fr.univtln.bruno.samples.jee91.dao.Person</class> - </persistence-unit> -</persistence> \ No newline at end of file diff --git a/wsClient/src/main/resources/log4j.properties b/wsClient/src/main/resources/log4j.properties deleted file mode 100644 index b26344f..0000000 --- a/wsClient/src/main/resources/log4j.properties +++ /dev/null @@ -1,17 +0,0 @@ -log4j.rootLogger=debug, stdout, R - -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout - -# Pattern to output the caller's file name and line number. -log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n - -log4j.appender.R=org.apache.log4j.RollingFileAppender -log4j.appender.R.File=wqClient.log - -log4j.appender.R.MaxFileSize=100KB -# Keep one backup file -log4j.appender.R.MaxBackupIndex=1 - -log4j.appender.R.layout=org.apache.log4j.PatternLayout -log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n \ No newline at end of file -- GitLab