Skip to content

Commit

Permalink
switch to open-liberty maven tools
Browse files Browse the repository at this point in the history
  • Loading branch information
jdmcclur committed Nov 6, 2020
1 parent 2e08ab7 commit 441f1cd
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 189 deletions.
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM openliberty/open-liberty:kernel-java11-openj9-ubi

COPY --chown=1001:0 src/main/liberty/config/server.xml /config/server.xml
COPY --chown=1001:0 src/main/liberty/config/server.xml /config/server.env
COPY --chown=1001:0 target/io.openliberty.sample.daytrader8.war /config/apps/

#Derby
COPY --chown=1001:0 target/liberty/wlp/usr/shared/resources/DerbyLibs/derby-10.14.2.0.jar /opt/ol/wlp/usr/shared/resources/DerbyLibs/derby-10.14.2.0.jar
COPY --chown=1001:0 target/liberty/wlp/usr/shared/resources/data /opt/ol/wlp/usr/shared/resources/data

RUN configure.sh
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ git clone [email protected]:OpenLiberty/sample.daytrader8.git

From inside the sample.daytrader8 directory, build and start the application in Open Liberty with the following command:
```
mvn clean package liberty:run-server
mvn clean package liberty:run
```

The server will listen on port 9080 by default. You can change the port (for example, to port 9081) by adding `mvn clean package liberty:run-server -DtestServerHttpPort=9081` to the end of the Maven command.
The server will listen on port 9080 by default. You can change the port (for example, to port 9081) by adding `mvn clean package liberty:run -DtestServerHttpPort=9081` to the end of the Maven command.

Once the server is started, you should be able to access the application at:
http://localhost:9080/daytrader
Expand Down
206 changes: 88 additions & 118 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,134 +1,104 @@
<?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">
<modelVersion>4.0.0</modelVersion>

<groupId>io.openliberty.samples</groupId>
<artifactId>io.openliberty.sample.daytrader8</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<parent>
<groupId>net.wasdev.wlp.maven.parent</groupId>
<artifactId>liberty-maven-app-parent</artifactId>
<version>2.6.1</version>
</parent>


<properties>
<modelVersion>4.0.0</modelVersion>
<groupId>io.openliberty.samples</groupId>
<artifactId>io.openliberty.sample.daytrader8</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<app.name>LibertyProject</app.name>
<!-- Derby library -->
<version.derby>10.14.2.0</version.derby>
<derby.path>${user.home}/.m2/repository/org/apache/derby/derby</derby.path>
<!-- Liberty configuration -->
<testServerHttpPort>9080</testServerHttpPort>
<testServerHttpsPort>9443</testServerHttpsPort>
<package.file>${project.build.directory}/${app.name}.zip</package.file>
<packaging.type>usr</packaging.type>
<skipTests>false</skipTests>
</properties>

<dependencies>
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0</version>
<scope>provided</scope>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.1</version>
<scope>compile</scope>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
<scope>provided</scope>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>copy-derby</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<!-- Derby from https://mvnrepository.com/artifact/org.apache.derby/derby -->
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>${version.derby}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<!-- Enable liberty-maven plugin -->
<plugins>
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>3.3-M4</version>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.13.1.1</version>
<outputDirectory>${project.build.directory}/liberty/wlp/usr/shared/resources/DerbyLibs</outputDirectory>
</artifactItem>
</artifactItems>
<bootstrapProperties>
<default.http.port>${testServerHttpPort}</default.http.port>
<default.https.port>${testServerHttpsPort}</default.https.port>
</bootstrapProperties>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/liberty/wlp/usr/shared/resources/data</outputDirectory>
<resources>
<resource>
<directory>resources/data</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<packagingExcludes>pom.xml</packagingExcludes>
</configuration>
</plugin>
<!-- Enable liberty-maven plugin -->
<plugin>
<groupId>net.wasdev.wlp.maven.plugins</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<assemblyArtifact>
<groupId>io.openliberty</groupId>
<artifactId>openliberty-runtime</artifactId>
<version>RELEASE</version>
<type>zip</type>
</assemblyArtifact>
<serverName>sampleAppServer</serverName>
<configFile>src/main/liberty/config/server.xml</configFile>
<serverEnv>src/main/liberty/config/server.env</serverEnv>
<packageFile>${package.file}</packageFile>
<include>${packaging.type}</include>
<bootstrapProperties>
<default.http.port>${testServerHttpPort}</default.http.port>
<default.https.port>${testServerHttpsPort}</default.https.port>
</bootstrapProperties>
</configuration>
</plugin>
</plugins>
</build>

</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.2</version>
<executions>
<execution>
<id>copy-derby-dependency</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeArtifactIds>derby</includeArtifactIds>
<outputDirectory>${project.build.directory}/liberty/wlp/usr/shared/resources/DerbyLibs/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/liberty/wlp/usr/shared/resources/data</outputDirectory>
<resources>
<resource>
<directory>resources/data</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
142 changes: 73 additions & 69 deletions src/main/liberty/config/server.xml
Original file line number Diff line number Diff line change
@@ -1,75 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<server>
<featureManager>
<feature>ejb-3.2</feature>
<feature>servlet-4.0</feature>
<feature>jsf-2.3</feature>
<feature>jpa-2.2</feature>
<feature>mdb-3.2</feature>
<feature>wasJmsServer-1.0</feature>
<feature>wasJmsClient-2.0</feature>
<feature>cdi-2.0</feature>
<feature>websocket-1.1</feature>
<feature>concurrent-1.0</feature>
<feature>jsonp-1.1</feature>
<feature>jsonb-1.0</feature>
<feature>beanValidation-2.0</feature>
<feature>jaxrs-2.1</feature>
<feature>ssl-1.0</feature>
</featureManager>

<keyStore id="defaultKeyStore" password="yourPassword" />
<featureManager>
<feature>ejb-3.2</feature>
<feature>servlet-4.0</feature>
<feature>jsf-2.3</feature>
<feature>jpa-2.2</feature>
<feature>mdb-3.2</feature>
<feature>wasJmsServer-1.0</feature>
<feature>wasJmsClient-2.0</feature>
<feature>cdi-2.0</feature>
<feature>websocket-1.1</feature>
<feature>concurrent-1.0</feature>
<feature>jsonp-1.1</feature>
<feature>jsonb-1.0</feature>
<feature>beanValidation-2.0</feature>
<feature>jaxrs-2.1</feature>
<feature>ssl-1.0</feature>
</featureManager>

<!--<logging traceSpecification="daytrader=fine"/>-->
<variable name="derby.lib" defaultValue="${shared.resource.dir}/DerbyLibs/derby-10.14.2.0.jar" />

<!-- allow reuse of 'busy' ports for fast server recycling on linux (where ports remain blocked for up to 2 mins after server stops) ${tradelite.http.port} set in bootstrap.properties -->
<httpEndpoint host="*" httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint">
<tcpOptions soReuseAddr="true"/>
<httpOptions maxKeepAliveRequests="-1"/>
</httpEndpoint>
<keyStore id="defaultKeyStore" password="yourPassword" />

<webApplication id="daytrader8" location="io.openliberty.sample.daytrader8.war" name="daytrader8" context-root="daytrader"/>
<!--<logging traceSpecification="daytrader=fine"/>-->

<connectionManager agedTimeout="-1" connectionTimeout="0" id="conMgr1" maxIdleTime="-1" maxPoolSize="100" minPoolSize="100" purgePolicy="FailingConnectionOnly" reapTime="-1"/>
<!-- allow reuse of 'busy' ports for fast server recycling on linux (where ports remain blocked for up to 2 mins after server stops) ${tradelite.http.port} set in bootstrap.properties -->
<httpEndpoint host="*" httpPort="${default.http.port}" httpsPort="${default.https.port}" id="defaultHttpEndpoint">
<tcpOptions soReuseAddr="true" />
<httpOptions maxKeepAliveRequests="-1" />
</httpEndpoint>

<application location="io.openliberty.sample.daytrader8.war" type="war" context-root="/daytrader" />

<!-- Derby Library Configuration -->
<library id="derbyJDBCLib">
<file name="${derby.lib}" />
</library>

<authData id="TradeDataSourceAuthData" password="db_password" user="db_username" />
<authData id="TradeAdminAuthData" password="db_password" user="db_username" />

<jdbcDriver id="DerbyEmbedded" libraryRef="DerbyLib"/>
<library filesetRef="DerbyFileset" id="DerbyLib"/>
<fileset dir="${shared.resource.dir}/DerbyLibs" id="DerbyFileset" includes="derby-10.13.1.1.jar"/>

<authData id="TradeDataSourceAuthData" password="db_password" user="db_username"/>
<authData id="TradeAdminAuthData" password="db_password" user="db_username"/>

<dataSource connectionManagerRef="conMgr1" id="DefaultDataSource" isolationLevel="TRANSACTION_READ_COMMITTED" jdbcDriverRef="DerbyEmbedded" jndiName="jdbc/TradeDataSource" statementCacheSize="60">
<properties.derby.embedded createDatabase="create" databaseName="${shared.resource.dir}/data/tradedb" password="db_password" user="db_username"/>
</dataSource>

<messagingEngine id="defaultME">
<queue id="TradeBrokerQueue"/>
<topicSpace id="TradeTopicSpace"/>
</messagingEngine>

<jmsQueueConnectionFactory connectionManagerRef="ConMgr3" jndiName="jms/TradeBrokerQCF">
<properties.wasJms/>
</jmsQueueConnectionFactory>
<connectionManager id="ConMgr3" maxPoolSize="20"/>

<jmsTopicConnectionFactory connectionManagerRef="ConMgr4" jndiName="jms/TradeStreamerTCF">
<properties.wasJms/>
</jmsTopicConnectionFactory>
<connectionManager id="ConMgr4" maxPoolSize="20"/>

<jmsQueue id="TradeBrokerQueue" jndiName="jms/TradeBrokerQueue">
<properties.wasJms deliveryMode="NonPersistent" queueName="TradeBrokerQueue"/>
</jmsQueue>

<jmsTopic id="TradeStreamerTopic" jndiName="jms/TradeStreamerTopic">
<properties.wasJms deliveryMode="NonPersistent" topicSpace="TradeTopicSpace"/>
</jmsTopic>

<jmsActivationSpec id="io.openliberty.sample.daytrader8/DTBroker3MDB">
<properties.wasJms destinationRef="TradeBrokerQueue"/>
</jmsActivationSpec>

<jmsActivationSpec id="io.openliberty.sample.daytrader8/DTStreamer3MDB">
<properties.wasJms destinationRef="TradeStreamerTopic" destinationType="javax.jms.Topic"/>
</jmsActivationSpec>
</server>
<connectionManager agedTimeout="-1" connectionTimeout="0" id="conMgr1" maxIdleTime="-1" maxPoolSize="100" minPoolSize="100" purgePolicy="FailingConnectionOnly" reapTime="-1" />
<dataSource connectionManagerRef="conMgr1" id="DefaultDataSource" isolationLevel="TRANSACTION_READ_COMMITTED" jndiName="jdbc/TradeDataSource" statementCacheSize="60">
<jdbcDriver libraryRef="derbyJDBCLib" />
<properties.derby.embedded databaseName="${shared.resource.dir}/data/tradedb" password="db_password" user="db_username" />
</dataSource>

<messagingEngine id="defaultME">
<queue id="TradeBrokerQueue" />
<topicSpace id="TradeTopicSpace" />
</messagingEngine>

<connectionManager id="ConMgr2" maxPoolSize="20" />
<jmsQueueConnectionFactory connectionManagerRef="ConMgr2" jndiName="jms/TradeBrokerQCF">
<properties.wasJms />
</jmsQueueConnectionFactory>

<connectionManager id="ConMgr3" maxPoolSize="20" />
<jmsTopicConnectionFactory connectionManagerRef="ConMgr3" jndiName="jms/TradeStreamerTCF">
<properties.wasJms />
</jmsTopicConnectionFactory>

<jmsQueue id="TradeBrokerQueue" jndiName="jms/TradeBrokerQueue">
<properties.wasJms deliveryMode="NonPersistent" queueName="TradeBrokerQueue" />
</jmsQueue>

<jmsTopic id="TradeStreamerTopic" jndiName="jms/TradeStreamerTopic">
<properties.wasJms deliveryMode="NonPersistent" topicSpace="TradeTopicSpace" />
</jmsTopic>

<jmsActivationSpec id="io.openliberty.sample.daytrader8/DTBroker3MDB">
<properties.wasJms destinationRef="TradeBrokerQueue" />
</jmsActivationSpec>

<jmsActivationSpec id="io.openliberty.sample.daytrader8/DTStreamer3MDB">
<properties.wasJms destinationRef="TradeStreamerTopic" destinationType="javax.jms.Topic" />
</jmsActivationSpec>
</server>

0 comments on commit 441f1cd

Please sign in to comment.