users@glassfish.java.net

RE: Call Constructor of Web Service on Glassfish Container load

From: Vijay Ramachandran <Vijay.Ramachandran_at_Sun.COM>
Date: Wed, 20 Sep 2006 12:55:39 -0700

I just tried with this endpoint listed below and the PostConstruct
method is indeed called as expected. If this does not work for you, then
I will have to look at your sample endpoint that does not work.

If you have access to the glassfish/appserv-tests modules, check this
test for reference :
glassfish/appserv-tests/devtests/webservice/annotations/postconstruct

package endpoint;

import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.annotation.PostConstruct;

@WebService(
    name="Hello",
    serviceName="HelloService",
    targetNamespace="http://example.com/Hello"
)
public class Hello {
        String str = "postconstruct NOT called";

        public Hello() {}

        @PostConstruct
        public void postConstMethod() { str = "postconstruct called"; }

        @WebMethod(operationName="sayHello", action="urn:SayHello")
        public String sayHello(String who) {
                return "WebSvcTest-Hello " + who + " " + str;
        }
}

Vijay

On Wed, 2006-09-20 at 12:28, Patel, Ronak (US SSA) wrote:
> 1. We're using Glassfish-V1 Milestone 7
> 2. Servlet endpoint
> 3. We can put together a sample war that illustrates what we're doing. It's really just a simple endpoint with a no-arg constructor or a @PostConstruct annotated method.
>
> When the war file is first deployed, does the no-arg constructor or @PostConstruct method get called? All we have is a simple endpoint with a no-arg constructor and it does not get called after deployment. Is there something else that needs to be done after deployment?
>
> -----Original Message-----
> From: Vijay Ramachandran [mailto:Vijay.Ramachandran_at_Sun.COM]
> Sent: Wed 09/20/2006 03:15 PM
> To: users_at_glassfish.dev.java.net
> Cc:
> Subject: Re: Call Constructor of Web Service on Glassfish Container load
>
>
>
> This feature should work - if it does not, then it is a bug.
>
> Can you please give us more information :
>
> 1. Are you trying with latest GlassFish-v1 or GlassFish-v2 ?
>
> 2. What kind of endpoint are you using - servlet or EJB ?
>
> 3. Is it possible to mail your sample WAR/JAR ?
>
> Vijay
>
> On Wed, 2006-09-20 at 12:02, Patel, Ronak (US SSA) wrote:
> > Hello all,
> >
> > I just upgraded to the latest Glassfish Milestone build. I am looking for the container to call my no-arg constructor on container load time (i.e. when I start Glassfish).
> >
> > I tried the <load-on-startup> option in the web.xml file and the @postConstruct annotation, but the container fails to call the constructor when Glassfish starts.
> >
> > Is there some thing that I am not doing correctly? Is this feature currently supported in Glassfish?
> >
> > Any help would be greatly appreciated,
> >
> > Ronak Patel
> >
> > Software Engineer; BAE Systems
> >
> > ronak.patel_at_baesystems.com
> >
> >
> > ______________________________________________________________________
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> > For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
>