axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "robert lazarski" <robertlazar...@gmail.com>
Subject Re: ServiceLifeCycle changes
Date Thu, 19 Oct 2006 12:17:30 GMT
I personally don't need ConfigurationContext ... as you can see from
the code below, its ignored.

public void startUp(ConfigurationContext ignore, AxisService service) {

        System.out.println("Starting spring init");
        ClassLoader classLoader = service.getClassLoader();
        ClassPathXmlApplicationContext appCtx = new
        ClassPathXmlApplicationContext(new String[]
{"applicationContext.xml"}, false);
            appCtx.setClassLoader(classLoader);
            appCtx.refresh();
        if (logger.isDebugEnabled()) {
            logger.debug("\n\nstartUp() set spring classloader via
axisService.getClassLoader() ... ");
        }
        System.out.println("spring loaded");
    }

Now of course someone might need ConfigurationContext. Can you think
of an easy way to solve both cases, ie, startUp() called from
ServiceBuilder that does not have ConfigurationContext, and startUp()
- overloaded or another interface, etc - that includes
ConfigurationContext ?

Thanks for the help, much appreciated,
Robert

On 10/18/06, Deepal Jayasinghe <deepal@opensource.lk> wrote:
> Hi Robert;
>
> The only place that I can call startUp method is at the deployment
> engine, I can modify the code to call startUp method at the
> ServiceBuilder level. But the problem is that does not have access to
> configuration context.
>
> robert lazarski wrote:
>
> > Tried the two services in a service group idea, but unfortunately, the
> > MR is invoked before startUp() in seemingly all cases. So it loads the
> > MR and throws an exception, next startUp() loads the config, and then
> > subsequent calls will work. Still, we'd rather not have an exception
> > on start up.
> >
> > Thanks,
> > Robert
> >
> > On 10/15/06, robert lazarski <robertlazarski@gmail.com> wrote:
> >
> >> OK, I can now get startUp() to work, thanks. But startUp() happens
> >> _after_ the MR is processed. Why is that?
> >>
> >> The use case is this: startUp() inits a dependancy that the MR will
> >> need. The way it is now, the MR will throw because startUp() is called
> >> after the MR is processed.
> >>
> >> One work around I suppose is two have two services in one
> >> ServiceGroup, one that does nothing but have startUp() , and the other
> >> that uses the MR. I don't think that is really the right solution
> >> though.
> >>
> >> Thanks for working with me on this. Here's my stacktrace that shows
> >> the problem. Notice the
> >>  'Starting spring init' after the exception, which is a print
> >> statement in the first line in startUp(). Also I want to clarify what
> >> I'm trying to do here is a user space way to load spring inside an AAR
> >> - it has nothing to do with the Spring code inside Axis2 which is
> >> working fine.
> >>
> >> 2006-10-15 12:59:59,027 [org.apache.axis2.deployment.ServiceBuilder] -
> >> Error in schema generating null
> >> java.lang.reflect.InvocationTargetException
> >>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >>         at
> >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> >>
> >>         at
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >>
> >>         at java.lang.reflect.Method.invoke(Method.java:585)
> >>         at
> >> org.apache.axis2.deployment.util.Utils.fillAxisService(Utils.java:248)
> >>         at
> >> org.apache.axis2.deployment.ServiceBuilder.populateService(ServiceBuilder.java:266)
> >>
> >>         at
> >> org.apache.axis2.deployment.ServiceGroupBuilder.populateServiceGroup(ServiceGroupBuilder.java:91)
> >>
> >>         at
> >> org.apache.axis2.deployment.repository.util.ArchiveReader.buildServiceGroup(ArchiveReader.java:83)
> >>
> >>         at
> >> org.apache.axis2.deployment.repository.util.ArchiveReader.processServiceGroup(ArchiveReader.java:117)
> >>
> >>         at
> >> org.apache.axis2.deployment.DeploymentEngine.doDeploy(DeploymentEngine.java:533)
> >>
> >>         at
> >> org.apache.axis2.deployment.repository.util.WSInfoList.update(WSInfoList.java:200)
> >>
> >>         at
> >> org.apache.axis2.deployment.RepositoryListener.update(RepositoryListener.java:210)
> >>
> >>         at
> >> org.apache.axis2.deployment.RepositoryListener.checkServices(RepositoryListener.java:157)
> >>
> >>         at
> >> org.apache.axis2.deployment.DeploymentEngine.loadServices(DeploymentEngine.java:84)
> >>
> >>         at
> >> org.apache.axis2.deployment.WarBasedAxisConfigurator.loadServices(WarBasedAxisConfigurator.java:256)
> >>
> >>         at
> >> org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:72)
> >>
> >>         at
> >> org.apache.axis2.transport.http.AxisServlet.initConfigContext(AxisServlet.java:359)
> >>
> >>         at
> >> org.apache.axis2.transport.http.AxisServlet.init(AxisServlet.java:304)
> >>         at
> >> org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)
> >>
> >>         at
> >> org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:932)
> >>         at
> >> org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3917)
> >>
> >>         at
> >> org.apache.catalina.core.StandardContext.start(StandardContext.java:4201)
> >>
> >>         at
> >> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
> >>
> >>         at
> >> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
> >>         at
> >> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
> >>         at
> >> org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:809)
> >>         at
> >> org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:698)
> >>         at
> >> org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472)
> >>         at
> >> org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)
> >>         at
> >> org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
> >>
> >>         at
> >> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
> >>
> >>         at
> >> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)
> >>         at
> >> org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
> >>         at
> >> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
> >>         at
> >> org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
> >>         at
> >> org.apache.catalina.core.StandardService.start(StandardService.java:450)
> >>         at
> >> org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
> >>         at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
> >>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >>         at
> >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> >>
> >>         at
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >>
> >>         at java.lang.reflect.Method.invoke(Method.java:585)
> >>         at
> >> org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
> >>         at
> >> org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
> >> Caused by: org.apache.axis2.AxisFault: Axis2 Can't find Spring's
> >> ApplicationContext; nested exception is:
> >>         java.lang.Exception: Axis2 Can't find Spring's
> >> ApplicationContext
> >>         at org.apache.axis2.AxisFault.makeFault(AxisFault.java:318)
> >>         at
> >> org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier.getServiceObject(SpringAppContextAwareObjectSupplier.java:61)
> >>
> >>         ... 44 more
> >> Caused by: java.lang.Exception: Axis2 Can't find Spring's
> >> ApplicationContext
> >>         at
> >> org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier.getServiceObject(SpringAppContextAwareObjectSupplier.java:51)
> >>
> >>         ... 44 more
> >> Starting spring init
> >>
> >> On 10/14/06, Deepal Jayasinghe <deepal@opensource.lk> wrote:
> >> > your services.xml should look like below;
> >> >
> >> > <service name="SampleService3"
> >> >          class="org.apachecon.us.sample.ServiceLifeCycleImpl">
> >> >     <parameter name="ServiceClass" locked="false">
> >> >         org.apachecon.us.sample.SampleService3</parameter>
> >> > </service>
> >> >
> >> > robert lazarski wrote:
> >> >
> >> > > Hi all,
> >> > >
> >> > > I'm trying to test the latest svn with spring inside the aar via
> >> > > startUp() . This was working a few days ago with startUp() in the
> >> > > Service interface. Anyways, ServiceLifeCycle seems to work by
> >> > > reflection so I have a services.xml like so:
> >> > >
> >> > > <serviceGroup>
> >> > >  <service name="SpringInit">
> >> > >    <description>
> >> > >        This is a sample spring init service
> >> > >    </description>
> >> > >    <parameter name="ServiceClass"
> >> > > locked="false">spring.SpringInit</parameter>
> >> > >    <operation name="springInit">
> >> > >        <messageReceiver
> >> > > class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
> >> > >    </operation>
> >> > >  </service>
> >> > >  <service name="SpringAwareService">
> >> > >    <description>
> >> > >         simple spring example - inside the AAR
> >> > >    </description>
> >> > >    <!-- need the TCCL param when using spring inside the AAR -->
> >> > >    <parameter name="ServiceTCCL"
> >> locked="false">composite</parameter>
> >> > >    <parameter name="ServiceObjectSupplier"
> >> > >
> >> locked="false">org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier</parameter>
> >>
> >> > >
> >> > >    <parameter name="SpringBeanName"
> >> > > locked="false">springAwareService</parameter>
> >> > >    <operation name="getValue">
> >> > >        <messageReceiver
> >> > > class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
> >> > >    </operation>
> >> > >  </service>
> >> > > </serviceGroup>
> >> > >
> >> > > So the idea is that spring.SpringInit implements ServiceLifeCycle
> >> and
> >> > > will load the spring config via startUp() . And not until a client
> >> > > invokation the MR of SpringAwareService will be called.
> >> > >
> >> > > What I'm seeing though is the SpringAwareService MR is being
> >> called on
> >> > > server start, even though I have not declared any scope. And
> >> > > ServiceLifeCycle.startUp() is not called ever. The MR was never
> >> > > invoked on server start before with the default scope IIRC. This is
> >> > > generating a stack trace on server start as :
> >> > >
> >> > > 2006-10-13 15:07:00,997
> >> [org.apache.axis2.deployment.ServiceBuilder] -
> >> > > Error in schema generating null
> >> > > java.lang.reflect.InvocationTargetException
> >> > >     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >> > >     at
> >> > >
> >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> >>
> >> > >
> >> > >     at
> >> > >
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >>
> >> > >
> >> > >     at java.lang.reflect.Method.invoke(Method.java:585)
> >> > >     at
> >> > >
> >> org.apache.axis2.deployment.util.Utils.fillAxisService(Utils.java:243)
> >> > >     at
> >> > >
> >> org.apache.axis2.deployment.ServiceBuilder.populateService(ServiceBuilder.java:266)
> >>
> >> > >
> >> > >     at
> >> > >
> >> org.apache.axis2.deployment.ServiceGroupBuilder.populateServiceGroup(ServiceGroupBuilder.java:91)
> >>
> >> > >
> >> > >     at
> >> > >
> >> org.apache.axis2.deployment.repository.util.ArchiveReader.buildServiceGroup(ArchiveReader.java:83)
> >>
> >> > >
> >> > >     at
> >> > >
> >> org.apache.axis2.deployment.repository.util.ArchiveReader.processServiceGroup(ArchiveReader.java:117)
> >>
> >> > >
> >> > >     at
> >> > >
> >> org.apache.axis2.deployment.DeploymentEngine.doDeploy(DeploymentEngine.java:533)
> >>
> >> > >
> >> > >     at
> >> > >
> >> org.apache.axis2.deployment.repository.util.WSInfoList.update(WSInfoList.java:200)
> >>
> >> > >
> >> > >     at
> >> > >
> >> org.apache.axis2.deployment.RepositoryListener.update(RepositoryListener.java:210)
> >>
> >> > >
> >> > >     at
> >> > >
> >> org.apache.axis2.deployment.RepositoryListener.checkServices(RepositoryListener.java:157)
> >>
> >> > >
> >> > >     at
> >> > >
> >> org.apache.axis2.deployment.DeploymentEngine.loadServices(DeploymentEngine.java:84)
> >>
> >> > >
> >> > >     at
> >> > >
> >> org.apache.axis2.deployment.WarBasedAxisConfigurator.loadServices(WarBasedAxisConfigurator.java:252)
> >>
> >> > >
> >> > >     at
> >> > >
> >> org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:72)
> >>
> >> > >
> >> > >     at
> >> > >
> >> org.apache.axis2.transport.http.AxisServlet.initConfigContext(AxisServlet.java:359)
> >>
> >> > >
> >> > >     at
> >> > >
> >> org.apache.axis2.transport.http.AxisServlet.init(AxisServlet.java:304)
> >> > >     at
> >> > >
> >> org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
> >>
> >> > >
> >> > >     at
> >> > >
> >> org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:925)
> >> > >     at
> >> > >
> >> org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3880)
> >>
> >> > >
> >> > >     at
> >> > >
> >> org.apache.catalina.core.StandardContext.start(StandardContext.java:4141)
> >>
> >> > >     at
> >> > >
> >> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
> >>
> >> > >
> >> > >     at
> >> > >
> >> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
> >> > >     at
> >> > >
> >> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
> >> > >     at
> >> > >
> >> org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:804)
> >> > >     at
> >> > >
> >> org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:693)
> >> > >     at
> >> > >
> >> org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472)
> >> > >     at
> >> org.apache.catalina.startup.HostConfig.start(HostConfig.java:1118)
> >> > >     at
> >> > >
> >> org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
> >>
> >> > >
> >> > >     at
> >> > >
> >> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
> >>
> >> > >
> >> > >     at
> >> > >
> >> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
> >> > >     at
> >> org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
> >> > >     at
> >> > >
> >> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
> >> > >     at
> >> > >
> >> org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
> >> > >     at
> >> > >
> >> org.apache.catalina.core.StandardService.start(StandardService.java:450)
> >> > >     at
> >> > >
> >> org.apache.catalina.core.StandardServer.start(StandardServer.java:680)
> >> > >     at org.apache.catalina.startup.Catalina.start(Catalina.java:536)
> >> > >     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >> > >     at
> >> > >
> >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> >>
> >> > >
> >> > >     at
> >> > >
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >>
> >> > >
> >> > >     at java.lang.reflect.Method.invoke(Method.java:585)
> >> > >     at
> >> org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:275)
> >> > >     at
> >> org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
> >> > > Caused by: org.apache.axis2.AxisFault: Axis2 Can't find Spring's
> >> > > ApplicationContext; nested exception is:
> >> > >     java.lang.Exception: Axis2 Can't find Spring's
> >> ApplicationContext
> >> > >     at org.apache.axis2.AxisFault.makeFault(AxisFault.java:318)
> >> > >     at
> >> > >
> >> org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier.getServiceObject(SpringAppContextAwareObjectSupplier.java:61)
> >>
> >> > >
> >> > >     ... 44 more
> >> > > Caused by: java.lang.Exception: Axis2 Can't find Spring's
> >> > > ApplicationContext
> >> > >     at
> >> > >
> >> org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier.getServiceObject(SpringAppContextAwareObjectSupplier.java:51)
> >>
> >> > >
> >> > >     ... 44 more
> >> > >
> >> > > Any ideas ?
> >> > > Robert
> >> > >
> >> > >
> >> ---------------------------------------------------------------------
> >> > > To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> >> > > For additional commands, e-mail: axis-dev-help@ws.apache.org
> >> > >
> >> > >
> >> > >
> >> >
> >> > --
> >> > Thanks,
> >> > Deepal
> >> > ................................................................
> >> > ~Future is Open~
> >> >
> >> >
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> >> > For additional commands, e-mail: axis-dev-help@ws.apache.org
> >> >
> >> >
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-dev-help@ws.apache.org
> >
> >
> >
>
> --
> Thanks,
> Deepal
> ................................................................
> ~Future is Open~
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Mime
View raw message