servlet连接EJB问题
在编译过程中出现这个问题:
"Servlet1.java": create(java.lang.String) in vg.GoodHome cannot be applied to () at line 35, column 22
servlet1代码如下:
package vg;
import java.io.*;
import java.util.*;
import javax.naming.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Servlet1 extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=GBK";
private GoodHome GoodHome;
private Good Good;
public String sa;
public String price;
public void init(ServletConfig config) throws ServletException {
super.init(config);
try {
String initCtxFactory = getInitParameter(Context.INITIAL_CONTEXT_FACTORY);
String providerURL = getInitParameter(Context.PROVIDER_URL);
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, "t3://localhost:7001");
Context ctx = new InitialContext(env);
GoodHome = (GoodHome)ctx.lookup("Good");
Good =GoodHome.create();
sa = Good.getName();
price = Good.getPassword();
}
catch (Exception e) {
throw new ServletException(e.toString());
}
}
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>MyfirstServlet</title></head>");
out.println("<body bgcolor=\"#fffff0\">");
out.println("<p>The servlet has received a GET. This is the reply.</p>");
out.println("<p>the response from EJB is:" + sa + "</p>");
out.println("<p>the response from EJB is:" + price + "</p>");
out.println("</body></html>");
}
//Clean up resources
public void destroy() {
}
}