0

I've created a java bean (just very simple for the time being because I want to get it working mostly) called "Folders" I've exported it as a .jar file and placed it in the /WEB-INF/lib/ directory. However, when I try to use it on the intended pages I get this error (I can add the res of the long statement if need be):

Feb 22, 2013 12:02:31 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.UnsupportedClassVersionError: com/mysite/folders/Folders : Unsupported major.minor     version 51.0 (unable to load class com.mysite.folders.Folders)

Here's the bean if it might be what is causing the issue:

package com.mysite.folders;

import java.io.Serializable;
import java.util.ArrayList;

public class Folders implements Serializable {

private String accountNumber;
private String folderName;
private String groupName;
private ArrayList<String> folderNames;
private ArrayList<String> groupNames;       

public String getAccountNumber() {
    return accountNumber;
}

public void setAccountNumber(String accountNumber) {
    this.accountNumber = accountNumber;
}

public String getFolderName() {
    return folderName;
}

public void setFolderName(String folderName) {
    this.folderName = folderName;
}

public String getGroupName() {
    return groupName;
}

public void setGroupName(String groupName) {
    this.groupName = groupName;
}

public ArrayList<String> getFolderNames() {
    return folderNames;
}

public void setFolderNames(ArrayList<String> folderNames) {
    this.folderNames = folderNames;
}

public ArrayList<String> getGroupNames() {
    return groupNames;
}

public void setGroupNames(ArrayList<String> groupNames) {
    this.groupNames = groupNames;
}

public Folders(String accountNumber, String folderName, String groupName,
        ArrayList<String> folderNames, ArrayList<String> groupNames) {
    super();
    this.accountNumber = accountNumber;
    this.folderName = folderName;
    this.groupName = groupName;
    this.folderNames = folderNames;
    this.groupNames = groupNames;
}
}

And finally my statement on the page:

<jsp:useBean id="Folders" scope="session" class="com.mysite.folders.Folders" />

I feel like I did this properly and am uncertain why this wouldn't be working. Any advice or tips would be much appreciated.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Hirthas
  • 359
  • 2
  • 13
  • 1
    Have you searched on the exact error message ["Unsupported major.minor version 51.0"](http://stackoverflow.com/search?q=Unsupported+major.minor+version+51.0)? You're definitely not the first one who get that. Note that this problem is completely unrelated to JSP/Javabeans. It's just basic Java, as indicated by the `java.lang` package of the `java.lang.UnsupportedClassVersionError`. If you had a real JSP problem, you'd have gotten an exception/error of `javax.servlet.jsp` package. – BalusC Feb 22 '13 at 18:26
  • possible duplicate of [Java, UnsupportedClassVersionError. How can I fix this](http://stackoverflow.com/questions/8350355/java-unsupportedclassversionerror-how-can-i-fix-this) – Brian Roach Feb 22 '13 at 18:27
  • which version of jdk you are using? – subodh Feb 22 '13 at 18:28
  • maybe you will find help with this post: [see here][1] [1]: http://stackoverflow.com/questions/2466828/java-lang-unsupportedclassversionerror-bad-version-number-in-class-file – Cygnusx1 Feb 22 '13 at 18:29

4 Answers4

2

Check that your compiler and tomcat are using the same version of Java.

hd1
  • 33,938
  • 5
  • 80
  • 91
2

Seems like you are using JDK7 for compiling and Lower version on Where you are using it

See Wikipedia code on

major version number of the class file format being used.

J2SE 7 = 51 (0x33 hex).

As all suggested see thisone also How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version

Community
  • 1
  • 1
Suresh Atta
  • 120,458
  • 37
  • 198
  • 307
0

You are compiling using a later JDK than you are running under.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
0

you are using multiple compilers: you used one for creating the jar (probably the newest JDK 7) and are using the other one for Tomcat. The first thing to do is:

  • go to your program files/java and check for jdks
  • go to properties/environment variables and set JAVA_HOME to the newst sdk possible (it should point at the root of jdk instead of bin library or anything else)
fdreger
  • 12,264
  • 1
  • 36
  • 42