Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-491

@FormParam in @Form gives null in JBoss 6 when CDI is enabled (beans.xml in WEB-INF)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 2.2-beta-1
    • 2.1.0.GA
    • None
    • None
    • Hide

      1. Copy the default JBoss server config and name it "form-test".
      2. Unzip the attached form-test zip archive and place the resulting exploded war directory (form-test.war) in the form-test/deploy directory
      3. Copy the form-test.war directory to a form-test2.war directory. The copy is placed in the deploy directory as well.
      4. Start JBoss with the new config (run.sh -c form-test)
      5. Go to http://localhost:8080/form-test/form-test.html. Submit the form. You will get a NullPointerException
      6. Go to http://localhost:8080/form-test2/form-test.html. Submit the form. You will get a successful result page ("worked: aaa").

      I'd expect either both step 5 and 6 to give a NullPointerException, or both to have worked.

      Show
      1. Copy the default JBoss server config and name it "form-test". 2. Unzip the attached form-test zip archive and place the resulting exploded war directory (form-test.war) in the form-test/deploy directory 3. Copy the form-test.war directory to a form-test2.war directory. The copy is placed in the deploy directory as well. 4. Start JBoss with the new config (run.sh -c form-test) 5. Go to http://localhost:8080/form-test/form-test.html . Submit the form. You will get a NullPointerException 6. Go to http://localhost:8080/form-test2/form-test.html . Submit the form. You will get a successful result page ("worked: aaa"). I'd expect either both step 5 and 6 to give a NullPointerException, or both to have worked.

    Description

      @Form seems to break when CDI is enabled.

      I have a class like this:


      import javax.servlet.http.HttpServletRequest;
      import javax.ws.rs.FormParam;
      import javax.ws.rs.POST;
      import javax.ws.rs.Path;
      import javax.ws.rs.core.Context;

      import org.jboss.resteasy.annotations.Form;

      @Path("form-test")
      public class FormTest {
      public static class FormValues

      { @FormParam("stringAttribute") private String stringAttribute; }

      @POST
      public String create(@SuppressWarnings("unused") @Context HttpServletRequest request, @Form FormValues formValues) throws Exception {
      if(formValues.stringAttribute == null)

      { throw new NullPointerException("stringAttribute is null"); }

      return "worked: " + formValues.stringAttribute;
      }
      }

      I've put this class in WEB-INF/classes in my exploded war-directory in my deploy directory.

      If I don't have a beans.xml in the WEB-INF directory, this class works as it should. I can submit to it, and the stringAttribute parameter will be available in the form object.

      If I put a beans.xml in the WEB-INF directory, and restart JBoss, then the value will not be available, instead I get null.

      This problem only seems to affect the first war that loads RestEasy classes. Any other war in the deploy directory has no problem with the @Form object, even if there's a beans.xml file in WEB-INF. I can copy the first exploded war directory, rename it to another name, and then one of these two will work, the other won't work.

      As a current workaround I've done this: Put another war with a dummy resteasy-class and the beans.xml in the deploy directory. This war must be loaded before the other wars that I want to work (is it alphabetical order based on filename?). The first will be broken, the others will work.

      Attachments

        Activity

          People

            rhn-engineering-jharting Jozef Hartinger
            foborg Alexander Foborg (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: