I have this very odd problem with Java (using Eclipse as IDE). I’m working on an EJB & Servlet assignment and I exported the EJB interface & helper classes as a JAR file. When I import the JAR into the Servlet project, I can’t access one of the public methods. I tested the JAR file by starting another project and I can access all the helper class’s public methods in the JAR.
The key difference between the Servlet project and the tester project is that the Servlet project was using an older version of the JAR. I added 1 new public method and re-export & re-import the JAR and the problem persisted.
package helper;
public class RespCodeType {
private String code,msg,output;
public RespCodeType()
{
code = "";
msg = "";
output ="";
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getOutput() {
setOutput(new String("Result: " + code + ". " + msg + "."));
return output;
}
public void setOutput(String output) {
this.output = output;
}
}
I added the “output” getter & setter but for some reason it just won’t access it when I export & import the modified JAR.
It turns out that I imported the JAR incorrectly. I initially placed a copy of the JAR under WEB-INF/lib which conflicted with the later import which I simply copied to the workspace directory and added to build path. Once I deleted the JAR from WEB-INF/lib the problem is resolved.