Reputation: 1575
I am new to Java EE development. I downloaded Payara micro-server 6.2023.8 and generated a simple Java EE application through the maven archetype com.airhacks:javaee8-essentials-archetype:0.0.4
(https://github.com/AdamBien/javaee8-essentials-archetype).
However, when I deploy the war
file (generated through mvn clean package
) on the server through the command:
java -jar 'G:\Workspace\payara-micro-6.2023.8.jar' --deploy .\target\javaee-demo.war --port 8080
, the REST endpoint (http://localhost:8080/javaee-demo/resources/ping
) is not exposed and generates a 404
error when accessed via a browser. The only URL present in the logged output against 'Payara Micro URLs
' is http://localhost:8080/javaee-demo
.
Here's my resource (generated automatically from the archetype used):
@Path("ping")
public class PingResource {
@Inject
@ConfigProperty(name = "message")
String message;
@GET
public String ping() {
return this.message + " Jakarta EE with MicroProfile 2+!";
}
}
Here's my JAX-RS configuration file:
@ApplicationPath("resources")
public class JAXRSConfiguration extends Application {
}
And, here's the (partial) output of running the above command:
"Deployed": [
{
"Name": "javaee-demo",
"Type": "war",
"Context Root": "/javaee-demo"
}
]
pom.xml
file for reference:
<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>in.mydemoprojects</groupId>
<artifactId>javaee-demo</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>2.0.1</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>javaee-demo</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
</project>
I looked into the other stackoverflow questions about this, but to no avail. Can someone please help me debug?
Upvotes: 1
Views: 577
Reputation: 11
The issue sometimes has to do with your <jta-data-source>
in persistence.xml
if not properly configured, the endpoints will not be exposed.
Try removing it temporarily to see if it helps.
I had the same issue but was able to test my app with the in-memory h2
db.
Upvotes: 0
Reputation: 1
I had the same issue by deploying this simple Java EE application with Payara micro 6.2023.11. The REST end points are not exposed. As a workaround I switched to Payara micro 5.2021.7, ran the same command again and with this version it works.
By the way - I am using OpenJDK 11 - it seems to have nothing to do with the Java version, but that an additional setting and/or annotation is required for Payara micro server 6.2023.11 to make it work with this version too. But since I am also new to programming Java EE and using an application server, I don't know the real reason for the "inconsistency".
Upvotes: 0
Reputation: 107
I meandered my way around this same problem as below. You may want to try it too:
java -version
on command prompt.dependencies
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>3.0.0</version>
</dependency>
Upvotes: 0