Results 1 to 3 of 3
  1. #1
    saadm is offline Member
    Join Date
    Dec 2013
    Posts
    4
    Rep Power
    0

    Default Trouble starting Jersey based Web-Service

    Hi,
    I have created a REST Jersey based web-service. I have followed tutorials and have added the references to the appropriate jar files.

    Here is my code:

    package com.gwabbit.service;

    import javax.ws.rs.GET;
    import javax.ws.rs.Path;
    import javax.ws.rs.Produces;
    import java.util.regex.*;

    @Path("/EmailService")
    public class RESTEmailService {

    @Path("/parseEmail")
    @GET
    @Produces("application/json")
    public String parseEmail(String email) {
    }

    Here is my web.xml file.

    <web-app id="WebApp_ID" version="2.4"
    xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>Restful Web Application</display-name>

    <servlet>
    <servlet-name>jersey-servlet</servlet-name>
    <servlet-class>
    com.sun.jersey.spi.container.servlet.ServletContai ner
    </servlet-class>
    <init-param>
    <param-name>com.sun.jersey.config.property.packages</param-name>
    <param-value>com.mkyong.rest</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
    <servlet-name>jersey-servlet</servlet-name>
    <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>

    </web-app>



    When I run this within Eclipse with Tomcat 8.0 as the server with this url:

    http://localhost:8080/rest/EmailService/parseEmail/test

    I get the Http 404 resource not found error.

    Can someone please help with this?

    Thanks,



    Saad

  2. #2
    saadm is offline Member
    Join Date
    Dec 2013
    Posts
    4
    Rep Power
    0

    Default Re: Trouble starting Jersey based Web-Service

    One more thing.

    I am getting this error:

    Unable to process Jar entry [module-info.class] from Jar [file:/C:/Eclipseworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/ProgrammingExcercise3/WEB-INF/lib/javax.json-1.1.jar] for annotations
    org.apache.tomcat.util.bcel.classfile.ClassFormatE xception: Invalid byte tag in constant pool: 19

    on files

    [file:/C:/Eclipseworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/ProgrammingExcercise3/WEB-INF/lib/javax.json-1.1.jar]
    [file:/C:/Eclipseworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/ProgrammingExcercise3/WEB-INF/lib/yasson-1.0.jar
    [file:/C:/Eclipseworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/ProgrammingExcercise3/WEB-INF/lib/javax.json-api-1.1.jar] for annotations

    but I don't even have a reference to the javax.json-1.1.jar and javax.json-api-1.1.jar in my project.

    I cleaned the Tomcat server and re-started it. Now, I get these messages in the console.


    SEVERE: StandardWrapper.Throwable
    java.lang.NoClassDefFoundError: javax/json/bind/JsonbException
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Unknown Source)





    Saad


    Quote Originally Posted by saadm View Post
    Hi,
    I have created a REST Jersey based web-service. I have followed tutorials and have added the references to the appropriate jar files.

    Here is my code:

    package com.gwabbit.service;

    import javax.ws.rs.GET;
    import javax.ws.rs.Path;
    import javax.ws.rs.Produces;
    import java.util.regex.*;

    @Path("/EmailService")
    public class RESTEmailService {

    @Path("/parseEmail")
    @GET
    @Produces("application/json")
    public String parseEmail(String email) {
    }

    Here is my web.xml file.

    <web-app id="WebApp_ID" version="2.4"
    xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>Restful Web Application</display-name>

    <servlet>
    <servlet-name>jersey-servlet</servlet-name>
    <servlet-class>
    com.sun.jersey.spi.container.servlet.ServletContai ner
    </servlet-class>
    <init-param>
    <param-name>com.sun.jersey.config.property.packages</param-name>
    <param-value>com.mkyong.rest</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
    <servlet-name>jersey-servlet</servlet-name>
    <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>

    </web-app>



    When I run this within Eclipse with Tomcat 8.0 as the server with this url:

    http://localhost:8080/rest/EmailService/parseEmail/test

    I get the Http 404 resource not found error.

    Can someone please help with this?

    Thanks,



    Saad

  3. #3
    saadm is offline Member
    Join Date
    Dec 2013
    Posts
    4
    Rep Power
    0

    Default Re: Trouble starting Jersey based Web-Service

    Ok, now I have deployed the war file on Tomcat and am making a GET request to the service using Postman.

    I get the following error:

    Hi,

    I have a simple REST based web-service that is returning JSON data as String. When I deploy the web-service on Tomcat and make a GET request using Postman, I get the following error:



    java.lang.NoClassDefFoundError: javax/json/bind/JsonbException



    Does any one have any ideas on how to solve this error?




    Saad

Similar Threads

  1. Replies: 1
    Last Post: 12-16-2016, 09:19 AM
  2. Replies: 16
    Last Post: 08-09-2013, 12:02 PM
  3. how to call service method inside another service
    By kirtichopra2003 in forum Web Frameworks
    Replies: 1
    Last Post: 10-24-2009, 02:19 AM
  4. (Location based Service) application for Pocket PC
    By talk_to_vivekmishra in forum CLDC and MIDP
    Replies: 0
    Last Post: 08-14-2007, 08:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •