Wednesday, October 13, 2010

Fixing org.apache.jasper.JasperException: PWC6180: Unable to initialize TldScanner Error on GlassFish 3.0.1

If you get the following error when running a Java EE 6 / JSF 2.0 web application in GlassFish 3.0.1 :

Oct 14, 2010 1:05:26 AM org.apache.catalina.core.StandardContext callServletContainerInitializers
SEVERE: PWC1420: Error invoking ServletContainerInitializer org.apache.jasper.runtime.TldScanner
org.apache.jasper.JasperException: PWC6180: Unable to initialize TldScanner
at org.apache.jasper.runtime.TldScanner.scanTlds(TldScanner.java:287)
at org.apache.jasper.runtime.TldScanner.onStartup(TldScanner.java:228)
at org.apache.catalina.core.StandardContext.callServletContainerInitializers(StandardContext.java:5352)
at com.sun.enterprise.web.WebModule.callServletContainerInitializers(WebModule.java:550)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5263)
at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:928)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:912)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1947)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1619)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:90)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:126)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:236)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:339)
at org.glassfish.kernel.embedded.EmbeddedDeployerImpl.deploy(EmbeddedDeployerImpl.java:214)
at org.glassfish.kernel.embedded.EmbeddedDeployerImpl.deploy(EmbeddedDeployerImpl.java:144)
at org.glassfish.maven.RunMojo.execute(RunMojo.java:98)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:195)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:140)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:314)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:151)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:445)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:168)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:132)
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:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class com.sun.appserv.web.taglibs.cache.CacheContextListener
at org.apache.catalina.core.StandardContext.addListener(StandardContext.java:2659)
at org.apache.catalina.core.StandardContext.addListener(StandardContext.java:2642)
at org.apache.catalina.core.ApplicationContext.addListener(ApplicationContext.java:1270)
at org.apache.catalina.core.ApplicationContextFacade.addListener(ApplicationContextFacade.java:665)
at org.apache.jasper.runtime.TldScanner.addListener(TldScanner.java:435)
at org.apache.jasper.runtime.TldScanner.scanJar(TldScanner.java:420)
at org.apache.jasper.runtime.TldScanner.scanJars(TldScanner.java:633)
at org.apache.jasper.runtime.TldScanner.scanTlds(TldScanner.java:282)
... 39 more

The solution is to update the jsp-impl.jar library file since GlassFish 3.0.1 used an older and buggy one.

Download the newest jsp-impl.jar from http://download.java.net/maven/2/org/glassfish/web/jsp-impl/
(currently the newest version is 2.2.2-b03)

Overwrite the file in ${GLASSFISH_HOME}/glassfish/modules/jsp-impl.jar with the new jsp-impl.jar (rename the file to omit the version number).

Now your Java EE applications should run just fine. I also run a mixed Java EE/Scala web application and it runs fine with the new jsp-impl.jar.