Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open Liberty support #283

Merged
merged 13 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,35 @@ To set up in Visual Studio Code, follow these steps:
* Open the directory that contains the code in Visual Studio Code. Visual Studio Code will do the rest for you, it will automatically configure a Maven project. Proceed with clean/building the application.
* After the project is built (which will take a while the very first time as Maven downloads dependencies), simply run the generated `cargo-tracker.war` file under the `target` directory using Payara Tools.

## Getting Started with Open Liberty

To set up the project with Open Liberty and Maven:

* Ensure you are running Java SE 11, or Java SE 17. IBM Semeru is the recommended Java SDK for Open Liberty. Go to [IBM Semeru Runtimes Downloads](https://developer.ibm.com/languages/java/semeru-runtimes/downloads/) and select Java 11 or Java 17 from the version dropdown menu.
* Make sure the `JAVA_HOME`environment variable is set on your system.
* Navigate to the `cargotracker` directory and develop the application with the [Liberty Maven Plugin](https://github.com/OpenLiberty/ci.maven#cimaven--): `mvn -P openliberty liberty:dev`.
* You can safely ignore the shrinkwrap features warning, message-driven bean warning, and the AggregateObjectMapping nested foreign key warning, as they don't affect the application functionality.
* The application starts without any additional errors and you can visit it at the http://localhost:8080/cargo-tracker URL.

To set up the project with Open Liberty in Visual Studio Code:

* Ensure you are running [Visual Studio Code](https://code.visualstudio.com/download) with Java 17.
* Install [Liberty Tools for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=Open-Liberty.liberty-dev-vscode-ext).
* Open the Cargo Tracker project by selecting **Explorer** > **Open Folder**. Select the `cargotracker` directory.
* The `cargo-tracker` project appears under the `LIBERTY DASHBOARD` extension in the Explorer sidebar.
* Right-click the `cargo-tracker` project and select `Start...` to start the application. Type `-P openliberty` in the pop-up entry field and then press the Enter/return key.
* A terminal window in the IDE opens and the Liberty Maven Plugin starts the application. Liberty is running in dev mode.
* You can safely ignore the shrinkwrap features warning, message-driven bean warning, and the AggregateObjectMapping nested foreign key warning, as they don't affect the application functionality.
* You can visit the application at http://localhost:8080/cargo-tracker when you see the following message at the terminal:
```
************************************************************************
[INFO] * Liberty is running in dev mode.
...
[INFO] Source compilation was successful.
[INFO] Tests compilation was successful.
```


## Exploring the Application

After the application runs, it will be available at:
Expand Down
67 changes: 67 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -296,5 +296,72 @@
</plugins>
</build>
</profile>
<profile>
<id>openliberty</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<db.driverClass>org.hsqldb.jdbc.JDBCDriver</db.driverClass>
<db.jdbcUrl>jdbc:hsqldb:file:./cargo-tracker-data/cargo-tracker-database;create=true</db.jdbcUrl>
</properties>
<dependencies>
<!-- Provided dependencies -->
<dependency>
<groupId>org.eclipse.microprofile</groupId>
gkwan-ibm marked this conversation as resolved.
Show resolved Hide resolved
<artifactId>microprofile</artifactId>
<version>6.0</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
gkwan-ibm marked this conversation as resolved.
Show resolved Hide resolved
<version>10.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.7.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
m-reza-rahman marked this conversation as resolved.
Show resolved Hide resolved
<artifactId>jersey-server</artifactId>
<version>3.1.2</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<!-- Enable liberty-maven plugin -->
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>3.8.2</version>
<configuration>
<copyDependencies>
<dependencyGroup>
<location>${project.build.directory}/liberty/wlp/usr/shared/resources</location>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
</dependencyGroup>
</copyDependencies>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
6 changes: 6 additions & 0 deletions src/main/liberty/config/bootstrap.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
org.apache.el.parser.SKIP_IDENTIFIER_CHECK=true
com.ibm.ws.logging.max.file.size=100
com.ibm.ws.logging.max.files=3
default.http.port=8080
default.https.port=8081
# com.ibm.ws.logging.trace.specification=*=info=enabled:logservice=all:com.ibm.ws.jaxrs*=all:com.ibm.websphere.jaxrs*=all:org.apache.cxf.*=all:EJBContainer=all:Injection=all
142 changes: 142 additions & 0 deletions src/main/liberty/config/server.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<server description="Cargo Tracker service">

<featureManager>
<feature>batch-2.1</feature>
<feature>beanValidation-3.0</feature>
<feature>cdi-4.0</feature>
<feature>enterpriseBeansLite-4.0</feature>
<feature>enterpriseBeansPersistentTimer-4.0</feature>
<feature>faces-4.0</feature>
<feature>jdbc-4.3</feature>
<feature>jndi-1.0</feature>
<feature>jsonb-3.0</feature>
<feature>mdb-4.0</feature>
<feature>messaging-3.1</feature>
<feature>messagingClient-3.0</feature>
<feature>messagingServer-3.0</feature>
<feature>persistence-3.1</feature>
<feature>restfulWS-3.1</feature>
<feature>xmlBinding-4.0</feature>
</featureManager>

<!--
<logging traceSpecification="*=info:EJBContainer=all:Injection*=all:com.ibm.websphere.jaxrs*=all:com.ibm.ws.jaxrs*=all:logservice*=all:org.apache.cxf.*=all:rarInstall*=all:WAS.j2c*=all:runtime.update*=all:resource*=all"
traceFileName="trace.log"
maxFileSize="0"
maxFiles="0"
traceFormat="BASIC"
/>
-->

<variable defaultValue="8080" name="default.http.port"/>
<variable defaultValue="8081" name="default.https.port"/>

<httpEndpoint host="*" httpPort="${default.http.port}" httpsPort="${default.https.port}" id="defaultHttpEndpoint"/>
<wasJmsEndpoint host="*" id="InboundJmsCommsEndpoint" wasJmsPort="7276" wasJmsSSLPort="9100"/>

<quickStartSecurity userName="usr" userPassword="pwd"/>

<authorization-roles id="com.ibm.ws.batch">
<security-role name="batchAdmin">
<special-subject type="EVERYONE"/>
</security-role>
</authorization-roles>

<connectionManager id="CargoCM" maxPoolSize="400" minPoolSize="1"/>

<messagingEngine id="defaultME">
<queue forceReliability="ReliablePersistent" id="CargoHandledQueue" maxQueueDepth="5000"/>
<queue forceReliability="ReliablePersistent" id="MisdirectedCargoQueue" maxQueueDepth="5000"/>
<queue forceReliability="ReliablePersistent" id="DeliveredCargoQueue" maxQueueDepth="5000"/>
<queue forceReliability="ReliablePersistent" id="HandlingEventRegistrationAttemptQueue" maxQueueDepth="5000"/>
<queue forceReliability="ReliablePersistent" id="RejectedRegistrationAttemptsQueue" maxQueueDepth="5000"/>
</messagingEngine>

<jmsQueueConnectionFactory connectionManagerRef="CargoCM" jndiName="java:app/jms/QueueConnectionFactory">
</jmsQueueConnectionFactory>

<jmsQueue id="CargoHandledQueue" jndiName="jms/CargoHandledQueue">
<properties.wasJms queueName="CargoHandledQueue"/>
</jmsQueue>

<jmsActivationSpec id="cargo-tracker/CargoHandledConsumer">
<properties.wasJms destinationLookup="java:app/jms/CargoHandledQueue" destinationRef="CargoHandledQueue" destinationType="jakarta.jms.Queue" maxConcurrency="200"/>
</jmsActivationSpec>

<jmsQueue id="MisdirectedCargoQueue" jndiName="jms/MisdirectedCargoQueue">
<properties.wasJms queueName="MisdirectedCargoQueue"/>
</jmsQueue>

<jmsActivationSpec id="cargo-tracker/MisdirectedCargoConsumer">
<properties.wasJms destinationRef="MisdirectedCargoQueue" destinationType="jakarta.jms.Queue" maxConcurrency="200"/>
</jmsActivationSpec>

<jmsQueue id="DeliveredCargoQueue" jndiName="jms/DeliveredCargoQueue">
<properties.wasJms queueName="DeliveredCargoQueue"/>
</jmsQueue>

<jmsActivationSpec id="cargo-tracker/DeliveredCargoConsumer">
<properties.wasJms destinationRef="DeliveredCargoQueue" destinationType="jakarta.jms.Queue" maxConcurrency="200"/>
</jmsActivationSpec>

<jmsQueue id="HandlingEventRegistrationAttemptQueue" jndiName="jms/HandlingEventRegistrationAttemptQueue">
<properties.wasJms queueName="HandlingEventRegistrationAttemptQueue"/>
</jmsQueue>

<jmsActivationSpec id="cargo-tracker/HandlingEventRegistrationAttemptConsumer">
<properties.wasJms destinationRef="HandlingEventRegistrationAttemptQueue" destinationType="jakarta.jms.Queue" maxConcurrency="200"/>
</jmsActivationSpec>

<jmsQueue id="RejectedRegistrationAttemptsQueue" jndiName="jms/RejectedRegistrationAttemptsQueue">
<properties.wasJms queueName="RejectedRegistrationAttemptsQueue"/>
</jmsQueue>

<jmsActivationSpec id="cargo-tracker/RejectedRegistrationAttemptsConsumer">
<properties.wasJms destinationRef="RejectedRegistrationAttemptsQueue" destinationType="jakarta.jms.Queue" maxConcurrency="200"/>
</jmsActivationSpec>

<jdbcDriver id="dbDriver" libraryRef="dbLib"/>

<library id="dbLib">
<fileset dir="${shared.resource.dir}" includes="hsqldb*.jar"/>
</library>

<dataSource id="cargoTrackerDataStore" jndiName="jdbc/CargoTrackerDatabase">
<jdbcDriver libraryRef="dbLib"/>
<properties URL="jdbc:hsqldb:mem:CargoTrackerDB" password="pwd" user="usr"/>
</dataSource>

<databaseStore id="EJBPersistentTimerStore" keyGenerationStrategy="SEQUENCE" tablePrefix="WLP2_"/>
<persistentExecutor enableTaskExecution="true" id="EJBPersistentTimerExecutor" ignore.minimum.for.test.use.only="true" initialPollDelay="-1" retryInterval="300s" retryLimit="-1" taskStoreRef="EJBPersistentTimerStore">
</persistentExecutor>

<databaseStore id="ejbTimerDataStore" keyGenerationStrategy="SEQUENCE"/>
<dataSource id="DefaultDataSource" jdbcDriverRef="dbDriver">
<properties URL="jdbc:hsqldb:mem:EJBTimerDS" password="pwd" user="usr"/>
</dataSource>

<ejbContainer>
<timerService persistentExecutorRef="EJBPersistentTimerExecutor"/>
<timerService missedPersistentTimerAction="ONCE"/>
</ejbContainer>

<webApplication contextRoot="cargo-tracker" location="cargo-tracker.war">
<classloader commonLibraryRef="dbLib"/>
<web-bnd moduleName="cargo-tracker">
<env-entry name="java:app/configuration/GraphTraversalUrl" value="http://localhost:8080/cargo-tracker/rest/graph-traversal/shortest-path"/>
</web-bnd>
<application-bnd>
<security-role name="batchAdmin">
<special-subject type="EVERYONE"/>
</security-role>
</application-bnd>
</webApplication>

<keyStore id="defaultKeyStore" password="password"/>
<applicationMonitor updateTrigger="mbean"/>
<applicationManager autoExpand="true"/>
<httpSession cookieName="COOKIE"/>
<channelfw chainQuiesceTimeout="60s"/>

</server>