Announcement Announcement Module
Collapse
No announcement yet.
Problem migrating from struts to Springs using DelegatingActionProxy Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem migrating from struts to Springs using DelegatingActionProxy

    Hi,

    I am trying to use springs with my existing struts-1.2 application
    I have made the following changes :

    In struts-config.xml

    Code:
     <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
        <set-property property="contextConfigLocation" value="/WEB-INF/action-servlet.xml"/>
     </plug-in>
    in struts-custom-config.xml

    Code:
     <action input="/jsp/services/VerifyDetails.jsp" parameter="method" path="/verifyDetails"  name="VerifyDetailsForm" scope="session" type="org.springframework.web.struts.DelegatingActionProxy" >
    		<forward name="load" path="/dca/jsp/services/VerifyDetails.jsp" />
    		<forward name="displayDetails" path="/dca/jsp/services/DisplayVerifyDetails.jsp" />
    		/>
    	</action>
    and in action-servlet.xml

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" 
     "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
        
        <bean name="/verifyDetails"   
            class="com.services.actions.VerifyDetailsAction" >
          
         </bean>
    </beans>

    But while startup i get the exception:

    [Servlet.LOG]: action: null: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '/verifyDetails' defined in ServletContext resource [/WEB-INF/action-servlet.xml]: Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError


    Any clues ?
    Thanks

  • #2
    Please post the full stacktrace and when doing so please use [ code][/code ] tags for stacktraces also.

    Comment


    • #3
      Originally posted by Marten Deinum View Post
      Please post the full stacktrace and when doing so please use [ code][/code ] tags for stacktraces also.

      Hi,
      The complete stack trace is :

      Code:
      5/21/12 18:29:52:179 IST] 00000015 WebApp        A   SRVE0181I: [FrontOfficeEAR#FrontOfficeWEB.war] [/DPWeb] [Servlet.LOG]: action: null: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '/verifyDetails' defined in ServletContext resource [/WEB-INF/action-servlet.xml]: Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError
      5/21/12 18:29:52:179 IST] 00000015 WebApp        A   SRVE0181I: [FrontOfficeEAR#FrontOfficeWEB.war] [/DPWeb] [Servlet.LOG]: action: null: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '/verifyDetails' defined in ServletContext resource [/WEB-INF/action-servlet.xml]: Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:883)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:839)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
      	at java.security.AccessController.doPrivileged(AccessController.java:214)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
      	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
      	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
      	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
      	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
      	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
      	at org.springframework.web.struts.ContextLoaderPlugIn.createWebApplicationContext(ContextLoaderPlugIn.java:354)
      	at org.springframework.web.struts.ContextLoaderPlugIn.initWebApplicationContext(ContextLoaderPlugIn.java:295)
      	at org.springframework.web.struts.ContextLoaderPlugIn.init(ContextLoaderPlugIn.java:225)
      	at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:1158)
      	at org.apache.struts.action.ActionServlet.init(ActionServlet.java:473)
      	at com..core.struts.ActionServlet.init(ActionServlet.java:47)
      	at javax.servlet.GenericServlet.init(GenericServlet.java:256)
      	at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:185)
      	at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.init(ServletWrapper.java:316)
      	at com.ibm.ws.webcontainer.servlet.ServletWrapper.initialize(ServletWrapper.java:1119)
      	at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.initialize(ServletWrapper.java:149)
      	at com.ibm.wsspi.webcontainer.extension.WebExtensionProcessor.createServletWrapper(WebExtensionProcessor.java:99)
      	at com.ibm.ws.webcontainer.webapp.WebApp.getServletWrapper(WebApp.java:742)
      	at com.ibm.ws.webcontainer.webapp.WebApp.initializeTargetMappings(WebApp.java:422)
      	at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinish(WebApp.java:275)
      	at com.ibm.ws.wswebcontainer.webapp.WebApp.initialize(WebApp.java:272)
      	at com.ibm.ws.wswebcontainer.webapp.WebGroup.addWebApplication(WebGroup.java:88)
      	at com.ibm.ws.wswebcontainer.VirtualHost.addWebApplication(VirtualHost.java:157)
      	at com.ibm.ws.wswebcontainer.WebContainer.addWebApp(WebContainer.java:655)
      	at com.ibm.ws.wswebcontainer.WebContainer.addWebApplication(WebContainer.java:608)
      	at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:333)
      	at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:549)
      	at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1295)
      	at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1129)
      	at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:567)
      	at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:814)
      	at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:948)
      	at com.ibm.ws.runtime.component.ApplicationMgrImpl$AppInitializer.run(ApplicationMgrImpl.java:2114)
      	at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:340)
      	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)
      Caused by: java.lang.ExceptionInInitializerError
      	at java.lang.J9VMInternals.initialize(J9VMInternals.java:195)
      	at com.core.actions.ActionClass.<clinit>(ActionClass.java:80)
      	at java.lang.J9VMInternals.initializeImpl(Native Method)
      	at java.lang.J9VMInternals.initialize(J9VMInternals.java:177)
      	at java.lang.J9VMInternals.initialize(J9VMInternals.java:144)
      	at java.lang.J9VMInternals.initialize(J9VMInternals.java:144)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:67)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:521)
      	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100)
      	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:877)
      	... 43 more
      Caused by: java.lang.NullPointerException
      	at com..core.util.ApplicationProperties.<clinit>(ApplicationProperties.java:35)
      	at java.lang.J9VMInternals.initializeImpl(Native Method)
      	at java.lang.J9VMInternals.initialize(J9VMInternals.java:177)
      	... 55 more

      Comment


      • #4
        Judging from the stacktrace the root of your problem lies in the ApplicationProperties class, which upon constuction expects properties to be set which aren't yet set/available.

        Comment


        • #5
          Originally posted by Marten Deinum View Post
          Judging from the stacktrace the root of your problem lies in the ApplicationProperties class, which upon constuction expects properties to be set which aren't yet set/available.
          Hi
          But the moment I comment the changes I have made the code works fine.
          Hope I am not missing anything as far as the changes in struts framework are concerned...

          Comment


          • #6
            I suggest you take a look at the stacktrace, the fact that the code works without the changes says nothing. It doesn't work with the changes, so the error is either part of the changes (I suspect the configuration) and/or the assumption on how things in your code work.

            The stacktrace clearly indicates that you get a NullPointer in the ApplicationProperties (which you probably also configured inside spring or at least something is instantiating that) and in the constructor (or a static code block) you expect something to be already set, which isn't .

            Comment


            • #7
              Originally posted by Marten Deinum View Post
              I suggest you take a look at the stacktrace, the fact that the code works without the changes says nothing. It doesn't work with the changes, so the error is either part of the changes (I suspect the configuration) and/or the assumption on how things in your code work.

              The stacktrace clearly indicates that you get a NullPointer in the ApplicationProperties (which you probably also configured inside spring or at least something is instantiating that) and in the constructor (or a static code block) you expect something to be already set, which isn't .

              This is apparently because something is causing an exception at call to
              Code:
               super.init();
              in my ActionServlet (hence unable to load the properties required by the config file)

              Code:
              	/22/12 12:13:51:426 IST] 00000016 ServletWrappe E   Deregister the mbean because of uncaught init() exception thrown by servlet action: javax.servlet.UnavailableException
              		at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:1169)
              		at org.apache.struts.action.ActionServlet.init(ActionServlet.java:473)
              		at com.core.struts.ActionServlet.init(ActionServlet.java:47)
              		at javax.servlet.GenericServlet.init(GenericServlet.java:256)
              		at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:185)
              		at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.init(ServletWrapper.java:316)
              		at com.ibm.ws.webcontainer.servlet.ServletWrapper.initialize(ServletWrapper.java:1119)
              		at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.initialize(ServletWrapper.java:149)
              		at com.ibm.wsspi.webcontainer.extension.WebExtensionProcessor.createServletWrapper(WebExtensionProcessor.java:99)
              		at com.ibm.ws.webcontainer.webapp.WebApp.getServletWrapper(WebApp.java:742)
              		at com.ibm.ws.webcontainer.webapp.WebApp.initializeTargetMappings(WebApp.java:422)
              		at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinish(WebApp.java:275)
              		at com.ibm.ws.wswebcontainer.webapp.WebApp.initialize(WebApp.java:272)
              		at com.ibm.ws.wswebcontainer.webapp.WebGroup.addWebApplication(WebGroup.java:88)
              		at com.ibm.ws.wswebcontainer.VirtualHost.addWebApplication(VirtualHost.java:157)
              		at com.ibm.ws.wswebcontainer.WebContainer.addWebApp(WebContainer.java:655)
              		at com.ibm.ws.wswebcontainer.WebContainer.addWebApplication(WebContainer.java:608)
              		at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:333)
              		at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:549)
              		at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1295)
              		at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1129)
              		at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:567)
              		at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:814)
              		at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:948)
              		at com.ibm.ws.runtime.component.ApplicationMgrImpl$AppInitializer.run(ApplicationMgrImpl.java:2114)
              		at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:340)
              		at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)
              	,

              Comment


              • #8
                Originally posted by albusdumbeldore View Post
                This is apparently because something is causing an exception at call to
                Code:
                 super.init();
                in my ActionServlet (hence unable to load the properties required by the config file)

                Code:
                	/22/12 12:13:51:426 IST] 00000016 ServletWrappe E   Deregister the mbean because of uncaught init() exception thrown by servlet action: javax.servlet.UnavailableException
                		at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:1169)
                		at org.apache.struts.action.ActionServlet.init(ActionServlet.java:473)
                		at com.core.struts.ActionServlet.init(ActionServlet.java:47)
                		at javax.servlet.GenericServlet.init(GenericServlet.java:256)
                		at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:185)
                		at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.init(ServletWrapper.java:316)
                		at com.ibm.ws.webcontainer.servlet.ServletWrapper.initialize(ServletWrapper.java:1119)
                		at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.initialize(ServletWrapper.java:149)
                		at com.ibm.wsspi.webcontainer.extension.WebExtensionProcessor.createServletWrapper(WebExtensionProcessor.java:99)
                		at com.ibm.ws.webcontainer.webapp.WebApp.getServletWrapper(WebApp.java:742)
                		at com.ibm.ws.webcontainer.webapp.WebApp.initializeTargetMappings(WebApp.java:422)
                		at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinish(WebApp.java:275)
                		at com.ibm.ws.wswebcontainer.webapp.WebApp.initialize(WebApp.java:272)
                		at com.ibm.ws.wswebcontainer.webapp.WebGroup.addWebApplication(WebGroup.java:88)
                		at com.ibm.ws.wswebcontainer.VirtualHost.addWebApplication(VirtualHost.java:157)
                		at com.ibm.ws.wswebcontainer.WebContainer.addWebApp(WebContainer.java:655)
                		at com.ibm.ws.wswebcontainer.WebContainer.addWebApplication(WebContainer.java:608)
                		at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:333)
                		at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:549)
                		at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1295)
                		at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1129)
                		at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:567)
                		at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:814)
                		at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:948)
                		at com.ibm.ws.runtime.component.ApplicationMgrImpl$AppInitializer.run(ApplicationMgrImpl.java:2114)
                		at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:340)
                		at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)
                	,

                This is coming from :
                Code:
                 protected void initModulePlugIns(ModuleConfig config)
                    throws ServletException
                  {
                    if (log.isDebugEnabled()) {
                      log.debug("Initializing module path '" + config.getPrefix() + "' plug ins");
                    }
                
                    PlugInConfig[] plugInConfigs = config.findPlugInConfigs();
                    PlugIn[] plugIns = new PlugIn[plugInConfigs.length];
                
                    getServletContext().setAttribute("org.apache.struts.action.PLUG_INS" + config.getPrefix(), plugIns);
                    for (int i = 0; i < plugIns.length; i++)
                      try {
                        plugIns[i] = ((PlugIn)RequestUtils.applicationInstance(plugInConfigs[i].getClassName()));
                
                        BeanUtils.populate(plugIns[i], plugInConfigs[i].getProperties());
                        try
                        {
                          PropertyUtils.setProperty(plugIns[i], "currentPlugInConfigObject", plugInConfigs[i]);
                        }
                        catch (Exception e)
                        {
                        }
                
                        plugIns[i].init(this, config);
                      }
                      catch (ServletException e) {
                        throw e;
                      } catch (Exception e) {
                        String errMsg = this.internal.getMessage("plugIn.init", plugInConfigs[i].getClassName());
                
                        log(errMsg, e);
                        throw new UnavailableException(errMsg);
                      }
                  }
                in org.apache.struts.action.ActionServlet.java

                Comment


                • #9
                  No it isn't... The servlet cannot load/start because there are problems in your configuration (as I pointed out earlier) due to those your servlet isn't available. Please post your ApplicationProperties class.

                  Comment

                  Working...
                  X