Nice exception if JAI is not installed

Description

Hi,

I've made a clean installation of the JDK 1.4.2_04, i.e. without (yet) the JAI extension.

http://localhost:8080/geoserver/wms?request=GetMap&layers=bc_roads&bbox=489153,5433000,529000,5460816&width=800&height=400&srs=EPSG:27354&styles=normal&Format=image/png - http://localhost:8080/geoserver/wms?request=GetMap&layers=bc_roads&bbox=489153,5433000,529000,5460816&width=800&height=400&srs=EPSG:27354&styles=normal&Format=image/png

... returns an exception whose stack trace is :

UNCAUGHT EXCEPTION: java.lang.NoClassDefFoundError: javax/media/jai/ComponentSampleModelJAI at org.geotools.io.image.TextImageReader$Spi.<clinit>(TextImageReader.java:356) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:219) at sun.misc.Service$LazyIterator.next(Service.java:270) at javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(IIORegistry.java:174) at javax.imageio.spi.IIORegistry.<init>(IIORegistry.java:113) at javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:134) at javax.imageio.ImageIO.<clinit>(ImageIO.java:46) at org.vfny.geoserver.responses.wms.map.JAIMapResponse.getSupportedFormats(JAIMapResponse.java:114) at org.vfny.geoserver.responses.wms.GetMapResponse.<clinit>(GetMapResponse.java:51) at org.vfny.geoserver.servlets.wms.GetMap.getResponseHandler(GetMap.java:45) at org.vfny.geoserver.servlets.AbstractService.doService(AbstractService.java:347) at org.vfny.geoserver.servlets.AbstractService.doGet(AbstractService.java:233) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.vfny.geoserver.servlets.wms.WmsDispatcher.doResponse(WmsDispatcher.java:135) at org.vfny.geoserver.servlets.wms.WmsDispatcher.doGet(WmsDispatcher.java:106) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530) at java.lang.Thread.run(Thread.java:534)

and (this may not be related with JAI however) http://localhost:8080/geoserver/wms?request=GetMap&layers=bc_roads&bbox=489153,5433000,529000,5460816&width=800&height=400&srs=EPSG:27354&styles=normal&Format=image/svg+xml - http://localhost:8080/geoserver/wms?request=GetMap&layers=bc_roads&bbox=489153,5433000,529000,5460816&width=800&height=400&srs=EPSG:27354&styles=normal&Format=image/svg+xml

... returns an exception whose stack trace is :

UNCAUGHT EXCEPTION: java.lang.NoClassDefFoundError at org.vfny.geoserver.servlets.wms.GetMap.getResponseHandler(GetMap.java:45) at org.vfny.geoserver.servlets.AbstractService.doService(AbstractService.java:347) at org.vfny.geoserver.servlets.AbstractService.doGet(AbstractService.java:233) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.vfny.geoserver.servlets.wms.WmsDispatcher.doResponse(WmsDispatcher.java:135) at org.vfny.geoserver.servlets.wms.WmsDispatcher.doGet(WmsDispatcher.java:106) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530) at java.lang.Thread.run(Thread.java:534)

I don't know of an elegant way to detect if JAI is installed (maybe a Class.forName() call ?) but, IMHO, those exceptions should be caught an return a more user-friendly message.

OK : stack traces are now archived, I can now install the JAI extension and continue my tests <img class="emoticon" src="https://jira.codehaus.org/images/icons/emoticons/smile.gif" height="16" width="16" align="absmiddle" alt="" border="0"/>

Cheers,

p.b.

Environment

None

Activity

Show:
codehaus
April 10, 2015, 4:25 PM

CodeHaus Comment From: jmacgill - Time: Thu, 22 Apr 2004 17:11:33 -0500
---------------------
<p>Not actualy a depends upon, more a 'related to'.</p>

codehaus
April 10, 2015, 4:25 PM

CodeHaus Comment From: brihaye - Time: Thu, 22 Apr 2004 18:11:09 -0500
---------------------
<p>Hi,</p>

<p>Notice that :</p>

<p>java.lang.NoClassDefFoundError: javax/media/jai/ComponentSampleModelJAI at org.geotools.io.image.TextImageReader$Spi.</p>

<p>...would suggest that it is a Geotools problem rather than a Geoserver one.</p>

<p>IMHO, when a class' imports can't be resolved at runtime, it is <b>this</b> class' job to notify the other classes that it can't honour its contract. </p>

<p>I even wonder if this should raise an exception (vs. a value like "isReady") since missing packages are not such an exceptionnal situation <img class="emoticon" src="https://jira.codehaus.org/images/icons/emoticons/smile.gif" height="16" width="16" align="absmiddle" alt="" border="0"/></p>

<p>Cheers,</p>

<p>p.b.</p>

codehaus
April 10, 2015, 4:25 PM

CodeHaus Comment From: cholmes - Time: Thu, 22 Apr 2004 22:50:22 -0500
---------------------
<p>Hmmm... This used to work. I'll test it out again. Maybe it's because of the call to new LiteRenderer in the code to actually draw the map? Does you getCaps choke? And does it return all the formats or just svg? Because it definitely has a try block around the new renderer, which should catch the class not found exception and then report back that it can't support stuff. This is with 1.2.0-rc1, yes?</p>

codehaus
April 10, 2015, 4:25 PM

CodeHaus Comment From: brihaye - Time: Fri, 23 Apr 2004 03:01:18 -0500
---------------------
<p>Hi,</p>

<p>&gt;This is with 1.2.0-rc1, yes?</p>

<p>The CVS version dating from... say... 1 hour before my post <img class="emoticon" src="https://jira.codehaus.org/images/icons/emoticons/smile.gif" height="16" width="16" align="absmiddle" alt="" border="0"/></p>

<p>Regarding your possible explanations, I will try to investigate further in the day.</p>

<p>Cheers,</p>

<p>p.b.</p>

codehaus
April 10, 2015, 4:25 PM

CodeHaus Comment From: cholmes - Time: Fri, 18 Jun 2004 20:18:33 -0500
---------------------
<p>Ok, expanded the try block to the ImageIO.getWriterTypes, as it looks like liteRenderer no longer eats it if things aren't right, but the getMIMETypes does. So it's now in the try block.</p>

Fixed

Assignee

Unassigned

Reporter

codehaus

Triage

None

Fix versions

Affects versions

Components

Priority

Low