HTTP 500 when getting an input stream from a URLConnection
stevepark Aug 1, 2002 12:11 PMMy application consists of a swing applet connecting to a layer of servlets to pass serialized objects. On JBoss 2.4.x this worked fine. I'm currently migrating to JBoss 3.0.0 and now I'm getting a HTTP 500 error message in my browser's applet console. I have all my loggers set to Debug and no error messages are showing up anywhere in the server logs. I'm suspecting this is a configuration issue because I still get the HTTP 500 message even when I comment out all of the code in my service methods in the servlet.
My web.xml file:
<?xml version="1.0"?>
<web-app>
<context-param>
<param-name>EDITPORTFOLIO_PATH</param-name>
<param-value>/AccountManager/EditPortfolioInfoServ</param-value>
</context-param>
<servlet-name>EditPortfolioInfoServ</servlet-name>
<servlet-class>Servlets.EditPortfolioInfoServ</servlet-class>
<load-on-startup>5</load-on-startup>
<servlet-mapping>
<servlet-name>EditPortfolioInfoServ</servlet-name>
<url-pattern>/EditPortfolioInfoServ/*</url-pattern>
</servlet-mapping>
<ejb-ref>
<ejb-ref-name>StudentSession</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
ejb.session.StudentSessionHome
ejb.session.StudentSession
<ejb-link>StudentSession</ejb-link>
</ejb-ref>
</web-app>
My jboss-web.xml file:
<?xml version="1.0"?>
<jboss-web>
<ejb-ref>
<ejb-ref-name>StudentSession</ejb-ref-name>
<jndi-name>StudentSession</jndi-name>
</ejb-ref>
</jboss-web>
My servlet java file:
public class EditPortfolioInfoServ extends HttpServlet {
private StudentSession stdntSession;
public void init(ServletConfig config) throws ServletException {
super.init(config);
try {
StudentSessionHome stdntSessionHome = (StudentSessionHome)PortableRemoteObject.narrow(new InitialContext().lookup("StudentSession"), StudentSessionHome.class);
stdntSession = stdntSessionHome.create();
}
catch(Exception e) {
e.printStackTrace();
}
}
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
try {
ObjectOutputStream out = new ObjectOutputStream(new GZIPOutputStream(new BufferedOutputStream(res.getOutputStream())));
Integer studentID = new Integer(req.getParameter("stdnt"));
tFolioInfo tfiInfo = stdntSession.getInitValues(studentID);
out.writeObject(tfiInfo);
out.flush();
out.close();
}
catch(Exception e) {
e.printStackTrace();
}
}
}
Here's the applet client code that connects to the Servlet:
tFolioInfo tfiInfo = null;
try {
URL url = new URL("https://" + Common.HTTP_HOST + "/" + Common.SERVROOT + "/EditPortfolioInfoServ?stdnt=" + studentID);
URLConnection con = url.openConnection();
con.setUseCaches(false);
ObjectInputStream in = new ObjectInputStream(new GZIPInputStream(new BufferedInputStream(con.getInputStream())));
tfiInfo = (tFolioInfo)in.readObject();
in.close();
}
catch(Exception e) {
e.printStackTrace();
}
If anyone sees anything wrong here, please let me know ASAP. I'm under a major deadline to get this out.