I'm having a classNotFoundException in my jsp.
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:
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;
}
}
When the file is there but still throws a ClassNotFoundException
this most of the times mean that the JSP
could not compile.
Now looking at the error Only a type can be imported, Model.Pattern resolve to a package
I'm pretty sure you want to change
<%@ page import="Model.Pattern" %>
to
<%@ page import="Model.Pattern.*" %>
Now for other people that might have the same error, and that the file does actually compile, note that sometime the cache need to be flushed.
For example with tomcat, simply delete all the files in the work
directory.
Looking at your edit, it confirms that the problem is in the import. The 2 other errors only happen because Pattern
was not imported. But your import
seems correct to me, have you tried to flush the cache like I said ? Also you should try to re-type the import statement, maybe you accidentaly typed a control char. Another thing to try would be of deleting the deleted folders (the extracted content of the war) to make sure tomcat re-deploy them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With