Announcement Announcement Module
Collapse
No announcement yet.
lazy initialization not working with Struts and EJB client Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • lazy initialization not working with Struts and EJB client

    I am using WebLogic and Struts together with spring to access two EJBs on the network. The problem is, even if I specified lazy-init="true" for all the beans, as seen in the stack trace, if one of the ejb at t3://142.178.100.139:20101 is not available, I can't not even use the other ejb at iiop://142.178.34.135:19099 by using delegate bean. The stack trace provide here is a result of deploying this web application when one of the EJB is down. The same error is also found when when calling delegate.xxxMethod() where deployement was successful but the EJB was down later on.

    Attached spring bean definition file.

    ####<Aug 11, 2005 4:21:18 PM MDT> <Info> <HTTP> <ivrlab04.ent.agt.ab.ca> <SIT> <Thread-454> <kernel identity> <>
    <101047> <[ServletContext(id=4710613,name=PayNow,context-path=/PayNow)] WebServiceServlet: init>
    ####<Aug 11, 2005 4:21:18 PM MDT> <Info> <HTTP> <ivrlab04.ent.agt.ab.ca> <SIT> <Thread-454> <kernel identity> <>
    <101047> <[ServletContext(id=4710613,name=PayNow,context-path=/PayNow)] action: init>
    ####<Aug 11, 2005 4:21:19 PM MDT> <Info> <HTTP> <ivrlab04.ent.agt.ab.ca> <SIT> <Thread-454> <kernel identity> <>
    <101047> <[ServletContext(id=4710613,name=PayNow,context-path=/PayNow)] Initializing WebApplicationContext for St
    ruts ActionServlet 'action', module ''>
    ##PEM 2005.08.11-16:21:20 ivrlab04.ent.agt.ab.ca UNTITLED INFO com.telus.ccs.delegate.aspect.Tracing [ -1 >>>>Ent
    ering com.telus.ccs.delegate.adapter.OldStackAdapter.set OldStackBackendService(IOR:0000000000000031524d493 a636f6d
    2e74656c75732e6976722e4976724d616e61676572456a623a 30303030303030303030303030303030000000000000 ] 0010000000000000
    0c8000101000000000f3134322e3137382e33342e313335000 0ae6d0000000000814a4d4249000000121bde3447663165356 5333632323730
    3030303030000000240000005d49454a5001000a415450726f 6a656374731544656661756c7420454a4220436f6e7461696e 657200000032a
    cac0002000101270000004956524265616e732349565242656 16e735f315f332e6a6172234976724d616e61676572456a620 0000000000001
    00000001000000180000000000010001000000010001002000 01010000000000)
    ##PEM 2005.08.11-16:21:20 ivrlab04.ent.agt.ab.ca UNTITLED INFO com.telus.ccs.delegate.aspect.Tracing [ -1 <<<<Exi
    ting com.telus.ccs.delegate.adapter.OldStackAdapter.set OldStackBackendService() null ]
    ####<Aug 11, 2005 4:21:21 PM MDT> <Warning> <RJVM> <ivrlab04.ent.agt.ab.ca> <SIT> <Thread-454> <kernel identity>
    <> <000519> <Unable to connect to a remote server on address 142.178.100.139 and port 20101 with protocol t3. The
    Exception is java.net.ConnectException: Connection refused>
    ##PEM Context initialization failed
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '/action/makePayment' defi
    ned in ServletContext resource [/WEB-INF/web-spring.xml]: Can't resolve reference to bean 'delegate' while settin
    g property 'delegate'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creatin
    g bean with name 'delegate' defined in ServletContext resource [/WEB-INF/web-spring.xml]: Can't resolve reference
    to bean 'payNowService' while setting property 'payNowService'; nested exception is org.springframework.beans.fa
    ctory.BeanCreationException: Error creating bean with name 'payNowService' defined in ServletContext resource [/W
    EB-INF/web-spring.xml]: Can't resolve reference to bean 'newStackService' while setting property 'newStackService
    '; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'ne
    wStackService' defined in ServletContext resource [/WEB-INF/web-spring.xml]: Can't resolve reference to bean 'new
    StackBackendService' while setting property 'newStackBackendService'; nested exception is org.springframework.bea
    ns.factory.BeanCreationException: Error creating bean with name 'newStackBackendService' defined in ServletContex
    t resource [/WEB-INF/web-spring.xml]: Initialization of bean failed; nested exception is javax.naming.Communicati
    onException: null
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'delegate' defined in Serv
    letContext resource [/WEB-INF/web-spring.xml]: Can't resolve reference to bean 'payNowService' while setting prop
    erty 'payNowService'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating
    bean with name 'payNowService' defined in ServletContext resource [/WEB-INF/web-spring.xml]: Can't resolve refer
    ence to bean 'newStackService' while setting property 'newStackService'; nested exception is org.springframework.
    beans.factory.BeanCreationException: Error creating bean with name 'newStackService' defined in ServletContext re
    source [/WEB-INF/web-spring.xml]: Can't resolve reference to bean 'newStackBackendService' while setting property
    'newStackBackendService'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error cre
    ating bean with name 'newStackBackendService' defined in ServletContext resource [/WEB-INF/web-spring.xml]: Initi
    alization of bean failed; nested exception is javax.naming.CommunicationException: null
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'payNowService' defined in
    ServletContext resource [/WEB-INF/web-spring.xml]: Can't resolve reference to bean 'newStackService' while setti
    ng property 'newStackService'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error
    creating bean with name 'newStackService' defined in ServletContext resource [/WEB-INF/web-spring.xml]: Can't re
    solve reference to bean 'newStackBackendService' while setting property 'newStackBackendService'; nested exceptio
    n is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'newStackBackendServi
    ce' defined in ServletContext resource [/WEB-INF/web-spring.xml]: Initialization of bean failed; nested exception
    is javax.naming.CommunicationException: null
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'payNowService' defined in
    ServletContext resource [/WEB-INF/web-spring.xml]: Can't resolve reference to bean 'newStackService' while setti
    ng property 'newStackService'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error
    creating bean with name 'newStackService' defined in ServletContext resource [/WEB-INF/web-spring.xml]: Can't re
    solve reference to bean 'newStackBackendService' while setting property 'newStackBackendService'; nested exceptio
    n is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'newStackBackendServi
    ce' defined in ServletContext resource [/WEB-INF/web-spring.xml]: Initialization of bean failed; nested exception
    is javax.naming.CommunicationException: null
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'newStackService' defined
    in ServletContext resource [/WEB-INF/web-spring.xml]: Can't resolve reference to bean 'newStackBackendService' wh
    ile setting property 'newStackBackendService'; nested exception is org.springframework.beans.factory.BeanCreation
    Exception: Error creating bean with name 'newStackBackendService' defined in ServletContext resource [/WEB-INF/we
    b-spring.xml]: Initialization of bean failed; nested exception is javax.naming.CommunicationException: null
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'newStackBackendService' d
    efined in ServletContext resource [/WEB-INF/web-spring.xml]: Initialization of bean failed; nested exception is j
    avax.naming.CommunicationException: null
    javax.naming.CommunicationException. Root exception is
    java.net.ConnectException: t3://142.178.100.139:20101: Destination unreachable; nested exception is:
    java.net.ConnectException: Connection refused; No available router to destination
    at weblogic.rjvm.RJVMFinder.findOrCreate(RJVMFinder.j ava:180)
    at weblogic.rjvm.ServerURL.findOrCreateRJVM(ServerURL .java:262)
    at weblogic.jndi.WLInitialContextFactoryDelegate.getI nitialContext(WLInitialContextFactoryDelegate.java :3
    23)
    at weblogic.jndi.WLInitialContextFactoryDelegate.getI nitialContext(WLInitialContextFactoryDelegate.java :2
    21)
    at weblogic.jndi.WLInitialContextFactory.getInitialCo ntext(WLInitialContextFactory.java:149)
    at javax.naming.spi.NamingManager.getInitialContext(N amingManager.java:660)
    at javax.naming.InitialContext.getDefaultInitCtx(Init ialContext.java:241)
    at javax.naming.InitialContext.init(InitialContext.ja va:217)
    at javax.naming.InitialContext.<init>(InitialContext. java:193)
    at org.springframework.jndi.JndiTemplate.createInitia lContext(JndiTemplate.java:105)
    at org.springframework.jndi.JndiTemplate.execute(Jndi Template.java:83)
    at org.springframework.jndi.JndiTemplate.lookup(JndiT emplate.java:121)
    at org.springframework.jndi.JndiLocatorSupport.lookup (JndiLocatorSupport.java:71)
    at org.springframework.jndi.JndiObjectLocator.lookup( JndiObjectLocator.java:85)
    at org.springframework.ejb.access.AbstractRemoteSlsbI nvokerInterceptor.lookup(AbstractRemoteSlsbInvoker In
    terceptor.java:93)
    at org.springframework.ejb.access.AbstractSlsbInvoker Interceptor.refreshHome(AbstractSlsbInvokerInterce pt
    or.java:102)
    at org.springframework.ejb.access.AbstractSlsbInvoker Interceptor.afterPropertiesSet(AbstractSlsbInvoker In
    terceptor.java:90)
    at org.springframework.ejb.access.SimpleRemoteStatele ssSessionProxyFactoryBean.afterPropertiesSet(Simpl eR
    emoteStatelessSessionProxyFactoryBean.java:95)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr ac
    tAutowireCapableBeanFactory.java:962)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wi
    reCapableBeanFactory.java:354)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:223)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:147)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nV
    alueResolver.java:176)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe fi
    nitionValueResolver.java:105)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tr
    actAutowireCapableBeanFactory.java:916)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu to
    wireCapableBeanFactory.java:727)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wi
    reCapableBeanFactory.java:336)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:223)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:147)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nV
    alueResolver.java:176)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe fi
    nitionValueResolver.java:105)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tr
    actAutowireCapableBeanFactory.java:916)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu to
    wireCapableBeanFactory.java:727)
    reCapableBeanFactory.java:336)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:223)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:147)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nV
    alueResolver.java:176)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe fi
    nitionValueResolver.java:105)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tr
    actAutowireCapableBeanFactory.java:916)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu to
    wireCapableBeanFactory.java:727)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wi
    reCapableBeanFactory.java:336)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:223)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:147)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nV
    alueResolver.java:176)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe fi
    nitionValueResolver.java:105)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tr
    actAutowireCapableBeanFactory.java:916)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu to
    wireCapableBeanFactory.java:727)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wi
    reCapableBeanFactory.java:336)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:223)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:147)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tL
    istableBeanFactory.java:277)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va
    :312)
    at org.springframework.web.context.support.AbstractRe freshableWebApplicationContext.refresh(AbstractRef re
    shableWebApplicationContext.java:134)
    at org.springframework.web.struts.ContextLoaderPlugIn .createWebApplicationContext(ContextLoaderPlugIn.j av
    a:352)
    at org.springframework.web.struts.ContextLoaderPlugIn .initWebApplicationContext(ContextLoaderPlugIn.jav a:
    295)
    at org.springframework.web.struts.ContextLoaderPlugIn .init(ContextLoaderPlugIn.java:224)
    at org.apache.struts.action.ActionServlet.initModuleP lugIns(ActionServlet.java:1158)
    at org.apache.struts.action.ActionServlet.init(Action Servlet.java:473)
    at javax.servlet.GenericServlet.init(GenericServlet.j ava:258)
    at weblogic.servlet.internal.ServletStubImpl$ServletI nitAction.run(ServletStubImpl.java:1075)
    at weblogic.security.service.SecurityServiceManager.r unAs(SecurityServiceManager.java:780)
    at weblogic.servlet.internal.ServletStubImpl.createSe rvlet(ServletStubImpl.java:899)
    at weblogic.servlet.internal.ServletStubImpl.createIn stances(ServletStubImpl.java:833)
    at weblogic.servlet.internal.ServletStubImpl.prepareS ervlet(ServletStubImpl.java:773)
    at weblogic.servlet.internal.WebAppServletContext.pre loadServlet(WebAppServletContext.java:2782)
    at weblogic.servlet.internal.WebAppServletContext.pre loadServlets(WebAppServletContext.java:2727)
    at weblogic.servlet.internal.WebAppServletContext.pre loadResources(WebAppServletContext.java:2700)
    at weblogic.servlet.internal.HttpServer.preloadResour ces(HttpServer.java:563)
    at weblogic.servlet.internal.WebService.preloadResour ces(WebService.java:476)
    at weblogic.t3.srvr.ServletInitRunner$1.run(ServletIn itRunner.java:50)
    at weblogic.security.service.SecurityServiceManager.r unAs(SecurityServiceManager.java:780)
    at weblogic.t3.srvr.ServletInitRunner.run(ServletInit Runner.java:46)
    at java.lang.Thread.run(Thread.java:479)


    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

    <!--
    - Application context definition for PayNow subapplication.
    -->
    <beans>

    <bean name="/action/makePayment"
    class="com.telus.ccs.paynow.action.MakePaymentActi on">
    <property name="delegate"><ref bean="delegate"/></property>
    </bean>

    <bean id="delegate" lazy-init="true"
    class="com.telus.ccs.delegate.BusinessDelegateImpl ">

    <property name="payNowService">
    <ref bean="payNowService"/>
    </property>
    </bean>


    <bean id="payNowService" class="com.telus.ccs.paynow.PayNowServiceImpl">
    <property name="oldStackService"><ref bean="oldStackService"/></property>
    <property name="newStackService"><ref bean="newStackService"/></property>
    <property name="errorCodes">
    <props>
    <prop key="10010">"TransactionFailure"</prop>
    <prop key="10011">"Eigen NOT available"</prop>
    <prop key="10012">"Bank NOT available"</prop>
    <prop key="10013">"CCM shutdown"</prop>
    <prop key="10014">"CCM in batch mode"</prop>
    <prop key="10015">"Timeout"</prop>
    <prop key="10016">"Encryption"</prop>
    <prop key="10017">"Database"</prop>
    <prop key="10018">"Bank Failure"</prop>
    <prop key="10019">"CCM in Error State"</prop>
    <prop key="10101">"Invalid Credit Card Number"</prop>
    <prop key="10102">"Invalid Expiry Date"</prop>
    <prop key="10103">"Invalid Amount"</prop>
    <prop key="10104">"Invalid Transaction Type"</prop>
    <prop key="10105">"Invalid Payment Date"</prop>
    <prop key="10106">"Invalid Subsidiary"</prop>
    <prop key="10107">"Invalid Host"</prop>
    <prop key="10108">"Invalid Service Order Number"</prop>
    <prop key="10109">"Invalid Response Type"</prop>
    <prop key="10110">"Invalid userid"</prop>
    <prop key="10111">"Invalid CAN"</prop>
    <prop key="10112">"Invalid Area Code"</prop>
    <prop key="10113">"Invalid Phone Number"</prop>
    <prop key="10114">"Invalid Customer Name"</prop>
    <prop key="10115">"Invalid Callback Required/Number Field"</prop>
    <prop key="10116">"Invalid CAN/Phone Number Combination"</prop>
    <prop key="10100">"BACKEND INTEGRATION: PARAMETER NOT VALID "</prop>
    </props>
    </property>
    </bean>


    <bean id="oldStackService" lazy-init="true"
    class="com.telus.ccs.delegate.adapter.OldStackAdap ter">

    <property name="oldStackBackendService">
    <ref bean="oldStackBackendService"/>
    </property>

    </bean>

    <bean id="newStackService" lazy-init="true"
    class="com.telus.ccs.delegate.adapter.NewStackAdap ter">

    <property name="newStackBackendService">
    <ref bean="newStackBackendService"/>
    </property>

    </bean>

    <bean id="oldStackBackendService" lazy-init="true"
    class="org.springframework.ejb.access.SimpleRemote StatelessSessionProxyFactoryBean">

    <property name="jndiName">
    <value>com/telus/ivr/IvrManagerEjb</value>
    </property>
    <property name="jndiTemplate">
    <ref bean="oldStackJndiTemplate" />
    </property>
    <property name="businessInterface">
    <value>com.telus.ivr.IvrManagerEjb</value>
    </property>
    </bean>

    <bean id="newStackBackendService" lazy-init="true"
    class="org.springframework.ejb.access.SimpleRemote StatelessSessionProxyFactoryBean">

    <property name="jndiName">
    <value>com.telus.contactcentermgt.ivrmgt.compsvc.I vrCompsvc</value>
    </property>

    <property name="jndiTemplate">
    <ref bean="newStackJndiTemplate" />
    </property>

    <property name="businessInterface">
    <value>com.telus.contactcentermgt.ivrmgt.compsvc.I vrCompsvc</value>
    </property>
    </bean>

    <bean id="oldStackJndiTemplate" lazy-init="true"
    class="org.springframework.jndi.JndiTemplate">

    <property name="environment">
    <props>
    <prop key="java.naming.factory.initial">
    com.ibm.websphere.naming.WsnInitialContextFactory
    </prop>
    <prop key="java.naming.provider.url">
    iiop://142.178.34.135:19099
    </prop>
    </props>
    </property>
    </bean>

    <bean id="newStackJndiTemplate" lazy-init="true"
    class="org.springframework.jndi.JndiTemplate">

    <property name="environment">
    <props>
    <prop key="java.naming.factory.initial">
    weblogic.jndi.WLInitialContextFactory
    </prop>
    <prop key="java.naming.provider.url">
    t3://142.178.100.139:20101
    </prop>
    </props>
    </property>
    </bean>
    </beans>


    Regards,
    David

  • #2
    This is caused by this problem:

    Code:
    <bean name="/action/makePayment" 
    class="com.telus.ccs.paynow.action.MakePaymentAction"> 
    <property name="delegate"><ref bean="delegate"/></property> 
    </bean>
    although you place lazy-init="true" in some of your settings,
    this bean definition is calling any other related beans, and it has not lazy-nit="true", so every other else will be instantiated.

    Comment


    • #3
      Maybe it would help to specify the lookupHomeOnStartup property with true on your SimpleRemoteStatelessSessionProxyFactoryBean.

      Regards,
      Andreas

      Comment


      • #4
        resolved and thanks

        Thanks a lot Andreas, lookupHomeOnStartup worked for me, so did LazyInitTargetSource.

        Regards,
        David

        Comment


        • #5
          What is the difference between the lazy-init attribute and the lookupOnStartup property?

          Comment


          • #6
            Does lookupHomeOnStartup allow lazy init?

            Comment

            Working...
            X