1

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?

Python_user
  • 1,378
  • 3
  • 12
  • 25

1 Answers1

0

I meandered my way around this same problem as below. You may want to try it too:

  1. Use jdk-1.8, confirm this by running the command java -version on command prompt.
  2. If the command returns a different version, then: 2.1. download and install jdk-1.8. 2.2. go to the bin folder created as a result of the installation. 2.3. copy at least (and perhaps, javac, javaw) the file "java.exe" and paste it in the folder (let's call it "folderA") where java looks for executables. 2.4. on my windows machine, the "folderA" is in "C:\Program Files\Common Files\Oracle\Java\javapath". 2.5 run the command in #2 above again, ensure Jdk-1.8.xxx is returned.
  3. Download Payara Microedition 5.181 (not version 6.0) from here: https://jar-download.com/artifacts/fish.payara.extras/payara-micro/5.181/source-code
  4. In your POM file, add the following dependencies:

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>
  1. Attempt to deploy your app on payara again, it should work. There's probably a better solution out there though.
adoughdough
  • 107
  • 1
  • 4