I have the following code in BeerSelect.java and is placed in "C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\Beer-v1\WEB-INF\classes\com\example\web" directory. The BeerSelect.class file is also present in this directory.
Check the files in the logs directory for error messages, especially the catalina* files; something should be in there.
vijay kaaman
Greenhorn
Joined: May 18, 2011
Posts: 5
posted
0
I find the following error message.
Nov 17, 2011 11:15:37 PM org.apache.catalina.startup.HostConfig deployDirectory
SEVERE: Error deploying web application directory Beer-v1
java.lang.UnsupportedClassVersionError: com/example/web/BeerSelect : Unsupported major.minor version 51.0 (unable to load class com.example.web.BeerSelect)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2822)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:108)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:58)
at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:297)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1078)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:261)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4612)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
in the catalina.* file
Tim Moores
Rancher
Joined: Sep 21, 2011
Posts: 2407
posted
1
That means you're using a newer Java version (Java 7, specifically) to compile the code than Tomcat uses to run it. The best way to address this is to uninstall all but one JDK from your machine. Whether you choose to keep Java 7 -or maybe Java 6- is up to you; both should work.
Tim Moores wrote:The best way to address this is to uninstall all but one JDK from your machine. Whether you choose to keep Java 7 -or maybe Java 6- is up to you; both should work.
No it's not. This isn't Microsoft, where you can have only one IE. Java is very expressly designed to allow as many different JDK and JVM versions on a machine as you can stand. And (for better or worse), sometimes for business purposes, it's a necessary advantage.
The JDK that's used by Tomcat is the one that is defined by the JAVA_HOME environment variable for the command shell (or equivalent) that's running Tomcat. Want a different JVM? Change that shell's JAVA_HOME. Or create a TOMCAT_HOME\bin\setenv.bat and assign it there.
You can create Java 6-compatible classes without deleting JDKs, as well. The java compiler has options that set what version of Java the output classes should be compatible with. Java is extremely big on backwards compatibility. Or you can just specify the desired compiler JDK in the build process.
Tim Moores
Rancher
Joined: Sep 21, 2011
Posts: 2407
posted
0
Gotta disagree with your disagreement. For someone working at the level of that kind of problem it's almost certainly better (less confusing) not to keep multiple JDKs/JREs installed.