So you think you are an Java uber-geek? Then figure this one out. . .

Ok, uber-Java geeks, let's see if you can figure this one out. It' s butt-ugly and got me totally stumped.

This is in a Tomcat 5.5 environment.

I have a jsp (hierarchy.jsp) which has static nested class called MgmtAuthBean. This hierarchy.jsp creates a TreeMap object which contains instances of the static nested class, MgmtAuthBean. So, after compilation of the hierarchy.jsp, I end having 2 jsp's:

hierarchy_jsp.java <==== original jsp

hierarchy_jsp$MgmtAuthBean.java <==== nested static class jsp

Ok, easy to understand so far. . .now for the rub. . .

The hierarchy_jsp.java then saves the TreeMap object in a session.

Another servlet (ExcelServlet) then accesses this saved session object, but in the process of reconstituting the TreeMap object, it requires access to the nested static class hierarchy_jsp$MgmtAuthBean.java.

The problem is that ExcelServlet craters because it can't find hierarchy_jsp$MgmtAuthBean.java in order to reconstitute the TreeMap object.

Since jsp's are dynamically created when called, how do I point either the Tomcat container or ExcelServlet to hierarchy_jsp$MgmtAuthBean.java?

For reason's too stupid to explain, I can't get rid of the static nested class, so I have to figure out how to make this work. . .

:)

[1335 byte] By [megaskinsa] at [2007-11-27 11:05:22]
# 1

Tomcat provides a utility for pre-compiling JSP into Servlet class files. This can also be done in ANT. You can precompile the JSP which will create the inner class file and then compile the Java files that need the inner class file. It may take some tweaking to get all of the classes to compile in the correct order.

A possible alternative is t have the inner class implement an interface. the hierarchy_jsp can then refer to the contents of the TreeMap as instances of the interface instead of as instances of the inner class.

tolmanka at 2007-7-29 13:08:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

I have seen the same problem, but instead of between two different .jsps, between two different JVMs, when the session is replicated.

My solution was to remove the inner class and only use standard java collections to hold the values.

It sounds like you can't move the static inner class into a .jar file.

So you might try writing your own serialization logic, for example storing all the fields individually in the Session object, rather than the object itself. Then duplicate the code in the other .jsp file.

jleecha at 2007-7-29 13:08:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...