Hello,
I have embedded jetty into my java application.
I also have created a web application (one servlet) that has a
ThreadPoolExecutor and it received POST requests, decodes them and
submit the decoded task to the ThreadPoolExecutor.
If a deploy the web application with Tomcat or Jetty (started
normally), then everything works fine.
But, it does not work with jetty embedded.
What is it possible to go wrong ?
Since the war runs well on standalone servers, what is the difference
on the embedded jetty ?
I post some code:
1. Here is how I embed jetty:
//start service
public void start() throws Exception {
jetty = new org.eclipse.jetty.server.Server(ListeningPort);
//start Jetty Server
try {
WebAppContext webapp = new WebAppContext();
webapp.setContextPath("/");
webapp.setWar("c:\\pGams\\WebApplication1.war");
webapp.setDefaultsDescriptor("c:\\pGams\\webdefault.xml");
jetty.setHandler(webapp);
jetty.start();
jetty.join();
} catch (Exception ex) {
Logger.getLogger(pGAMS_Server.class.getName()).severe("Failed load
jetty: "+ ex.toString());
}
}
2. Here is how the servlet works
@Override
protected void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html; charset=UTF-8");
PrintWriter out = new PrintWriter(new
OutputStreamWriter(response.getOutputStream(), "UTF8"), true);
GamsProblemMimeMessage gPmm = new
GamsProblemMimeMessage(request.getInputStream());
GamsProblem gp = gPmm.getGamsProblem();
GamsProblemProcessor gpPr = new GamsProblemProcessor(gp,new
String[] {"gdx=results"});
jobServer.submit(gpPr); //THIS IS THE ThreadPoolExecutor
}
Thanks
Dimitris
|