Elvira Elvira - 29 days ago 16
Java Question

ClassNotFoundException JSP

I'm having a classNotFoundException in my jsp.
enter image description here

Code in my JSP:

<%@ page import="Model.Pattern" %>

<% Pattern p = new Pattern("test");%>


Can you guys tell me what's wrong with it ? I've enclosed a screenshot of the exception and the tree where the files are based.

Thanks very much.

Second error:
enter image description here

Pattern class:

package Model;
import java.io.Serializable;
import java.util.ArrayList;
import java.io.File;

public class Pattern implements Serializable {
/**
*
*/
private static final long serialVersionUID = -2262846250404779815L;
private String name;
private String allConsequences;
private Context context;
private String allProblems;
private String allSolutions;
private File diagram;

public Pattern(String nm){
name =nm;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public File getDiagram(){
return diagram;
}

public void setDiagram(File dia){
this.diagram = dia;
}

public Context getContext() {
return context;
}

public void setContext(Context context) {
this.context = context;
}

public String getAllConsequences() {
return allConsequences;
}

public void setAllConsequences(String allConsequences) {
this.allConsequences = allConsequences;
}

public String getAllProblems() {
return allProblems;
}

public void setAllProblems(String allProblems) {
this.allProblems = allProblems;
}

public String getAllSolutions() {
return allSolutions;
}

public void setAllSolutions(String allSolutions){
this.allSolutions = allSolutions;
}

}

Answer

I think the problem here is that you have specified a constructor with parameters in your Pattern class:

public Pattern(String nm){
    name =nm;
}

In that case the default constructor need to be implemented too otherwise you can't instantiate this class, try to add it to your class:

public Pattern(){  
}