2

I can't get the message "hello" when I visit the page.

package jaxrs.ressources;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("greeting")
public class HelloRessource {
    @GET
    @Path("hello")
    @Produces(MediaType.TEXT_PLAIN)
    public String sayhello() {
    return "Hello from JAX-RS";
}}

and this class

package jaxrs.utilities;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationPath("/rest")
public class RestActivator  extends Application{

}

The url http://127.0.0.1:8383/JAXRS_Hello_GL-1.0/rest/greeting/hello always displays "not found"

Is there any solution ?

enter image description here

this is what contains the pom.xml file :

    <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.esprit.jaxrs.hello</groupId>
  <artifactId>JAXRS_Hello_GL</artifactId>
  <version>1.0</version>
  <packaging>war</packaging>

  <properties>
    <failOnMissingWebXml>false</failOnMissingWebXml>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>
  </properties>
  <!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jaxrs -->
<dependencies>

<!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jaxrs -->
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jaxrs</artifactId>
    <version>3.1.4.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jaxrs -->
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-client</artifactId>
    <version>3.1.4.Final</version>
</dependency>

  </dependencies>

</project>

please tell me if you need other clarification

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
aymen0406
  • 127
  • 10

1 Answers1

0

Can you add the initializer:

<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-servlet-initializer</artifactId>
    <version>3.1.4.Final</version>
</dependency>

Mr.Paul have the solution in the comments , please check it

Zain Elabidine
  • 349
  • 5
  • 16