5 Replies Latest reply on Mar 31, 2011 11:39 AM by Nick Scavelli

    Deployment of GateIn REST services

    Jacek Bukowski Newbie

      Hi,

      I searched throught the forum, but everywhere there is a recommendation to deploy the REST services as jar file and put it somwhere to be available on classpath. I would prefer to have my REST services deployed in the ear, together with other my application stuff. Is it possible?

      I have added following jar:

       

      {noformat}

      META-INF

      package

          REST_service.class

      conf

          portal

             configuration.xml

      {noformat}

       

      to my EAR, and then added entry in application.xml:

       

      {noformat}

        <module>

          <java>esg-portal-config-jar-1.0.jar</java>

        </module>

      {noformat}

       

      But the REST service is not available. What am I doing wrong? Or maybe it is not possible to deploy REST service this way?

        • 1. Deployment of GateIn REST services
          Giovanni Marigi Newbie

          I tried to deploy a rest service either in a .war archive or in .ear archive. It deploys but the rest service is not registered. The only chance to get it working is to create a .jar archive as you did; I put it in gatein.ear/lib.

           

          Someone did it in a war archive?

           

          Thanks,

          Giovanni

          • 2. Deployment of GateIn REST services
            Minh Hoang TO Novice

            Could you post the configuration and code (annotation part) of your REST service?

            • 3. Deployment of GateIn REST services
              Trong Tran Master

              You could try by configure your war/ear as a portal extension, this only ensures that configuration in your war/ear will be read by Portal Container. BUT i'm not sure if it work totally, i didn't try it though :-)

              • 4. Re: Deployment of GateIn REST services
                Jacek Bukowski Newbie

                Thank you all for the replies.

                 

                @Giovanni, I do also have a feeling that it only works as jar file deployed either to lib directory of the serwer or gatein.ear/lib.

                 

                My configuration.xml in jar with REST service is very simple:

                 

                {noformat}

                <configuration

                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                   xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"

                   xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">

                 

                 

                  <component>

                    <type>t3.examples.restservices.HelloWorldRest</type>

                  </component>

                <configuration>

                {noformat}

                 

                The REST service is also a sample one:

                 

                {noformat}

                @Path( "HelloWorldRest" )

                public class HelloWorldRest implements ResourceContainer {

                 

                    @GET

                    @Path( "/ejbtest" )

                    public Response ejbTest( @Context SecurityContext sc ) {

                        String test = "ERROR";

                        try{

                            javax.naming.Context context = new InitialContext();

                            TestServiceRemote testService = (TestServiceRemote)context.lookup( "app/TestServiceBean/remote" );

                            test = testService.getTest();

                        }catch( NamingException e ){

                            e.printStackTrace();

                        }

                        return Response

                            .ok(

                                "Got from test service: " + test + "<br/>"

                                    + "This method is permitted for all authenticated users, caller principal "

                                    + sc.getUserPrincipal() ).header( HttpHeaders.CACHE_CONTROL, CC ).build();

                    }

                }

                {noformat}

                 

                I tried to deploy it in EAR with my application, as well as in another EAR, where I have only portal (new portal, pages, users, etc.) configuration (I mean it works as portal extension). The deployment succedded, all other stuff worked but REST service was not accessible.

                • 5. Re: Deployment of GateIn REST services
                  Nick Scavelli Novice

                  You can definitely deploy your rest service in an ear file, however pretty sure it needs to be part of an extension like Trong mentioned. 

                   

                  One thing I would do is put a System.out.println in a default constructor of your HelloWorldRest class to see if the container is picking up your class.  If not then there's a classpath issue and the container is not seeing it.  If it is then there's an issue with your rest service or the path you are trying to access it.

                   

                  Try something even simpler:

                   

                   

                  @Path( "HelloWorldRest" )
                  public class HelloWorldRest implements ResourceContainer {
                     @GET
                     public String helloWorld()
                     {
                        return "Hello World !";
                     }
                  }
                  

                   

                  and see what you get by going to http://localhost:8080/rest/HelloWorldRest