Announcement Announcement Module
Collapse
No announcement yet.
Getting Wicket to work with S2AP: NCDFE on javax.servlet.Filter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting Wicket to work with S2AP: NCDFE on javax.servlet.Filter

    Hello,
    I'm trying, in a quite dirty way I'm afraid, to hack up a way to use Wicket with S2AP (using bundles not wars).

    Fortunately Wicket, since 1.4 M2, provides out-of-box OSGI'fied jars.
    But to configure Wicket, one must declare a filter + an init param in web.xml, something like this:

    <filter>
    <filter-name>WicketApplication</filter-name>
    <filter-class>org.apache.wicket.protocol.http.WicketFilter </filter-class>
    <init-param>
    <param-name>applicationClassName</param-name>
    <param-value>com.example.MyApplication</param-value>
    </init-param>
    </filter>

    <filter-mapping>
    <filter-name>WicketApplication</filter-name>
    <url-pattern>/</url-pattern>
    </filter-mapping>

    So, the problems are:
    - To declare the filter
    - To pass an init param to it

    As far as I know, there is no manifest header (why ?) to declare a filter, and I'm afraid there is too little documentation on 'Spring Filters', so I've tried to play a bit with these.
    My goal was to encapsulate a org.apache.wicket.protocol.http.WicketFilter in a GenericFilterBean, which gives:

    public class S2APWicketFilter extends GenericFilterBean {
    private WicketFilter wf;
    private String applicationClassName;

    @Override
    protected void initFilterBean() throws ServletException {
    super.initFilterBean();
    wf = new WicketFilter();
    FilterConfig fc = getFilterConfig();
    wf.init(new MyFilterConfig(fc, applicationClassName));

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response,
    FilterChain chain) throws IOException, ServletException {
    wf.doFilter(request, response, chain);
    }

    public String getApplicationClassName() {
    return applicationClassName;
    }

    public void setApplicationClassName(String applicationClassName) {
    this.applicationClassName = applicationClassName;
    }
    }

    to be continued ....

  • #2
    Getting Wicket to work with S2AP: NCDFE on javax.servlet.Filter

    MyfilterConfig is yet another encapsulation of a FilterConfig to add the applicationClassName parameter to the init-params:

    class MyFilterConfig implements FilterConfig {

    private final FilterConfig fc;
    private final String applicationClassName;

    public MyFilterConfig(FilterConfig fc, String applicationClassName) {
    super();
    this.fc = fc;
    this.applicationClassName = applicationClassName;
    }

    @Override
    public String getFilterName() {

    return fc.getFilterName();
    }

    @Override
    public String getInitParameter(String arg) {
    if ("applicationClassName".equals(arg))
    return applicationClassName;
    else
    return fc.getInitParameter(arg);
    }

    @Override
    public Enumeration getInitParameterNames() {

    return new Enumeration() {
    private boolean x = true;

    @Override
    public boolean hasMoreElements() {
    boolean h = fc.getInitParameterNames().hasMoreElements();
    if (h) {
    return true;
    } else if (x) {
    x = false;
    return true;
    } else
    return false;
    }

    @Override
    public Object nextElement() {
    if (x)
    return fc.getInitParameterNames().nextElement();
    else
    return applicationClassName;
    }

    };
    }

    @Override
    public ServletContext getServletContext() {
    return fc.getServletContext();
    }

    }


    and then, in my wicket bundle, I declare this filter in a spring file (META-INF/spring/wicket-context.xml):

    <bean class="djo.s2ap.rnd.wicket.S2APWicketFilter"
    id="s2APWicketFilter"
    p:applicationClassName="djo.s2ap.rnd.wicket.MyAppl ication" />

    here is my manifest:

    Manifest-Version: 1.0
    Bundle-Version: 1.0.0
    Bundle-Name: Wicket Bundle
    Bundle-SymbolicName: djo.s2ap.rnd.wicket
    Web-ContextPath: wicket
    Platform-ModuleType: Web
    Import-Library: org.springframework.spring;version="2.5.4"
    Import-Package: javax.servlet,
    javax.servlet.http,
    org.apache.wicket,
    org.apache.wicket.markup.html,
    org.apache.wicket.markup.html.basic,
    org.apache.wicket.model,
    org.apache.wicket.protocol.http
    Web-FilterMappings: s2APWicketFilter;url-patterns:="/"

    But when I launch the S2AP (after adding this bundle to the server from eclipse), I get the following exception:
    short version:
    java.lang.NoClassDefFoundError: javax/servlet/Filter in PlatformBundleClassLoader: [bundle=djo.s2ap.rnd.wicket_1.0.0]

    to be continued ...

    Comment


    • #3
      Getting Wicket to work with S2AP: NCDFE on javax.servlet.Filter

      long version:


      com.springsource.platform.deployer.core.Deployment Exception: Deployment of 'file [/home/djo/Java/servers/springsource-ap-1.0.0.beta3/work/com.springsource.platform.deployer/Module/platform.admin.web-1.0.0.beta3.war-0/platform.admin.web-1.0.0.beta3.war]' failed due to time out
      at com.springsource.platform.deployer.core.module.Sta ndardModule.checkDeployed(StandardModule.java:264)
      at com.springsource.platform.deployer.app.legacy.Lega cyApplication.deploy(LegacyApplication.java:79)
      at com.springsource.platform.deployer.core.internal.S tandardApplicationDeployer.deploy(StandardApplicat ionDeployer.java:390)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:616)
      at org.springframework.osgi.service.importer.internal .aop.ServiceInvoker.doInvoke(ServiceInvoker.java:5 9)
      at org.springframework.osgi.service.importer.internal .aop.ServiceInvoker.invoke(ServiceInvoker.java:67)
      at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
      at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.doProceed(DelegatingIntroductionIn terceptor.java:131)
      at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.invoke(DelegatingIntroductionInter ceptor.java:119)
      at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
      at org.springframework.osgi.service.importer.support. LocalBundleContextAdvice.invoke(LocalBundleContext Advice.java:59)
      at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
      at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.doProceed(DelegatingIntroductionIn terceptor.java:131)
      at org.springframework.aop.support.DelegatingIntroduc tionInterceptor.invoke(DelegatingIntroductionInter ceptor.java:119)
      at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
      at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
      at $Proxy35.deploy(Unknown Source)
      at com.springsource.platform.deployer.hot.HotDeployme ntFileSystemListener.deploy(HotDeploymentFileSyste mListener.java:158)
      at com.springsource.platform.deployer.hot.HotDeployme ntFileSystemListener.onChange(HotDeploymentFileSys temListener.java:92)
      at com.springsource.platform.io.core.fs.WatchTask.not ifyListeners(WatchTask.java:194)
      at com.springsource.platform.io.core.fs.WatchTask.not ifyInitialState(WatchTask.java:136)
      at com.springsource.platform.io.core.fs.WatchTask.run (WatchTask.java:89)
      at java.lang.Thread.run(Thread.java:636)


      Any ideas on why the Filter class can not be found ?

      Comment


      • #4
        Getting Wicket to work with S2AP: NCDFE on javax.servlet.Filter

        That is very strange. Any chance you can create a JIRA for this? If you can attach the app (or a small piece showing the bug) that would be great.

        Regards,

        Rob

        Comment


        • #5
          Getting Wicket to work with S2AP: NCDFE on javax.servlet.Filter

          Thanks Rob for the reply: I've started to feel desperate

          Issue created:

          https://issuetracker.springsource.com/browse/PLATFORM-48

          Anyway, regarding the Wicket support in S2AP, I've heard (from Julien Dubois) that Rod himself is willing to put more steam on this. so, my question is should I stop playing the fool with this story of Wicket filter encapsulation and wait for the S2AP team to provide a cleaner solution ?
          Could you please provide any timeframe, even rough, on this ?

          Thanks,
          Jawher.

          Comment

          Working...
          X