Skip to main content

jawr maven plugin - Failed to invoke Servlet 2.5 getContextPath method

  5 posts   Feedicon  
Replies: 4 - Last Post: April 17, 2012 09:34
by: vai_shah
showing 1 - 5 of 5
Posted: October 12, 2011 23:39 by pakman
From the (scarce) maven-plugin documentation it says "the bundle processor will add the WEB-INF/lib directory in the classpath".. which doesn't seem to match reality. I had to add a few dependencies to the plugin which are present on WEB-INF/lib. Anyway, now I'm stuck with another problem:

Oct 12, 2011 6:20:21 PM net.jawr.maven.JawrMojo execute
SEVERE: null
java.lang.IllegalStateException: Failed to invoke Servlet 2.5 getContextPath method
	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:268)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)

...
Caused by: java.lang.NoSuchMethodException: javax.servlet.ServletContext.getContextPath()
	at java.lang.Class.getMethod(Class.java:1605)
	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:263)


What other dependencies should be added to the plugin?
Which ServletContext implementation will jawr use during this process?

Any help would be gratefully appreciated.
Regards, all

P.S. Great product by the way.
Posted: October 14, 2011 13:40 by icefox
Hi Pakman,

There was is an issue in the loading of libraries from the WEB-INF/lib directory.
This has been fixed in the development branch.

As you've found, the work around for this is to add the libraries as dependencies of the jawr-maven-plugin.

Jawr is able to work with almost any servlet API version.
We are using a mock for the servlet context in the plugin.
I think that the mock is using the servlet API version 2.3.

This is probably why it fails.
Unfortunately the only work around that you have is to update the code, and to rewrite the Mock to use the servlet API 2.5.

I'll create an issue in the JIRA to handle this case.

If you have ideas to improve the documentation, I'll be really glad to hear them.

Cheers,

PS : Thanks for your kind words Wink
Posted: October 14, 2011 18:51 by pakman
Thanks for your response.

I checked the mock ServletContext and in the getMinorVersion() it returns 5 so Spring assumes it can call the getContextPath() Method, which is not part of the Servlet spec < version 2.5. I changed it to return 4 instead of 5 but now Spring is calling getServletContextName() and since the MockServletContext is just a ... mock it throws an exception.

java.lang.RuntimeException: operation not supported
	at net.jawr.web.servlet.mock.MockServletContext.getServletContextName(MockServletContext.java:287)
	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:256)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
	at  net.jawr.web.bundle.processor.spring.SpringControllerBundleProcessor.initJawrSpringServlets(SpringControllerBundleProcessor.java:55)
	at net.jawr.web.bundle.processor.BundleProcessor.initJawrSpringControllers(BundleProcessor.java:339)
	at net.jawr.web.bundle.processor.BundleProcessor.process(BundleProcessor.java:219)


I guess I'll have to dig deeper into how/why jawr-bundle is initializing Spring.

By the way, all this refers to Spring 3.0.5 and Jawr 3.3.3, jawr maven 1.4.2.
Posted: October 17, 2011 10:02 by icefox
Hi pakman,

I would be interested to know where it fails to improve the Jawr pre compilation processor for spring.

If you can send me a sample application where it fails, I would be able to take a look at it.

Cheers,
Posted: April 17, 2012 09:34 by vai_shah
Were you able to solve this issue? If there is any work around please let me know as I am facing the same issue while integrating it with spring MVC project during maven build

Failed to execute goal net.jawr:maven-jawr-plugin:1.4.2:bundle (default) on project myproject: Execution default of goal net.jawr:maven-jawr-plugin:1.4.2:bundle failed: An API incompatibility was encountered while executing net.jawr:maven-jawr-plugin:1.4.2:bundle: java.lang.AbstractMethodError: net.jawr.web.servlet.mock.MockServletContext.getContextPath()Ljava/lang/String;
Replies: 4 - Last Post: April 17, 2012 09:34
by: vai_shah
 
 
Close
loading
Please Confirm
Close