Announcement Announcement Module
Collapse
No announcement yet.
Exception after deploying java.lang.ExceptionInInitializerError Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exception after deploying java.lang.ExceptionInInitializerError

    Hello

    Our project involves struts2 + spring + iBatis on Sun App server 8.2. Like a lot of other users we had the 'locking jars' issue when ear was deployed. Due to this every code change we had to undeploy the ear, stop the server, delete the project folder manually, start the server, deploy the ear again.

    To overcome the 'locking jars' issue we recently built an ANT script which unlocks a folder in windows environemnt. Using this we dont have to start/stop the server for ever undeploy/deployment of EAR.

    Now we can successfully undeploy the ear and deploy it w/out starting/stoping the server BUT when trying to access the site we get the following error

    Code:
    Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    java.lang.ExceptionInInitializerError
    	at org.springframework.web.context.ContextLoaderListener.createContextLoader(ContextLoaderListener.java:57)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:48)
    	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4010)
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4522)
    	at com.sun.enterprise.web.WebModule.start(WebModule.java:241)
    	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:827)
    	at org.apache.catalina.core.ContainerBase.access$000(ContainerBase.java:125)
    	at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run(ContainerBase.java:147)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:809)
    	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:646)
    	at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1331)
    	at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1040)
    	at com.sun.enterprise.web.WebContainer.loadJ2EEApplicationWebModules(WebContainer.java:967)
    	at com.sun.enterprise.server.TomcatApplicationLoader.load(TomcatApplicationLoader.java:104)
    	at com.sun.enterprise.server.ApplicationManager.applicationDeployed(ApplicationManager.java:229)
    	at com.sun.enterprise.server.ApplicationManager.applicationDeployed(ApplicationManager.java:164)
    	at com.sun.enterprise.server.ApplicationManager.applicationDeployed(ApplicationManager.java:499)
    	at com.sun.enterprise.admin.event.AdminEventMulticaster.invokeApplicationDeployEventListener(AdminEventMulticaster.java:872)
    	at com.sun.enterprise.admin.event.AdminEventMulticaster.handleApplicationDeployEvent(AdminEventMulticaster.java:856)
    	at com.sun.enterprise.admin.event.AdminEventMulticaster.processEvent(AdminEventMulticaster.java:424)
    	at com.sun.enterprise.admin.event.AdminEventMulticaster.multicastEvent(AdminEventMulticaster.java:139)
    	at com.sun.enterprise.admin.server.core.DeploymentNotificationHelper.multicastEvent(DeploymentNotificationHelper.java:288)
    	at com.sun.enterprise.deployment.phasing.DeploymentServiceUtils.multicastEvent(DeploymentServiceUtils.java:155)
    	at com.sun.enterprise.deployment.phasing.ServerDeploymentTarget.sendStartEvent(ServerDeploymentTarget.java:258)
    	at com.sun.enterprise.deployment.phasing.StartPhase.runPhase(StartPhase.java:87)
    	at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:71)
    	at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:639)
    	at com.sun.enterprise.deployment.phasing.PEDeploymentService.start(PEDeploymentService.java:361)
    	at com.sun.enterprise.deployment.phasing.PEDeploymentService.start(PEDeploymentService.java:396)
    	at com.sun.enterprise.admin.mbeans.ApplicationsConfigMBean.start(ApplicationsConfigMBean.java:702)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at com.sun.enterprise.admin.MBeanHelper.invokeOperationInBean(MBeanHelper.java:305)
    	at com.sun.enterprise.admin.config.BaseConfigMBean.invoke(BaseConfigMBean.java:360)
    	at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(DynamicMetaDataImpl.java:213)
    	at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:220)
    	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:815)
    	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:784)
    	at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at com.sun.enterprise.admin.util.proxy.ProxyClass.invoke(ProxyClass.java:54)
    	at $Proxy1.invoke(Unknown Source)
    	at com.sun.enterprise.admin.server.core.jmx.SunoneInterceptor.invoke(SunoneInterceptor.java:272)
    	at com.sun.enterprise.admin.jmx.remote.server.callers.InvokeCaller.call(InvokeCaller.java:38)
    	at com.sun.enterprise.admin.jmx.remote.server.MBeanServerRequestHandler.handle(MBeanServerRequestHandler.java:92)
    	at com.sun.enterprise.admin.jmx.remote.server.servlet.RemoteJmxConnectorServlet.processRequest(RemoteJmxConnectorServlet.java:69)
    	at com.sun.enterprise.admin.jmx.remote.server.servlet.RemoteJmxConnectorServlet.doPost(RemoteJmxConnectorServlet.java:94)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:767)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
    	at sun.reflect.GeneratedMethodAccessor66.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
    	at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
    	at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:257)
    	at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
    	at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263)
    	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    	at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:225)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)
    	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:132)
    	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933)
    	at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:189)
    	at com.sun.enterprise.web.connector.grizzly.ProcessorTask.doProcess(ProcessorTask.java:604)
    	at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:475)
    	at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:371)
    	at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:264)
    	at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:281)
    	at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:83)
    Caused by: java.lang.IllegalStateException: Could not load 'ContextLoader.properties': class path resource [ContextLoader.properties] cannot be opened because it does not exist
    	at org.springframework.web.context.ContextLoader.<clinit>(ContextLoader.java:134)
    	... 83 more
    HOWEVER, if we just restart the server (NOT REDEPLOY) the problem goes away.

    parsing through the stack trace I think this information is somewhat usefull but i am not an expert on spring so hoping someone can help
    Code:
    Caused by: java.lang.IllegalStateException: Could not load 'ContextLoader.properties': class path resource [ContextLoader.properties] cannot be opened because it does not exist
    	at org.springframework.web.context.ContextLoader.<clinit>(ContextLoader.java:134)
    	... 83 more
    I'd appreciate if someone can shed some light on what exactly is causing this error and how it can be resolved. Will make our dev environment somewhat agile.

    Thanks!

  • #2
    bump?

    maybe someone has a clue?

    Comment


    • #3
      That's what Spring is doing, it's nothing Spring-specific:

      Code:
      try {
      	ClassPathResource resource = new ClassPathResource(DEFAULT_STRATEGIES_PATH, ContextLoader.class);
      	defaultStrategies = PropertiesLoaderUtils.loadProperties(resource);
      }
      catch (IOException ex) {
      	throw new IllegalStateException("Could not load 'ContextLoader.properties': " + ex.getMessage());
      }
      where loadProperties fails with an IOException for you. The rest is also no magic:

      ClassPathResource:
      Code:
      public ClassPathResource(String path, Class clazz) {
      	Assert.notNull(path, "Path must not be null");
      	this.path = StringUtils.cleanPath(path);
      	this.clazz = clazz;
      }
      
      public InputStream getInputStream() throws IOException {
      	InputStream is = null;
      	if (this.clazz != null) {
      		is = this.clazz.getResourceAsStream(this.path);
      	}
      	else {
      		is = this.classLoader.getResourceAsStream(this.path);
      	}
      	if (is == null) {
      		throw new FileNotFoundException(
      				getDescription() + " cannot be opened because it does not exist");
      	}
      	return is;
      }
      PropertiesLoaderUtils:
      Code:
      public static Properties loadProperties(Resource resource) throws IOException {
      	Properties props = new Properties();
      	fillProperties(props, resource);
      	return props;
      }
      
      public static void fillProperties(Properties props, Resource resource) throws IOException {
      	InputStream is = resource.getInputStream();
      	try {
      		props.load(is);
      	}
      	finally {
      		is.close();
      	}
      }
      It's the search for the resource on the classpath that returns null and so Spring fails. So it seems the classloader/JVM/whatever is involved does not like the disconnection from the actual jar resources. I have no clue how to fix this.

      Joerg
      Last edited by Jörg Heinicke; Nov 19th, 2007, 10:46 PM.

      Comment

      Working...
      X