Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Java JSP struts
Error(1,32): cannot access class com.opensymphony.xwork2.ActionContext; class file has wrong version 49.0, should be 45.3 or 46.0 or 47.0 or 48.0
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import java.util.Map;
 
public class loginAction extends ActionSupport 
{
private String userId;
  private String password;
  public String execute() throws Exception{
 
    if ("admin".equals(userId) && "admin".equals(password)) {
      Map session = ActionContext.getContext().getSession();
      session.put("logged-in","true");
            return SUCCESS;
        }
    else{
       return ERROR;
    }
    }
 
    public String logout() throws Exception {
 
    Map session = ActionContext.getContext().getSession();
    session.remove("logged-in");
        return SUCCESS;
    }
 
    public String getPassword() {
        return password;
    }
 
    public void setPassword(String password) {
        this.password = password;
    }
 
    public String getUserId() {
        return userId;
    }
 
    public void setUserId(String userId) {
        this.userId = userId;
    }
}
Posted 31-Mar-11 1:35am
Edited 31-Mar-11 1:45am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This means you compiled a class with the wrong java version (49.0 is Java 1.5, I think) and it seems in this case you try to run it in an older Java-VM...
 
Try to set the javac to compile for an older Version e.g. 1.4 and retry.
 
You can set this in your build files - assuming ant it would look like this:
 
<javac srcdir="${src.dir}" destdir="${bin.dir}" debug="on" deprecation="off" optimize="off" includes="**" source="1.4" target="1.4" fork="yes" memoryMaximumSize="256m" encoding="utf-8">
    <classpath refid="build.classpath" />
</javac>
 

 
Hope this helps,
Cheers, Arndt
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Marcin Kozub 265
1 Richard MacCutchan 239
2 OriginalGriff 208
3 Sergey Alexandrovich Kryukov 185
4 Praneet Nadkar 167
0 OriginalGriff 7,913
1 Sergey Alexandrovich Kryukov 7,232
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,865


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 31 Mar 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100