I have developed simple application connects to the database, shows user the data in the table on JSP page.
Development Environment:
1. Eclipse Europa
2. Tomcat plug-in Eclipse Tomcat Launcher plugin Sysdeo(http://www.eclipsetotale.com/tomcatPlugin.html)
3. Tomcat 6.0.14(With JDK 1.5)
4. JDK 1.6 in eclipse.
The application was running quite fine in integrated environment with tomcat plugin and same tomcat.
I exported the project as a directory in the tomcat webapps directory and fired up the tomcat then I found following error in the
SEVERE: Servlet /webserverinfo threw load() exception
javax.servlet.UnavailableException: Parsing error processing resource path jndi:/localhost/webserverinfo/WEB-INF/struts-config.xml at org.apache.struts.action.ActionServlet.handleConfigException(ActionServlet.java:761) at org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.java:744) at org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:689) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:356) at javax.servlet.GenericServlet.init(GenericServlet.java:212) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4045) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4351) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardHost.start(StandardHost.java:719) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:566) 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 org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Solution:
· I referred all the google post for this problem . Everyone says this is problem related with struts-configuration file.
· I verified my struts-config.xml file and it was correct.
· The message from the exception provided above is generic and misleading too.
· I decided to enable debugging for tomcat and struts.
· To enable debugging for tomcat I modified file
All the fine were replaced by ALL.
Enable the logging for struts by adding log4j.properties file
-----------------------------------------------------------------------------------------------------------------------
log4j.rootLogger=ALL,stdout,R
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%5p] %d{mm:ss} (%F:%M:%L)%n%m%n%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=[%5p] %d{mm:ss} (%F:%M:%L)%n%m%n%n
log4j.appender.R.File=example.log
--------------------------------------------------------------------------------------------------------------------------------
Then I found in the example.log file the problem was related
java.lang.reflect.InvocationTargetException 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)
.
.
Caused by: java.lang.UnsupportedClassVersionError: Bad version number in .class file at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:620) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1817) at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:872) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1325) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204) at org.apache.struts.config.FormBeanConfig.formBeanClass(FormBeanConfig.java:612) at org.apache.struts.config.FormBeanConfig.setType(FormBeanConfig.java:166).
Now the problem is clear. I was having compiled the application java file in JDK 1.6 and tomcat was running on JDK 1.5.
I wasted my 6 hours to get this.
Conclusion:
My reservations are that struts doesn’t show the correct message
My suggestion is if you are using STRUTS during development keep enabled the debug so that you won’t waste your time.