John Wan John Wan - 1 year ago 122
Java Question

Glassfish 4.1 unnecessary re-deployment

As titled, the GlassFish 4.1 server decided to mess my head up with some random re-deployment to my web-application, which removes all my attributes within the session but somehow keeping the session ID intact.

This problem mostly occurs when I'm trying to select a combo-box which triggers the form submit where it will be sent to a Servlet to gathers the necessary information from the database to populate necessary text fields in the same form (done by JSP), the reason why I'm unable to root the problem because it happens on the third or fourth select attempt, sometimes it doesn't even happen at all.

The server logs doesn't help much at all, as these are the only messages that pops up whenever it decides to redeploy.

Server Logs:

Info: visiting unvisited references
Info: visiting unvisited references
Info: visiting unvisited references
Info: WebModule[null] ServletContext.log():filter_user:Initializing filter
Info: Loading application [IMS_Test] at [/IMS_Test]
Info: IMS_Test was successfully deployed in 558 milliseconds.

Servlet Code:

List<String> list = new ArrayList<String>();
rs = stmt.executeQuery("SELECT scp_id FROM ims_db.ims_scp_list WHERE scp_name = '" + t_scp_name + "'");

if ( {
scp_id = rs.getString("scp_id");

rs = stmt.executeQuery("SELECT epicor_id FROM ims_db.ims_parts_plan "
+ "WHERE scp_id = '" + scp_id + "'");

while ( {
RequestDispatcher rd = request.getRequestDispatcher("new_entryform.jsp");

session.setAttribute("epicor_list", list);
session.setAttribute("scp_name", t_scp_name);
rd.forward(request, response);

So the question, what have I done wrong that eventually forces GlassFish to redeploy my web-app in the midst of operation? Please help me out :(

Out of desperation I've created a SessionListener to see what's wrong. During debug it shows that all the codes were executed as expected , but sometimes it'll jump to "attributeRemoved" right after that, which really makes no sense.

Last resort, split the original form into two separate forms where one uses GET method while the main form uses the POST method. It solves the problem, for now.

The issues still bothering me whenever I'm trying to submit the forms to the server, but it only happens in POST method. Tried upgrading to GlassFish 5.0 (nightly build) but the problems doesn't seems to bug off. Any guidance / suggestion will be greatly appreciated. :(

Answer Source

After weeks of struggling I've finally found the answer. Apparently the random redeployments were caused by improper settings of @MultipartConfig annotations in the servlet I'm trying to access to.

Changing it to the following solved the issues :

@MultipartConfig(location="\fileDest", fileSizeThreshold=1024*1024, 
maxFileSize=1024*1024*5, maxRequestSize=1024*1024*5*5)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download