0

I am new in Java and i have a problem with the web service jersey. I created a project web service (project1) and a project abc. When i called the class Calcu in the web service i get an error as: enter image description here

HelloWorldService.java:

import aa.Calcu;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;

@Path("/hello") //Path
public class HelloWorldService {

    @GET
    @Path("/{param}") //parameter
    public Response getMsg(@PathParam("param") String msg) {

        Calcu c=new Calcu();
        String output = "My say : " + msg ;
        output= output + c.Concat("3","2");
        return Response.status(200).entity(output).build();

    }
    }

and 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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>ground1</groupId>
  <artifactId>project1</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>project1 Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <repositories>
        <repository>
            <id>maven2-repository.java.net</id>
            <name>Java.net Repository for Maven</name>
            <url>http://download.java.net/maven/2/</url>
            <layout>default</layout>
        </repository>
    </repositories>

  <dependencies>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-server</artifactId>
        <version>1.8</version>
    </dependency>
  </dependencies>
  <build>
    <finalName>project1</finalName>
  </build>
</project>

Please tell me what is wrong?

MyNguyen
  • 319
  • 4
  • 14
  • Read this to understand the exception: http://stackoverflow.com/questions/34413/why-am-i-getting-a-noclassdeffounderror-in-java – Thorbjørn Ravn Andersen Oct 28 '15 at 10:19
  • It make the project that has the class a Maven project, then add it as a dependency in the pom.xml file of your Jersey project, or Google how to add a jar to a Maven project. This still involves adding it to the pom.xml file. – Paul Samsotha Oct 28 '15 at 11:04
  • @ peeskillet: Thank you very much. I done it. – MyNguyen Oct 29 '15 at 06:36

0 Answers0