1

I am trying to use Tomcat for my web application but I got this error running the app:

SEVERE: Context initialization failed
java.lang.ExceptionInInitializerError
    at org.springframework.core.env.AbstractEnvironment.suppressGetenvAccess(AbstractEnvironment.java:406)
    at org.springframework.core.env.AbstractEnvironment.getSystemEnvironment(AbstractEnvironment.java:368)
    at org.springframework.core.env.StandardEnvironment.customizePropertySources(StandardEnvironment.java:79)
    at org.springframework.web.context.support.StandardServletEnvironment.customizePropertySources(StandardServletEnvironment.java:90)
    at org.springframework.core.env.AbstractEnvironment.<init>(AbstractEnvironment.java:124)
    at org.springframework.core.env.StandardEnvironment.<init>(StandardEnvironment.java:54)
    at org.springframework.web.context.support.StandardServletEnvironment.<init>(StandardServletEnvironment.java:44)
    at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.createEnvironment(AbstractRefreshableWebApplicationContext.java:156)
    at org.springframework.context.support.AbstractApplicationContext.getEnvironment(AbstractApplicationContext.java:288)
    at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.resolvePath(AbstractRefreshableConfigApplicationContext.java:122)
    at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.setConfigLocations(AbstractRefreshableConfigApplicationContext.java:80)
    at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.setConfigLocation(AbstractRefreshableConfigApplicationContext.java:68)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:386)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.NullPointerException
    at org.springframework.core.SpringProperties.<clinit>(SpringProperties.java:58)
    ... 24 more

abr 22, 2014 4:49:06 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.ExceptionInInitializerError
    at org.springframework.core.env.AbstractEnvironment.suppressGetenvAccess(AbstractEnvironment.java:406)
    at org.springframework.core.env.AbstractEnvironment.getSystemEnvironment(AbstractEnvironment.java:368)
    at org.springframework.core.env.StandardEnvironment.customizePropertySources(StandardEnvironment.java:79)
    at org.springframework.web.context.support.StandardServletEnvironment.customizePropertySources(StandardServletEnvironment.java:90)
    at org.springframework.core.env.AbstractEnvironment.<init>(AbstractEnvironment.java:124)
    at org.springframework.core.env.StandardEnvironment.<init>(StandardEnvironment.java:54)
    at org.springframework.web.context.support.StandardServletEnvironment.<init>(StandardServletEnvironment.java:44)
    at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.createEnvironment(AbstractRefreshableWebApplicationContext.java:156)
    at org.springframework.context.support.AbstractApplicationContext.getEnvironment(AbstractApplicationContext.java:288)
    at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.resolvePath(AbstractRefreshableConfigApplicationContext.java:122)
    at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.setConfigLocations(AbstractRefreshableConfigApplicationContext.java:80)
    at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.setConfigLocation(AbstractRefreshableConfigApplicationContext.java:68)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:386)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.NullPointerException
    at org.springframework.core.SpringProperties.<clinit>(SpringProperties.java:58)
    ... 24 more 

My web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">

    <display-name>Archetype Created Web Application</display-name>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>       
            classpath*:/META-INF/persistence-context.xml,
            classpath*:/META-INF/service-context.xml,
            classpath*:/META-INF/web-context.xml
        </param-value>
    </context-param>

    <context-param>
        <param-name>configuration</param-name>
        <param-value>development</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <filter>
        <filter-name>wicket.filter</filter-name>
        <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
        <init-param>
            <param-name>applicationFactoryClassName</param-name>
            <param-value>org.apache.wicket.spring.SpringWebApplicationFactory</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>wicket.filter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>ERROR</dispatcher>
    </filter-mapping>

    <session-config>
        <session-timeout>7200</session-timeout>
    </session-config>

</web-app>
Boris the Spider
  • 59,842
  • 6
  • 106
  • 166
evilkorona
  • 87
  • 2
  • 10
  • You can see here `java.lang.NullPointerException` that your Spring context is misconfigured. – Boris the Spider Apr 22 '14 at 19:59
  • I shall modify this part? contextConfigLocation classpath*:/META-INF/persistence-context.xml, classpath*:/META-INF/service-context.xml, classpath*:/META-INF/web-context.xml – evilkorona Apr 22 '14 at 20:03
  • Not sure what your syntax is, but I don't believe that `classpath*/...` is valid. Try with `classpath:/META-INF/*context.xml`. – Boris the Spider Apr 22 '14 at 20:07
  • Thst is valid, i used it before, but i saw an error in my web-context.xml where it says that doesn't found a bean. – evilkorona Apr 22 '14 at 20:19
  • Your issue is around NPE for `ClassLoader` for `SpringProperties`. Here is the same: http://stackoverflow.com/questions/22864931. Let's try to understand why `ClassLoader` is `null` from that static initializer. – Artem Bilan Apr 22 '14 at 20:26
  • what is your spring version? – bhdrk Apr 22 '14 at 20:31
  • It doesn't matter. Seems for me the Spring bug, because: http://stackoverflow.com/a/1921281/2756547. What does the `bootstrap class loader` mean ? – Artem Bilan Apr 22 '14 at 20:32
  • Where are your spring jars (e.g. `spring-core`) located relative to Tomcat ? – Artem Bilan Apr 22 '14 at 20:39
  • My spring version is 3.0.5.RELEASE, and i have the spring jars (of differnet versions) in the server tomcat classpath (server double right click -> open launch configration -> classpath in bootstrap entries) – evilkorona Apr 22 '14 at 22:18
  • Here is the code http://tip-dorrego.googlecode.com/svn/trunk/ – evilkorona Apr 22 '14 at 22:25
  • Well, can you move Spring jars somewhere else, not `bootstrap` classloader ? – Artem Bilan Apr 23 '14 at 07:58
  • BTW, the issue is fixed now in Spring: https://jira.spring.io/browse/SPR-11721 – Artem Bilan Apr 23 '14 at 21:53

0 Answers0