Announcement Announcement Module
Collapse
No announcement yet.
initialization fail error on applicationcontext getbean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • initialization fail error on applicationcontext getbean

    i will get initialization fail error when i use ajax or webservice to call backend. It only occur when i first start tomcat and use webservice. The error only can solve once i view the page and do any transaction on web after start tomcat.Then only can use webservice to call. It is because spring has not initialise he applicationcontext and then webservice go and getBean. So any suggestion?

  • #2
    Can you please post stack trace and your spring -servlet.xml file.

    Comment


    • #3
      web.xml ::
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
      "http://java.sun.com/dtd/web-app_2_3.dtd">
      <web-app>

      <context-param>
      <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
      <param-value>server</param-value>
      </context-param>

      <context-param>
      <param-name>javax.faces.CONFIG_FILES</param-name>
      <param-value>
      /WEB-INF/faces-managed-beans.xml
      </param-value>
      </context-param>

      <context-param>
      <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
      <param-value>true</param-value>
      </context-param>

      <context-param>
      <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
      <param-value>false</param-value>
      </context-param>

      <context-param>
      <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
      <param-value>true</param-value>

      </context-param>

      <context-param>
      <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
      <param-value>true</param-value>
      </context-param>

      <context-param>
      <param-name>tiles-definitions</param-name>
      <param-value>/WEB-INF/tiles-defs.xml</param-value>
      </context-param>

      <context-param>
      <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
      <param-value>.tiles</param-value>
      </context-param>

      <filter>
      <filter-name>MyFacesExtensionsFilter</filter-name>
      <filter-class>
      org.apache.myfaces.component.html.util.ExtensionsF ilter
      </filter-class>
      <init-param>
      <param-name>maxFileSize</param-name>
      <param-value>20m</param-value>

      </init-param>
      </filter>

      <filter>
      <filter-name>Acegi Filter Chain Proxy</filter-name>
      <filter-class>
      net.sf.acegisecurity.util.FilterToBeanProxy
      </filter-class>
      <init-param>
      <param-name>targetClass</param-name>
      <param-value>
      net.sf.acegisecurity.util.FilterChainProxy
      </param-value>
      </init-param>
      </filter>

      <filter>
      <filter-name>sessionFilter</filter-name>
      <filter-class>
      org.springframework.orm.hibernate3.support.OpenSes sionInViewFilter
      </filter-class>
      </filter>

      <filter-mapping>
      <filter-name>Acegi Filter Chain Proxy</filter-name>
      <url-pattern>/*</url-pattern>
      </filter-mapping>

      <filter-mapping>
      <filter-name>sessionFilter</filter-name>
      <url-pattern>*.jsf</url-pattern>
      </filter-mapping>

      <filter-mapping>
      <filter-name>MyFacesExtensionsFilter</filter-name>
      <url-pattern>*.jsf</url-pattern>
      </filter-mapping>
      <filter-mapping>
      <filter-name>MyFacesExtensionsFilter</filter-name>
      <url-pattern>/faces/*</url-pattern>
      </filter-mapping>

      <listener>
      <listener-class>
      org.apache.myfaces.webapp.StartupServletContextLis tener
      </listener-class>
      </listener>

      <listener>
      <listener-class>
      org.springframework.web.context.ContextLoaderListe ner
      </listener-class>
      </listener>

      <servlet>
      <servlet-name>FacesServlet</servlet-name>
      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
      </servlet>

      <servlet>
      <servlet-name>dwr-invoker</servlet-name>
      <servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
      <init-param>
      <param-name>debug</param-name>
      <param-value>false</param-value>
      </init-param>
      </servlet>
      <servlet>
      <servlet-name>Axis</servlet-name>

      <servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
      </servlet>

      <servlet>
      <servlet-name>AdminServlet</servlet-name>

      <servlet-class>org.apache.axis.transport.http.AdminServlet</servlet-class>

      <load-on-startup>10</load-on-startup>
      </servlet>

      <servlet-mapping>
      <servlet-name>Axis</servlet-name>
      <url-pattern>/webservice/*</url-pattern>
      </servlet-mapping>

      <servlet-mapping>
      <servlet-name>AdminServlet</servlet-name>
      <url-pattern>/webservice/AdminService</url-pattern>
      </servlet-mapping>

      <servlet-mapping>
      <servlet-name>FacesServlet</servlet-name>
      <url-pattern>*.jsf</url-pattern>
      </servlet-mapping>

      <servlet-mapping>
      <servlet-name>dwr-invoker</servlet-name>
      <url-pattern>/dwr/*</url-pattern>
      </servlet-mapping>

      <session-config>
      <session-timeout>10</session-timeout>
      </session-config>

      <welcome-file-list>
      <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>

      </web-app>

      Trace ::
      May 4, 2006 8:51:38 PM org.apache.catalina.startup.Catalina start
      INFO: Server startup in 75769 ms
      20:54:01,924 INFO EXCEPTIONS:400 - Exception:
      java.lang.ExceptionInInitializerError
      at com.webservice.FinanceWebService.<in
      it>(FinanceWebService.java:44)
      at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)

      at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(Unknown Source)

      at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(Unknown Sou
      rce)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at java.lang.Class.newInstance0(Unknown Source)
      at java.lang.Class.newInstance(Unknown Source)
      at org.apache.axis.providers.java.JavaProvider.makeNe wServiceObject(Java
      Provider.java:385)
      at org.apache.axis.providers.java.JavaProvider.getNew ServiceObject(JavaP
      rovider.java:235)
      at org.apache.axis.providers.java.JavaProvider.getSer viceObject(JavaProv
      ider.java:91)
      at org.apache.axis.providers.java.JavaProvider.invoke (JavaProvider.java:
      287)
      at org.apache.axis.strategies.InvocationStrategy.visi t(InvocationStrateg
      y.java:32)
      at org.apache.axis.SimpleChain.doVisiting(SimpleChain .java:118)
      at org.apache.axis.SimpleChain.invoke(SimpleChain.jav a:83)
      at org.apache.axis.handlers.soap.SOAPService.invoke(S OAPService.java:453
      )
      at org.apache.axis.server.AxisServer.invoke(AxisServe r.java:281)
      at org.apache.axis.transport.http.AxisServlet.doPost( AxisServlet.java:69
      9)
      at javax.servlet.http.HttpServlet.service(HttpServlet .java:767)
      at org.apache.axis.transport.http.AxisServletBase.ser vice(AxisServletBas
      e.java:327)
      at javax.servlet.http.HttpServlet.service(HttpServlet .java:860)
      at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(Appl
      icationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationF
      ilterChain.java:173)
      at net.sf.acegisecurity.util.FilterChainProxy$Virtual FilterChain.doFilte
      r(FilterChainProxy.java:292)
      at net.sf.acegisecurity.intercept.web.FilterSecurityI nterceptor.invoke(F
      ilterSecurityInterceptor.java:108)
      at net.sf.acegisecurity.intercept.web.SecurityEnforce mentFilter.doFilter
      (SecurityEnforcementFilter.java:197)
      at net.sf.acegisecurity.util.FilterChainProxy$Virtual FilterChain.doFilte
      r(FilterChainProxy.java:303)
      at net.sf.acegisecurity.context.HttpSessionContextInt egrationFilter.doFi
      lter(HttpSessionContextIntegrationFilter.java:220)
      at net.sf.acegisecurity.util.FilterChainProxy$Virtual FilterChain.doFilte
      r(FilterChainProxy.java:303)
      at net.sf.acegisecurity.securechannel.ChannelProcessi ngFilter.doFilter(C
      hannelProcessingFilter.java:168)
      at net.sf.acegisecurity.util.FilterChainProxy$Virtual FilterChain.doFilte
      r(FilterChainProxy.java:303)
      at net.sf.acegisecurity.util.FilterChainProxy.doFilte r(FilterChainProxy.
      java:173)
      at net.sf.acegisecurity.util.FilterToBeanProxy.doFilt er(FilterToBeanProx

      Comment


      • #4
        Can you post FinanceWebService.java as well please

        Also, can you wrap the code postings in code tags please.

        Comment


        • #5
          Code:
          	static{
          		appContext = FacesContextUtils.getWebApplicationContext(
          				FacesContext.getCurrentInstance());	
          	}
          
          	public static Object lookupBean(String beanName) {		
          		return appContext.getBean(beanName);
          	}
          The error is because of appContext.getBean(beanName)

          Comment


          • #6
            Ah OK; a JSF app, for which I have zero experience unfortunately.

            Are you sure line 44 is in the static methods? The exception seems to be coming from the constructor, not the static methods....

            Comment


            • #7
              Yup, because inside the constructor will call the getBean.

              Comment


              • #8
                Originally posted by jimmy6
                Yup, because inside the constructor will call the getBean.
                The fragment of code you posted doesn't include a constructor....

                Comment


                • #9
                  Just throwing an idea out here - try setting 'load-on-startup' for all the servlets explicitly.

                  Also, when tomcat starts, the log should show whether the app context has been initialized - it generates lots of logging, you can't miss it.

                  Comment


                  • #10
                    yes, i saw those logging in console but the error still will exist. Why?

                    Comment

                    Working...
                    X