0

EDIT : This has begun working and I have not changed anything, this is the second time that I've encountered this issue, my app works for a while and then just stops suddenly working. Is GAE unreliable when it comes to Spring ? Has anyone else experience similar GAE issues ?

I'm unable to display an animated gif on a jsp page. The gif displays locally but when I put live on app engine server an error is thrown. Here is my setup :

Ive added the images dir in appengine-web.xml :

<static-files> <include path="/images/**.*" /> </static-files>

My project structure :

enter image description here

I load the image using html code : `<img src="/images/ajax-loader.gif"/>`

But im receiving the error :

enter image description here

A java.lang.NoSuchMethodError: is being thrown in admin console, but I fail to see how this could be anything related to the loading of a gif image ? The gif im using is taken from http://www.ajaxload.info/ & indicator type is "indicator"

java.lang.NoSuchMethodError: org.springframework.jndi.JndiLocatorDelegate.isDefaultJndiEnvironmentAvailable()Z
    at org.springframework.web.context.support.StandardServletEnvironment.customizePropertySources(StandardServletEnvironment.java:85)
    at org.springframework.core.env.AbstractEnvironment.<init>(AbstractEnvironment.java:101)
    at org.springframework.core.env.StandardEnvironment.<init>(StandardEnvironment.java:54)
    at org.springframework.web.context.support.StandardServletEnvironment.<init>(StandardServletEnvironment.java:43)
    at org.springframework.web.servlet.HttpServletBean.<init>(HttpServletBean.java:90)
    at org.springframework.web.servlet.FrameworkServlet.<init>(FrameworkServlet.java:211)
    at org.springframework.web.servlet.DispatcherServlet.<init>(DispatcherServlet.java:303)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
    at java.lang.Class.newInstance0(Class.java:372)
    at java.lang.Class.newInstance(Class.java:325)
    at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
    at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:428)
    at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:263)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:685)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:202)
    at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:171)
    at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:123)
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:422)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:449)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:455)
    at com.google.tracing.TraceContext.runInContext(TraceContext.java:695)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:333)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:325)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:453)
    at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
    at java.lang.Thread.run(Thread.java:679)

External libs : enter image description here

blue-sky
  • 51,962
  • 152
  • 427
  • 752
  • 1
    Are you saying that if you replace the image with a **static** gif this exception is not thrown??? – Oleg Mikheev Feb 20 '12 at 14:36
  • @Qwe The exception is thrown regardless if the image is static or not. – blue-sky Feb 20 '12 at 14:51
  • edited the subject - animated gif is not related to the issue you're having – Oleg Mikheev Feb 20 '12 at 15:03
  • Are you getting the error when loading the page containing the `` tag, or when loading `/images/ajax-loader.gif` itself? What happens if you type `http:///images/ajax-loader.gif` directly in your browser's address bar? What happens if you remove the `` tag from the page serving the error? – Dan Sanderson Feb 21 '12 at 02:21

5 Answers5

3

NoSuchMethodError is almost always caused due to using incompatible versions of libraries. In this case you are probably using different version of Spring libraries. For example spring-web-3.1.0.jar and spring-context-3.0.x.jar. So, try to update all Spring jars to last version.

If you tell us which versions are you using maybe we can help you more.

EDIT: Spring dependencies in pom.xml

<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>3.1.0.RELEASE</version>
    </dependency>
...
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>3.1.0.RELEASE</version>
    </dependency>
</dependencies>

EDIT:

Well, what this NoSuchMethodError is telling us is your application is executing a StandardServletEnvironment which believes that JndiLocatorDelegate has a method named isDefaultJndiEnvironmentAvailable(), but the method doesn't exist when actually calls it. But this method exists in org.springframewor.context-3.1.1.jar, as you can see here (version 3.1.0).

So, the problem can be a couple of things:

  • There are more than one JndiLocatorDelegate in the classpath. This is possible if you are using another library as metrics.collector. In Eclipse you can press Ctrl+Shift+T and type JndiLocatorDelegate in order to be sure that ONLY ONE class named like this is found in the project and to see if that class contains isDefaultJndiEnvironmentAvailable() method.

  • For some strange reason, you are not executing your current code. Try cleaning your project, temp folders and Tomcat work directory.

If this doesn't help you, please give us a list of all jars included in your war.

sinuhepop
  • 20,010
  • 17
  • 72
  • 107
  • please see my question edit, ive updated to latest Spring jar. I've posted the jars that I using – blue-sky Feb 20 '12 at 19:36
  • @user470184: I can't manage to get Spring 3.1.1 with Maven. I've inspected 3.1.0 jars downloaded from Maven Central Repository and this error is absolutely not possible. Could you try with 3.1.0 version or show us your complete pom.xml? – sinuhepop Feb 20 '12 at 21:46
  • I've tried version 3.1.0Release from http://www.springsource.org/download/community?project=Spring%2520Framework but same error persists. I'm not using maven at the moment – blue-sky Feb 20 '12 at 21:58
  • I'll convert my project to use maven, can you post the pom file which uses the spring dependencies ? – blue-sky Feb 20 '12 at 22:11
  • @user470184: Mmm... this is very strange. Maybe is just a "dirty" project problem, try cleaning it. Are you sure there are only these Spring jars? – sinuhepop Feb 20 '12 at 22:23
  • 1
    Yes, ill try using maven & recreating the project. – blue-sky Feb 20 '12 at 22:57
  • I just have one JndiLocatorDelegate . "Try cleaning your project, temp folders and Tomcat work directory" since GAE runs in jetter container I cannot do this ? – blue-sky Feb 22 '12 at 20:39
  • Sorry, I have no experience with it. But for sure there is some other JndiLocatorDelegate in your classpath. What I would try to do is downgrade your Spring version (3.0.0, 2.5.6) until it works. I don't like this solution, but maybe is the only one. – sinuhepop Feb 24 '12 at 02:49
  • Ok, thanks very much for your help. How did you figure out I was missing "There are more than one JndiLocatorDelegate in the classpath", is this something you know from experience, or is there an area/site which describes these kind of errors. – blue-sky Feb 28 '12 at 09:15
  • @user470184: I've seen this error sometimes. So it's a little about experience and a little of trying to understand why this exception is being thrown. Good luck! – sinuhepop Feb 28 '12 at 12:46
1

In order to see what cause this error (it might be a GAE or Spring issue)

try working with a version of Spring that is 100% compatible with GAE , look here on the list

WillItPlayInJava

and pick up a version of Spring that is working with GAE for sure... cause maybe that version you trying to work with wont work at the moment with GAE (no without special tweks)

also , take a look here : Can i use Spring on GAE? for additional info..,

Community
  • 1
  • 1
Daniel
  • 36,833
  • 10
  • 119
  • 200
  • I'm not convinced WillItPlayInJava is up to date, as the question : ": Can i use Spring on GAE?" details how a user sucessfully used GAE with spring 3. Also WillItPlayInJava is copyrighted "2011" so may not be up do date. – blue-sky Feb 21 '12 at 21:41
  • I offered that just to be on the safe side... and to help to find out what is the cause of the error – Daniel Feb 22 '12 at 06:51
0

On your html tag:

<img src="/images/ajax-loader.gif"/>

I miss the web aplication context, needed for absolute paths on webapps (unless it's configured as the root application).

Suposing a contextPath "/foo" (as in http://host:post/foo):

<img src="/foo/images/ajax-loader.gif"/>
Tomas Narros
  • 13,390
  • 2
  • 40
  • 56
0

Try:

<static-files> <include path="/images/*.*" /> </static-files>

That double asterix in regex should be a closure which will kill regex or make it run forever.

Cris Stringfellow
  • 3,714
  • 26
  • 48
0

Since the HTML is served separately (by invoking a servlet), try removing that as a factor by going after the image directly (using the image's URL). What shows up in the logs then?

The only thing that looks suspicious to me is the include element. I use the

<include path="images/*.gif" />

form, having run into some quirky "**" handling before.

Dave W. Smith
  • 24,318
  • 4
  • 40
  • 46
  • This is something I tried when I first started seeing the error and I could always navigate to the image directly without issue. – blue-sky Feb 28 '12 at 09:17