Shruti sharma
Shruti sharma

Reputation: 211

Jax rs resources 404 not found errror

I am getting below error while running application in java using jax-rs

HTTP Status 404 – Not Found
Type Status Report 
Message /ajavaeeconcurrency/resources/greetUser
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Apache Tomcat/9.0.30

I am using java8 and trying to create restAPI using jax-rs Below is the code

package com.app.rest;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("resources")

public class JAXRSConfiguration extends Application {

}

Below is resource class

package com.app.rest;

import javax.ws.rs.GET;
import javax.ws.rs.Path;

@Path("/greetUser")
public class GreetResource {
    
    @GET
    public String greetUser()
    {
        return "java EE concurrency starts.";
    }
    

This is my pom.xml

<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>com.mycompany</groupId>
    <artifactId>ajavaeeconcurrency</artifactId>
    <version>0.0.1-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>ajavaeeconcurrency</finalName>
    </build>
    
    <properties>
    
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <failOnMissingWebXml>false</failOnMissingWebXml>
    </properties>
</project>

My artifactId is ajavaeeconcurrency . I am trying to access resource using below URI

GET http://localhost:8080/ajavaeeconcurrency/resources/greetUser

I am getting 404 error. How can I resolve the same

Upvotes: 1

Views: 1504

Answers (1)

Ivan Ivanov
Ivan Ivanov

Reputation: 23

I think your URL is http://localhost:8080/resources/greetUser.

URL with artifactId part usually configuried in application server if it need.

Upvotes: 1

Related Questions