WebModuleUtils problem?

21 views
Skip to first unread message

jokoul webster

unread,
May 21, 2010, 2:48:57 AM5/21/10
to impala...@googlegroups.com
Hi Phil:
   It seems that there is a bug within WebModuleUtils,for example,if I am using servlet2.4&jsp2.0,but my application server can support servlet2.5&jsp2.1(jetty6.1,jboss4.2.etc,),in this case,Impala will judge current app container can support servlet2.5&jsp2.1 and will invoke ServletContext.getContextPath(),but we know servlet2.4 does not have such method,then we will cahch a exception "java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String;".
  Anyone can help me?
 
Thanks
JK

--
You received this message because you are subscribed to the Google Groups "impala-users" group.
To post to this group, send email to impala...@googlegroups.com.
To unsubscribe from this group, send email to impala_group...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/impala_group?hl=en.

Phil Zoio

unread,
May 21, 2010, 4:37:00 AM5/21/10
to impala...@googlegroups.com
Jokoul

Can you check to see whether the servlet 2.4 jar is ending up in your
web application lib directory. I suspect that is the problem.

If your application server does support it, I would suggest to use the
servlet 2.5 jar, or better, take out the servlet jar altogether when
packaging your war file.

You can use the build property in your web host project
'web.lib.excludes' to control what files get copied from the local third
party repository project to WEB-INF/lib. By default the value is:

**/*-sources.jar,**/*-javadoc.jar,dist/*,provided/*,system/*,test/*,jetty/*

Hope that helps.

Phil

jokoul webster

unread,
May 21, 2010, 4:57:14 AM5/21/10
to impala...@googlegroups.com

Hi Phil:
   I have found that impala-web was compiled with Servlet2.5&jsp2.1,so whatever app server I wanna use,following funcation will always return "true":
===========================ServletContextUtils.java======================================
 public static boolean isAtLeast25(ServletContext servletContext) {
        return servletContext.getMajorVersion() >= 2 && servletContext.getMinorVersion() >= 5;
    }
========================================================================
but if I compile impala with servlet2.4,the ServletContextUtils does not work.

Thanks.

Phil Zoio

unread,
May 21, 2010, 5:32:28 AM5/21/10
to impala...@googlegroups.com
Jokoul,

You will need to compile against 2.5 otherwise ServletContextUtils will
not compile. However, you should be able to run it with 2.4 at runtime
(the idea of the isAtLeast25(ServletContext) method is to make sure
that servletContext.getContextPath() is not called unless 2.5 support
is there).

The problem you are talking about appears because the servlet context
implementation supports 2.5, but you only have a 2.4 version of the Jar
in the classpath.

I will raise a ticket to catch the NoSuchMethodError (and log a
warning): see http://code.google.com/p/impala/issues/detail?id=330

In the meantime, I'd recommend you change to the servlet 2.5 jar as per
my previous reply post (I'm thinking mostly of the Jetty environment,
where you need to supply the servlet jar environment. When running in
Tomcat or JBoss or the like, the servlet API classes should already be
on the classpath).

Cheers,
Phil

jokoul webster

unread,
May 21, 2010, 5:52:10 AM5/21/10
to impala...@googlegroups.com
Yes,I know jboss4.2+,jetty6.etc does support servlet2.5,but Phil,I will have to use weblogic9.2 now,which does not support servlet2.5,what could I do then?
 
Thanks

Phil Zoio

unread,
May 21, 2010, 6:03:20 AM5/21/10
to impala...@googlegroups.com
That should just work - ServletContextUtils.isAtLeast25(ServletContext
servletContext) should return false, in which case
servletContext.getContextPath() should not be called ...

Phil

jokoul webster

unread,
May 21, 2010, 6:09:08 AM5/21/10
to impala...@googlegroups.com
Yes,I have done as same as what you just say,but I am not sure if what will happen or Impala's mechnasim will be destroied by doing that!
Any advice would be appreciated,thanks.

Phil Zoio

unread,
May 21, 2010, 6:25:07 AM5/21/10
to impala...@googlegroups.com
No, the use of servletContext.getContextPath() is very limited - it's
purely there to allow for startup system properties to be partitioned by
servlet context path.

For example, if you want to run two web applications, one with servlet
context path /path1, and the other with path /path2, to set a system
property called my_prop, you could do it differently per web
application, using separate values for 'path1.my_prop' and 'path2.my_prop'.

Assuming you are not relying on that feature, there should be nothing
extra to worry about specific to this issue.

Phil

jokoul webster

unread,
May 21, 2010, 7:22:18 AM5/21/10
to impala...@googlegroups.com

Hi,if isAtLeast25() method always returns false,many test cases within impala-web do not work again,so I am afraid this is a hidden trouble,Phil,I really need your confirmation to encourage me to do this way.Thanks.

jokoul webster

unread,
May 21, 2010, 7:33:15 AM5/21/10
to impala...@googlegroups.com
Unfortunately,I have kept  isAtLeast25() return  false,but when I have deployed  the war in servlet2.4 environment,it is failed to work,because some exception are thrown:
=====================================================
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.lft.gecko.web.spring.integration.ModuleHttpServiceInvokerBuilder.for.mytest-web': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jsp': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/servlet/jsp/JspApplicationContext.

Phil Zoio

unread,
May 21, 2010, 11:49:46 AM5/21/10
to impala...@googlegroups.com
Sounds to me like you don't have the JSP API jar present in your
environment. If you're running within the IDE using Jetty, you will need
to provide this. Otherwise, the JSP jars should already be present on
the classpath.

The JSPApplicationContext is present in JSP 2.1 onwards.

Can you describe your environment in a bit more detail, as this can
certainly affect the advice I give here. I assume you are trying to get
the in-module JSP support working. This can be tricky, and if you are
struggling you might prefer to go for a simpler configuration, or use a
templating engine such as Freemarker (something I would recommend).

jokoul webster

unread,
May 21, 2010, 12:30:22 PM5/21/10
to impala...@googlegroups.com
Phil,what I am using is just a very simple project created by Impala's create console "ant newproject",during the creating process I have selected the "sevlet2.4",so I am sure Impala's "ant fetch get" command have downloaded and copied servlet2.4 and jsp2.0 to xxx-repository,and at present I wanna deploy this project under Weblogic9.2,not Jetty,that's all.Thanks.
 
JK

jokoul webster

unread,
May 21, 2010, 12:38:28 PM5/21/10
to impala...@googlegroups.com
Phil,I have deployed my very simple new project under jetty6.1 with servlet2.4 and jsp2.0,everything is breakdown,I can not run my project,so im my opinions I guess Impala CAN NOT support servlet2.4 and jsp2.0,do you think it?
If Impala really does not support servlet2.4 you should remove the "servlet2.4" selection from command console,or anyone else will be puzzled about this issue.Thanks.

Phil Zoio

unread,
May 21, 2010, 1:20:43 PM5/21/10
to impala...@googlegroups.com
OK, I think I see the problem. In the future, I am going to remove the
option to select 2.4 from the 'ant newproject' command. I will raise a
ticket for this.

You will need to use different jasper libraries for the JSP support,
compatible with servlet 2.4 and jsp 2.0.

Try adding the following entry into dependencies.txt

runtime from tomcat:jasper-runtime:5.5.15 source=false
runtime from tomcat:jasper-compiler:5.5.15 source=false
runtime from tomcat:jasper-compiler-jdt:5.5.15 source=false

which should replace the following:

runtime from org.apache.tomcat:jasper:6.0.16
runtime from org.apache.tomcat:jasper-el:6.0.16
runtime from org.apache.tomcat:jasper-jdt:6.0.16
runtime from org.apache.tomcat:juli:6.0.16

Obviously, update your classpath in Eclipse, and remove the 6.0 jars.

Good luck!

Phil

Phil Zoio

unread,
May 22, 2010, 3:48:22 AM5/22/10
to impala...@googlegroups.com
Jokoul
I have now in the source removed the option to generate a starter application using 'ant newproject' for the Servlet 2.4 spec.
See http://code.google.com/p/impala/issues/detail?id=331

Ideally 'ant newproject' should only work with options for which no extra manual step is required, and having to make manual changes to the JSP libraries breaks this rule.

Instead, I am using Servlet 2.5, and have added some instructions to the wiki on how to change the application for 2.4. The entry for this is http://code.google.com/p/impala/wiki/WebServlet24

I have verified that this works using the Jetty/Tomcat combination. Let me know how you get on with Weblogic 9.2.

Cheers,
Phil

jokoul webster

unread,
May 22, 2010, 9:10:24 AM5/22/10
to impala...@googlegroups.com

Hi Phil:
   I am still testing now,my environment is weblogic9.2 and jasper jsp have been changed to 5.1.5 version, but some questions have been found below:
   1:Can't deploy Impala application into Weblogic9 with "WAR",in this case weblogic can't find the files in "WEB-INF/modules/xxx.jar" when starting,so I have to expand my application.
   2:Now I can startup my application successfully(of course the application is very very simple,just only generated by wizard console),but when I click the link "http://xxx:port/mytesthost/web/message.htm" to see the message,exception is thrown,I will post here:
=======================================================================
<Error> <HTTP> <BEA-101017> <[weblogic.servlet.internal.WebAppServl
etContext@1ebf5c - appName: 'mytesthost', name: 'mytesthost', context-path: '/mytesthost'] Root caus
e of ServletException.
java.lang.IllegalStateException: No JSP servlet registered in the module to which the request was di
rected. Your module configuration requires a class org.impalaframework.web.jsp.JspServletFactoryBean configuration entry, or equivalent.
        at org.impalaframework.web.jsp.ModuleJspServlet.service(ModuleJspServlet.java:59)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.
java:225)
        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:127)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
        Truncated. see log file for complete stacktrace
========================================================================

and mytestweb-context.xml is here:
=========================================================================
 <service:import id="messageService" proxyTypes="com.mytest.main.MessageService"/>

    <web:mapping>
        <web:to-module prefix = "/web" setContextPath="true"/>
        <web:to-handler extension = "htm" servletName="dispatcher"/>
        <web:to-handler extension = "css" servletName="resources"/>
    </web:mapping>
   
    <web:servlet id = "dispatcher"/>
       
    <web:servlet id = "resources"
        servletClass = "org.impalaframework.web.servlet.ResourceServlet"
        initParameters = "cacheTimeout=10"/>
       
    <web:jsp-servlet id="jsp"/>

    <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/"/>
        <property name="suffix" value=".jsp"/>
    </bean>

    <bean class="com.mytest.web.MessageController">
        <property name = "messageService" ref = "messageService"/>
    </bean>
===============================================================================
I have tried to change the value of "htm" extension from "dispatcher" to "jsp",but the ClassCastException of JSP is thrown。

Phil Zoio

unread,
May 24, 2010, 9:17:52 AM5/24/10
to impala...@googlegroups.com
Jokoul,

On the face of it your configuration looks okay. Can you confirm that
the same application war file runs in Tomcat?

Phil
Reply all
Reply to author
Forward
0 new messages