Skip to content

Commit

Permalink
Updated by github actions from guide-jpa-intro (#3280)
Browse files Browse the repository at this point in the history
Co-authored-by: GuidesBot <GuidesBot@OpenLiberty.io>
  • Loading branch information
GuidesBot and GuidesBot authored Aug 30, 2024
1 parent c3d07ca commit 46e1594
Showing 1 changed file with 164 additions and 5 deletions.
169 changes: 164 additions & 5 deletions instructions/cloud-hosted-guide-jpa-intro/instructions.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
---
markdown-version: v1
title: instructions
branch: lab-447-instruction
version-history-start-date: 2021-12-02 17:23:03 UTC
tool-type: theia
---
::page{title="Welcome to the Accessing and persisting data in microservices using Java Persistence API (JPA) guide!"}
Expand Down Expand Up @@ -430,12 +427,174 @@ The DAO is injected into the ***backendServices/src/main/java/io/openliberty/gui



::page{title="Configuring the Derby driver and the Liberty Maven plugin"}

To use a Derby database, you need to download its libraries and store them to the Liberty shared resources directory. Configure the Liberty Maven plug-in in the ***pom.xml*** file of the ***backendServices*** service.

Replace the ***backendServices/pom.xml*** configuration file.

> To open the pom.xml file in your IDE, select
> **File** > **Open** > guide-jpa-intro/start/backendServices/pom.xml, or click the following button
::openFile{path="/home/project/guide-jpa-intro/start/backendServices/pom.xml"}



```xml
<?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.guides</groupId>
<artifactId>backendServices</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<!-- Liberty configuration -->
<backend.service.http.port>5050</backend.service.http.port>
<backend.service.https.port>5051</backend.service.https.port>
</properties>

<dependencies>
<!-- Provided dependencies -->
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-web-api</artifactId>
<version>10.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>6.1</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<!-- For tests -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.10.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>6.2.9.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-json-binding-provider</artifactId>
<version>6.2.9.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>jakarta.json</artifactId>
<version>2.0.1</version>
<scope>test</scope>
</dependency>
<!-- Derby from https://mvnrepository.com/artifact/org.apache.derby/derby -->
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.17.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyshared</artifactId>
<version>10.17.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbytools</artifactId>
<version>10.17.1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.4.0</version>
</plugin>
<!-- Enable liberty-maven plugin -->
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>3.10.3</version>
<configuration>
<copyDependencies>
<location>${project.build.directory}/liberty/wlp/usr/shared/resources</location>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyshared</artifactId>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbytools</artifactId>
</dependency>
</copyDependencies>
</configuration>
</plugin>
<!-- Plugin to run unit tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<!-- Plugin to run integration tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<systemPropertyVariables>
<backend.http.port>${backend.service.http.port}</backend.http.port>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</project>
```




This configuration adds three required Derby dependencies to the ***dependencies*** configuration so Maven can download the Derby libraries locally. The ***copyDependencies*** configuration instructs the Liberty Maven plug-in to copy the Derby libraries to the Liberty shared resources directory that is specified through the ***location*** configuration, and is referenced in the ***derbyJDBCLib*** ***library*** configuration of the ***server.xml*** file.

In the terminal where you started the ***backendServices*** microservice, type ***r*** and press the ***enter/return*** key to restart the Liberty instance and pick up the Derby libraries.



::page{title="Running the application"}

You started the Open Liberty in dev mode at the beginning of the guide, so all the changes were automatically picked up.
After you see the following message, your Liberty instance is ready in dev mode:

```
**************************************************************
* Liberty is running in dev mode.
```


When Liberty is running, click the following button to view the Event Manager application:
Click the following button to view the Event Manager application:
::startApplication{port="9090" display="external" name="Visit Event Manager application" route="/"}

Click ***Create Event*** in the left navigation bar to create events that are persisted to the database. After you create an event, it is available to view, update, and delete in the ***Current Events*** section.
Expand Down

0 comments on commit 46e1594

Please sign in to comment.