4 Replies Latest reply on Nov 11, 2012 5:16 AM by mbickel

    Getting servlet path in jboss as7/seam 2.3

    mbickel

      Hi folks,

       

      i've been busy upgrading to Seam 2.3 (i owe you, guys!). I've ported my app by generating a new project using seam-gen and then migrating my source/config into that.

       

      I'm using

      ServletLifecycle.getServletContext().getContextPath()
      

      in some places to construct an absolute URL for several redirects.

       

      However, compiling this with the gwt jars on the classpath will fail, but removing the jars will cause the deployment (to AS7) to fail since seam-remoting seems to depend on them.

       

      I don't need gwt in this project, but I do use seam-remoting. So, can I decouple these two somehow? And if not, is there an alternative way to get the context path?

       

      Thanks, M.

        • 1. Re: Getting servlet path in jboss as7/seam 2.3
          mkouba

          Hi,

          I think gwt libs are optional dependencies.. so you don't have to include them unless you use gwt. And if you use maven it won't be included by default.

           

          In any case I don't understand why including gtw libs causes compilation failure... could you post the stack trace or some error description?

           

          As for the alternative way - I think using ServletLifecycle is ok, though a slightly more convenient way is to call ServletLifecycle.getCurrentServletContext()...

          • 2. Re: Getting servlet path in jboss as7/seam 2.3
            mbickel

            Sure, here is the compile failure caused by including gwt*.jar in the ear's lib dir:

             

            [javac] /home/mbickel/svn/src/main/de/axxur/proj/sessionbean/action/DossierMgr.java:129: cannot find symbol
            [javac] symbol  : method getContextPath()
            [javac] location: interface javax.servlet.ServletContext
            [javac]         String url = ServletLifecycle.getServletContext().getContextPath() + "/docs/?docId=" + selectedDokumentId;
            

             

            AFAIK, gwt redefines ServletContext and causes this failure.

             

            Good point about maven, I just started with ant b/c that is what we already have.

            • 3. Re: Getting servlet path in jboss as7/seam 2.3
              mkouba

              I see, it's a gwt issue. So simply remove/omit gwt jar. And you could also try Ivy if stuck on ant...

              • 4. Re: Getting servlet path in jboss as7/seam 2.3
                mbickel

                Jup, once i discovered deployed-jars-{ear,war}.list and it's effects, that was pretty simple. Thanks a lot!