The net is vast
プログラミングや、コンピュータなどの備忘録です。 主にRuby, Java, Linux, 等を扱います。アルゴリズムも扱いたいな。
20:57

Slim3で同名のクラスでClassCastException

Category: , By jx
Slim3で開発しています。 JSPで次のような事をしたところ、例外が発生してしまいました。
<%
List<HotEntry> hotEntryList = (List<HotEntry>) request.getAttribute("hotEntryList");
for (HotEntry entry : hotEntryList) {
%>
<%= entry.getUrl() %>
<%
}
%>
エラーは以下の通り。
java.lang.ClassCastException: net.jirox.acom.model.HotEntry cannot be cast to net.jirox.acom.model.HotEntry
 at org.apache.jsp.index_jsp._jspService(index_jsp.java:57)
 at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
 at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
 at com.google.appengine.tools.development.PrivilegedJspServlet.access$101(PrivilegedJspServlet.java:23)
 at com.google.appengine.tools.development.PrivilegedJspServlet$2.run(PrivilegedJspServlet.java:59)
 at java.security.AccessController.doPrivileged(Native Method)
 at com.google.appengine.tools.development.PrivilegedJspServlet.service(PrivilegedJspServlet.java:57)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
 at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
 at org.slim3.controller.FrontController.doFilter(FrontController.java:288)
 at org.slim3.controller.FrontController.doFilter(FrontController.java:247)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
 at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
 at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
 at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
 at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
 at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
 at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:70)
 at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:268)
 at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:126)
 at org.slim3.controller.HotRequestDispatcherWrapper.forward(HotRequestDispatcherWrapper.java:67)
 at org.slim3.controller.FrontController.doForward(FrontController.java:696)
 at org.slim3.controller.FrontController.doForward(FrontController.java:667)
 at org.slim3.controller.FrontController.handleNavigation(FrontController.java:587)
 at org.slim3.controller.FrontController.processController(FrontController.java:544)
 at org.slim3.controller.FrontController.doFilter(FrontController.java:324)
 at org.slim3.controller.FrontController.doFilter(FrontController.java:285)
 at org.slim3.controller.FrontController.doFilter(FrontController.java:247)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
 at org.slim3.datastore.DatastoreFilter.doFilter(DatastoreFilter.java:54)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
 at org.slim3.controller.HotReloadingFilter.doHotReloading(HotReloadingFilter.java:223)
 at org.slim3.controller.HotReloadingFilter.doFilter(HotReloadingFilter.java:187)
 at org.slim3.controller.HotReloadingFilter.doFilter(HotReloadingFilter.java:157)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
 at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:51)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
 at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
 at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:121)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
 at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
 at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
 at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
 at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
 at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
 at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:70)
 at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
 at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:352)
 at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
 at org.mortbay.jetty.Server.handle(Server.java:313)
 at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
 at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:830)
 at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
 at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
 at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
 at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396)
 at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)
なんだろう。クラスローダが違うのかな?
List hotEntryList = (List) request.getAttribute("hotEntryList");
System.out.println(HotEntry.class.getClassLoader());
System.out.println(hotEntryList.getClass().getClassLoader());
上記のコードを実行してみた。
com.google.appengine.tools.development.IsolatedAppClassLoader@680e2291
null
ん〜?null?こういうコードってこういう風になるんだっけ? どうしたら良いんだろう。
 

1 comment so far.

  1. Unknown 2010年2月24日 11:06
    JSPではJSTLやELを使ってください。

    あるいはHOT reloadingはできなくなりますが、
    web.xmlのHotReloadingFilterをはずしても
    ClassCastExceptionは起きなくなります。

Something to say?