users@jersey.java.net

Re: complete dependency list in docs/dependencies for 0.5

From: Konstantin Rekk <konstantin.rekk_at_gbv.de>
Date: Mon, 28 Jan 2008 14:17:11 +0100

Hi Paul,

here is the project structure which I used (to start playing with a
technology I like to
have plain projects not clouded by extras to understand what's really
going on , though normally I would use ant or maven for that ;-) ):

compilation works fine without asm-3.1.jar in common/libs , running
not ... putting it there makes it work.

------------------------------------------

Here ist the dir-structure:

|-- common
| |-- LIBS_README.txt
| |-- libs
| | |-- asm-3.1.jar
| | |-- build_a_jar.jar
| | |-- javaee.jar
| | |-- jersey.jar
| | |-- jsr311-api.jar
| | `-- junit-4.4.jar

|-- rest_light
| |-- README.txt
| |-- build
| | |-- classes
| | `-- test-classes
| |-- clean.sh
| |-- compile.sh
| |-- run_main.sh
| |-- settings.env
| |-- src
| | `-- de
| | `-- gbv
| | `-- examples
| | `-- restlight
| | |-- Main.java
| | `-- resources
| | `-- HelloWorldResource.java

-----------------------------------------------------

Code:

compile.sh:
#!/bin/bash
#
# Compile from root dir
 settings.env

SRC="src/de/gbv/examples/$PACKAGE_NAME/*.java"
SRC1=""src/de/gbv/examples/$PACKAGE_NAME/resources/*.java""

echo "Compiling classes $SRC ."
javac
-cp ../common/libs/*:scr/de/gbv/examples/$PACKAGE_NAME/:scr/de/gbv/examples/$PACKAGE_NAME/resources/ -verbose -encoding UTF-8 $SRC $SRC1 -d build/classes

-------------------

run_main.sh:
#!/bin/bash
 settings.env

java -cp ../common/libs/*:./build/classes/
de.gbv.examples.$PACKAGE_NAME.Main

------------------------------

Main.java
package de.gbv.examples.restlight;

import com.sun.net.httpserver.HttpServer;
import com.sun.ws.rest.api.container.httpserver.HttpServerFactory;
import java.io.IOException;

/**
 * Class to run
 */
public class Main {

    public static void main(String[] args) throws IOException {

        HttpServer server =
HttpServerFactory.create("http://localhost:9998/");
        server.start();
        System.out.println("Server running");
        System.out.println("Visit: http://localhost:9998/helloworld");
        System.out.println("Hit return to stop...");
        System.in.read();
        System.out.println("Stopping server");
        server.stop(0);
        System.out.println("Server stopped");
        
    }

  
}

----------------------------

HelloWorldResource.java:

package de.gbv.examples.restlight.resources;

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

@Path("/helloworld")
public class HelloWorldResource {

    // react on GET
    @GET
    @ProduceMime("text/plain")
    public String getMessage() {
        return "Hello World from restlight.resources.HelloWorldResource!";
    }
}

Best!

On Mon, 2008-01-28 at 13:29 +0100, Paul Sandoz wrote:
> Konstantin Rekk wrote:
> > On Mon, 2008-01-28 at 11:37 +0100, Paul Sandoz wrote:
> >> Was this an issue after you installed Jersey onto GF? or when using
> >> the
> >> distribution directly?
> >
> > I used it directly with Lightweight Server (Java 6 SE).
> > No whistles and bells, just java, javac from commandline and
> > -cp setting.
> >
>
> Did you compile the example from here:
>
> jersey-0.5-ea/examples/HelloWorld
>
> or here:
>
> glassfish/jersey/examples/HelloWorld
>
> If the former then i don't know what the issue is. I have verified that
> in the Jersey 0.5 stable distribution the dependency documentation is up
> to date and the example compiles/runs.
>
> If the latter, I am wondering if there is some mix up between Jersey
> versions installed to GF.
>
> Paul.
>
-- 
Konstantin Rekk
VZG (GBV), Göttingen, Berlin
0176 2100 6000
030 29003511
skype: krekk1970 
rekk_at_gbv.de
http://www.gbv.de