CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2014
    Posts
    1

    Need help running java restful web service as a Linux service

    I have /etc/init.d/calc created to launch Calculator restful web service application;
    When calc run as linux service I'm getting NullPointerException, but when I launch application from a command line, it works great.

    Please could you tell me what I need to verify to address this issue.

    The Calculator application code can be found at
    http://theopentutorials.com/examples...jersey-jax-rs/.


    #!/bin/sh
    # chkconfig: 35 99 99
    # description : calc service script

    # Source function library.
    . /etc/init.d/functions
    . /etc/profile

    start()
    {
    $APP_HOME/bin/calc --start &
    }

    stop()
    {
    $APP_HOME/bin/calc --stop
    }

    status()
    {
    $APP_HOME/bin/calc --status
    }

    case "$1" in
    start)
    start
    ;;
    stop)
    stop
    ;;
    restart)
    stop
    start
    ;;
    status)
    status
    ;;
    *)
    echo $"Usage: $0 {start|stop|restart|status}"

    esac
    exit 0



    Here is the output

    Jun 11, 2014 4:18:07 PM com.sun.jersey.api.core.ClasspathResourceConfig init
    INFO: Scanning for root resource and provider classes in the paths:
    .
    /home/calc/jars/jettison-1.1.jar
    /home/calc/jars/commons-lang3-3.3.1.jar
    /home/calc/jars/jersey-core-1.18.jar
    /home/calc/jars/jersey-server-1.18.jar
    /home/calc/jars/commons-cli-1.2.jar
    /home/calc/jars/calc-utils.jar
    /home/calc/jars/jsr311-api-1.1.1.jar
    /home/calc/jars/log4j-1.2.16.jar
    /home/calc/jars/jackson-core-asl-1.9.2.jar
    /home/calc/jars/jackson-mapper-asl-1.9.2.jar
    /home/calc/jars/jersey-servlet-1.18.jar
    /home/calc/jars/jersey-json-1.18.jar
    /home/calc/jars/logback-core-1.1.1.jar
    /home/calc/jars/commons-collections-3.2.1.jar
    /home/calc/jars/logback-classic-1.1.1.jar
    /home/calc/jars/http-2.2.1.jar
    /home/calc/jars/jackson-jaxrs-1.9.2.jar
    /home/calc/jars/jersey-client-1.18.jar
    /home/calc/jars/asm-3.1.jar
    /home/calc/jars/jackson-xc-1.9.2.jar
    /home/calc/jars/slf4j-api-1.7.6.jar
    Exception in thread "main" java.lang.NullPointerException
    at com.sun.jersey.core.spi.scanning.FilesScanner.scanDir(FilesScanner.java:93)
    at com.sun.jersey.core.spi.scanning.FilesScanner.scanDir(FilesScanner.java:95)
    at com.sun.jersey.core.spi.scanning.FilesScanner.scanDir(FilesScanner.java:95)
    at com.sun.jersey.core.spi.scanning.FilesScanner.scan(FilesScanner.java:80)
    at com.sun.jersey.core.spi.scanning.FilesScanner.scan(FilesScanner.java:74)
    at com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:80)
    at com.sun.jersey.api.core.ClasspathResourceConfig.init(ClasspathResourceConfig.java:119)
    at com.sun.jersey.api.core.ClasspathResourceConfig.<init>(ClasspathResourceConfig.java:101)
    at com.sun.jersey.api.container.ContainerFactory.createContainer(ContainerFactory.java:263)
    at com.sun.jersey.api.container.ContainerFactory.createContainer(ContainerFactory.java:246)
    at com.sun.jersey.api.container.httpserver.HttpServerFactory.create(HttpServerFactory.java:117)
    at com.sun.jersey.api.container.httpserver.HttpServerFactory.create(HttpServerFactory.java:92)
    at com.utils.Config.CalcRESTStartUp.main(Unknown Source)


    Thanks,

  2. #2
    Join Date
    Jul 2005
    Location
    Currently in Mexico City
    Posts
    568

    Re: Need help running java restful web service as a Linux service

    Have you tried publishing the web service on some java server (Tomcat for ex.) and run this server as a Linux service?
    Wanna install linux on a vacuum cleaner. Could anyone tell me which distro sucks better?

    I had a nightmare last night. I was dreaming that I’m 64-bit and my blanket is 32-bit and I couldn’t cover myself with it, so I’ve spent the whole night freezing. And in the morning I find that my blanket just had fallen off the bed. =S (from: bash.org.ru)

    //always looking for job opportunities in AU/NZ/US/CA/Europe :P
    willCodeForFood(Arrays.asList("Java","PHP","C++","bash","Assembler","XML","XHTML","CSS","JS","PL/SQL"));

    USE [code] TAGS! Read this FAQ if you are new here. If this post was helpful, please rate it!

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured