cancel
Showing results for 
Search instead for 
Did you mean: 

Hybris 6 Migration | applicationContext not found error

Former Member
0 Kudos

After getting migrated to Hybris 6.0 from 5.7, running junit tests resulting in below error. This error was not there with 5.7

Kindly assist if anyone knows about this issue.

IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:344) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:252) at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127) at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93) at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129) at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:452) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:93) at org.glassfish.jersey.server.spring.SpringComponentProvider.createXmlSpringConfiguration(SpringComponentProvider.java:173) at org.glassfish.jersey.server.spring.SpringComponentProvider.createSpringContext(SpringComponentProvider.java:164) at org.glassfish.jersey.server.spring.SpringComponentProvider.initialize(SpringComponentProvider.java:99) at org.glassfish.jersey.server.ApplicationHandler$4.get(ApplicationHandler.java:408) at org.glassfish.jersey.server.ApplicationHandler$4.get(ApplicationHandler.java:399) at org.glassfish.jersey.internal.util.collection.Values$LazyValueImpl.get(Values.java:340) at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:350) at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:347) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255) at org.glassfish.jersey.server.ApplicationHandler.(ApplicationHandler.java:347) at org.glassfish.jersey.server.ApplicationHandler.(ApplicationHandler.java:299) at org.glassfish.jersey.test.inmemory.InMemoryTestContainerFactory$InMemoryTestContainer.(InMemoryTestContainerFactory.java:77) at org.glassfish.jersey.test.inmemory.InMemoryTestContainerFactory$InMemoryTestContainer.(InMemoryTestContainerFactory.java:63) at org.glassfish.jersey.test.inmemory.InMemoryTestContainerFactory.create(InMemoryTestContainerFactory.java:111) at org.glassfish.jersey.test.JerseyTest.createTestContainer(JerseyTest.java:277) at org.glassfish.jersey.test.JerseyTest.setUp(JerseyTest.java:609) at de.hybris.ant.taskdefs.yunit.JUnitTestRunner.run(JUnitTestRunner.java:586) at de.hybris.ant.taskdefs.yunit.JUnitTestRunner.launch(JUnitTestRunner.java:1301) at de.hybris.ant.taskdefs.yunit.JUnitTestRunner.main(JUnitTestRunner.java:1091) Caused by: java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330)

Accepted Solutions (0)

Answers (8)

Answers (8)

surziceanu
Explorer
0 Kudos

Hello,

Most probrably one of the web.xml is the issue. The following snippet is from the storefront extension. If the contextConfigLocation it is missing then spring default mechanism it's used.

<servlet>
<description>
DispatcherServlet
Spring MVC dispatcher servlet. This is the entry point for the Spring MVC application.
</description>
<servlet-name>DispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<description>
Specifies the location for Spring MVC to load an additional XML configuration file.
Because hybris is already configured with the XML spring configuration files to load
we must set this param value to EMPTY in order to prevent loading of the default
/WEB-INF/applicationContext.xml file.
</description>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
0 Kudos

In our case one extension had a tag "webmodule" in extensioninfo.xml what caused this issue. The extension is not supposed to be a webmodule, so we simply removed this tag and it was working again.

Perhaps this can help others as well.

former_member384558
Participant
0 Kudos

That's right, if you want to disable / remove the web access possibility of the extension. This works for me. Thanks for the hint!

Former Member
0 Kudos

Hi experts,

I am facing the same issue. Please help if anyone have any answer.

Former Member
0 Kudos

Hello experts, please share if anyone got any clue!?

Former Member
0 Kudos
 <display-name>specialiststorefront</display-name>

 <!--
  We have to explicitly clear the welcome file list.
  We don't need to serve a default or index page as we can handle all the requests via spring MVC.
 -->
 <welcome-file-list>
     <welcome-file/>
 </welcome-file-list>


 <!-- filters -->
  <filter>
     <filter-name>XSSFilter</filter-name>
     <filter-class>de.hybris.platform.servicelayer.web.XSSFilter</filter-class>
 </filter>

  <filter>
     <filter-name>RecommendedXSSFilter</filter-name>
     <filter-class>com.cj.xss.XSSFilter</filter-class>
 </filter>
 
 <!-- X-XSS-protection Header Filter -->
 <filter> 
     <filter-name>ConfigureXSSProtectionFilter</filter-name> 
     <filter-class>com.specialistholidays.storefront.filters.ConfigureXSSProtectionFilter</filter-class> 
     <init-param>
          <param-name>enable</param-name> 
          <param-value>true</param-value> 
     </init-param>
  </filter> 
 
 <filter>
 <filter-name>characterEncodingFilter</filter-name>
     <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
     <init-param>
         <param-name>encoding</param-name>
         <param-value>UTF-8</param-value>
     </init-param>
     <init-param>
         <param-name>forceEncoding</param-name>
         <param-value>true</param-value>
     </init-param>
 </filter>

 <!-- resource filter -->
 <filter>
     <description>
         ResourceFilter
         Filter used to server file resources by bypassing the other filters.
     </description>
     <filter-name>resourceFilter</filter-name>
     <filter-class>com.specialistholidays.storefront.filters.StaticResourceFilter</filter-class>
 </filter>
 
 <filter>
     <description>
         AddOn developer 'hot swap' filter.
     </description>
     <filter-name>addOnDevelopmentFilter</filter-name>
     <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
 </filter>

 <!-- spring based filter chain -->
 <filter>
     <description>
         Spring configured chain of spring filter beans in tenant scope
     </description>
     <filter-name>storefrontTenantFilterChain</filter-name>
     <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
 </filter>
 
 <filter>
     <filter-name>ResponseInScopeFilter</filter-name>
     <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
 </filter>
 
 <filter>
     <filter-name>bufferFilter</filter-name>
     <filter-class>org.springframework.web.filter.ShallowEtagHeaderFilter</filter-class>
 </filter>


 <!-- filter mappings -->
 <filter-mapping>
     <filter-name>XSSFilter</filter-name>
     <url-pattern>/*</url-pattern>
 </filter-mapping>
 <filter-mapping>
     <filter-name>RecommendedXSSFilter</filter-name>
     <url-pattern>/*</url-pattern>
 </filter-mapping>

 <filter-mapping>
     <filter-name>addOnDevelopmentFilter</filter-name>
     <url-pattern>/*</url-pattern>
     <dispatcher>INCLUDE</dispatcher>
     <dispatcher>REQUEST</dispatcher>
 </filter-mapping>
 
 <filter-mapping>
     <filter-name>characterEncodingFilter</filter-name>
     <url-pattern>/*</url-pattern>
 </filter-mapping>
 
 <filter-mapping>
     <filter-name>bufferFilter</filter-name>
     <url-pattern>/*</url-pattern>
 </filter-mapping>
 
 <filter-mapping>
     <filter-name>ConfigureXSSProtectionFilter</filter-name>
     <url-pattern>/*</url-pattern>
 </filter-mapping>

 <!-- <filter-mapping>
     <filter-name>ResponseInScopeFilter</filter-name>
     <servlet-name>DispatcherServlet</servlet-name>
     <dispatcher>REQUEST</dispatcher>
     <dispatcher>ERROR</dispatcher>
 </filter-mapping> -->
 
 <filter-mapping><filter-name>resourceFilter</filter-name><url-pattern>/_ui/*</url-pattern></filter-mapping>
 <filter-mapping><filter-name>storefrontTenantFilterChain</filter-name><servlet-name>DispatcherServlet</servlet-name></filter-mapping>


 <!-- HTTP Session Listeners -->

 <listener>
     <description>
         The HybrisContextLoaderListener extends the usual SpringContextLoaderListener (which loads
         the context from specified location) by adding the global application context of
         the platform as parent context. With having the global context set as parent you can access
         or override beans of the global context and get the 'tenant' scope.
     </description>
     <listener-class>com.specialistholidays.storefront.filters.HybrisStorefrontContextLoaderListener</listener-class>
 </listener>

 <listener>
     <description>
         The RequestContextListener exposes the 'request' scope to the context.
         Furthermore it is needed when overriding the 'jalosession' bean for your web application.
     </description>
     <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
 </listener>

  <listener>
      <description>
         HttpSessionListener that automatically exposes the session mutex when an HttpSession gets created.
         The session mutex is guaranteed to be the same object during the entire lifetime of the session. 
         It serves as a safe reference to synchronize on for locking on the current session.
     </description>
     <listener-class>org.springframework.web.util.HttpSessionMutexListener</listener-class>
 </listener>
 
 <!-- config -->
 <context-param>
     <description>
         The 'contextConfigLocation' papecifies where your configuration files are located.
         The 'WEB-INF/config/web-application-config.xml' file includes several other XML config
         files to build up the configuration for the application.
     </description>
     <param-name>contextConfigLocation</param-name>
     <param-value>WEB-INF/config/web-application-config.xml</param-value>
 </context-param>
 <context-param>
     <param-name>tagpoolMaxSize</param-name>
     <param-value>50</param-value>
 </context-param>    

 <!-- Servlets -->
 <servlet>
     <description>
         DispatcherServlet
         Spring MVC dispatcher servlet. This is the entry point for the Spring MVC application.
     </description>
     <servlet-name>DispatcherServlet</servlet-name>
     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
     <init-param>
         <description>
             Specifies the location for Spring MVC to load an additional XML configuration file.
             Because hybris is already configured with the XML spring configuration files to load
             we must set this param value to EMPTY in order to prevent loading of the default
             /WEB-INF/applicationContext.xml file.
         </description>
         <param-name>contextConfigLocation</param-name>
         <param-value></param-value>
     </init-param>
     <load-on-startup>1</load-on-startup>
 </servlet>
 
 <servlet>
     <servlet-name>CompressServlet</servlet-name>
     <servlet-class>com.granule.CompressServlet</servlet-class>
     <load-on-startup>1</load-on-startup>
 </servlet>


 <servlet-mapping>
     <servlet-name>CompressServlet</servlet-name>
     <url-pattern>/combined.js</url-pattern>
 </servlet-mapping>
 <servlet-mapping>
     <servlet-name>CompressServlet</servlet-name>
     <url-pattern>/combined.css</url-pattern>
 </servlet-mapping>

 <servlet-mapping>
     <servlet-name>DispatcherServlet</servlet-name>
     <!-- Map all requests to the DispatcherServlet -->
     <url-pattern>/</url-pattern>
 </servlet-mapping>

 <!-- Session -->

 <session-config>
     <!-- Session timeout of 30 minutes -->
     <session-timeout>30</session-timeout>
     <cookie-config>
         <http-only>true</http-only>
     </cookie-config>
 </session-config>


 <!-- JSP Configuration -->

 <jsp-config>
     <jsp-property-group>
         <url-pattern>*.jsp</url-pattern>
         <!-- Disable JSP scriptlets and expressions -->
         <scripting-invalid>true</scripting-invalid>
         <!-- Remove additional whitespace due to JSP directives -->
         <trim-directive-whitespaces>true</trim-directive-whitespaces>
     </jsp-property-group>
 </jsp-config>

 <mime-mapping>
     <extension>woff</extension>
     <mime-type>application/x-font-woff</mime-type>
 </mime-mapping>
 <mime-mapping>
     <extension>ttf</extension>
     <mime-type>application/octet-stream</mime-type>
 </mime-mapping>
 <mime-mapping>
     <extension>eot</extension>
     <mime-type>application/vnd.ms-fontobject</mime-type>
 </mime-mapping>
 <mime-mapping>
     <extension>less</extension>
     <mime-type>text/css</mime-type>
 </mime-mapping>
 <mime-mapping>
     <extension>xml</extension>
     <mime-type>application/xml</mime-type>
 </mime-mapping>
 <mime-mapping>
     <extension>svg</extension>
     <mime-type>image/svg+xml</mime-type>
 </mime-mapping>

former_member708417
Participant
0 Kudos

web.xml looks ok.

former_member708417
Participant
0 Kudos

Hi Parinay,

can you verify what is the param-value for contextConfigLocation param name in web.xml file under storefront extension?

we need to pass the empty value for contextConfigLocation param like below for servlets tag.

   <param-name>contextConfigLocation</param-name>
   <param-value></param-value>
Former Member
0 Kudos

Hi All,

We migrated our code from 5.7 to 6.2 and ran into same problem. Any help would be highly appreciated. Thanks, Parinay

Former Member
0 Kudos

Hi, please check if you haven't removed any web.xml file from your extensions during migration e.g. from *storefront extension. Hybris by default is not using files with name applicationContext.xml and looking for such files seems to be triggered by Spring's fallback mechanism.

0 Kudos

Hi,

we ran into the same error as well. We did not change anything regarding configuration of our extensions and kept all of our web.xml. Any hint would be helpful.

Regards