3 Replies Latest reply on Mar 24, 2009 10:10 PM by Arbi Sookazian

    seam newbie problems

    Johnathan Livingston Newbie

      Hello dear Seam community,


      I find Seam really cool, but I have rather basic but strange problems. I use the examples but the simplest things seem not being able to work.


      To bring it to the point, anytime I use injection, it comes to runtime exceptions with messages like: @In attribute requires non-null value register.em
      - register is a POJO component with SESSION scope with a private member variable em which is of course the EntityManager. By the way, do I need to create setters/getters for it and if not, how get Seam to now that there is such private member?


      Injection is done like this,


      @In (create=true)
      private EntityManager em;


      what could be the problem? In the IDE/Eclipse tooling it has a yellow marker for em and says, Unknown context variable name: em.


      I hope you can help me :-)


      Beyond this question - I use JBoss tools and after some deployments the server is out of memory. Is anybody familiar with this problem?

        • 1. Re: seam newbie problems
          Arbi Sookazian Master

          Whenever you see @In attribute requires non-null value foo this means that the component does not exist in the Seam container at the time of injection.  To fix this problem, you need to use @In(create=true) or @In(required=false).


          You should be able to inject your EntityManager/SMPC like this every time:


          @In     
          private EntityManager entityManager;



          in components.xml:


          <persistence:managed-persistence-context name="entityManager"
                                               auto-create="true"
                               persistence-unit-jndi-name="java:/fooEntityManagerFactory"/>



          The instance variable name that is injected must match the name attribute of the SMPC config in components.xml, as in the example above.


          Make sure your persistence.xml and foo-ds.xml are configured properly as well.  Look at the hotel booking example in the Seam distro for example configs (they use HSQLDB for the examples).

          • 2. Re: seam newbie problems
            Ingo Jobling Master

            For the out of memory problem, you need to increase PermSize, like this:


            -Dprogram.name="JBossTools JBoss 4.2 Runtime" -Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512
            -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 
            -Djava.endorsed.dirs="C:/jboss-4.2.3.GA/lib/endorsed"
            -Dnoverify



            If you are using Eclipse, this can be set in the Server Launch Configuration.

            • 3. Re: seam newbie problems
              Arbi Sookazian Master

              from DAllen's Seam in Action:


              Sun JVM options when running JBoss AS


              While you’re on the task of setting up the JBoss AS runtime, I recommend a set of
              JVM options to use when running JBoss AS with the Sun JVM. The default memory
              allocation settings in Java are extremely conservative. On top of that, Sun’s JVM has
              a concept of PermGen space, a separate allocated memory region from the heap.6
              Even though the JVM garbage collector frees up memory automatically, there are certain
              objects (such as class and method objects) that can evade removal because
              they are in this isolated memory region. A flag must be provided that enables garbage
              collection for the PermGen space. In addition, the garbage collector has trouble keeping
              up when memory is tight. The limited resources quickly become a problem when
              running a hefty application like JBoss AS that has high memory demands.
              To avoid an untimely death of the JVM, and in turn, JBoss AS, you should supply the
              following parameters in the VM options of the JBoss AS runtime configuration in your
              IDE (or bin/run.conf in the JBoss AS home directory). I have never experienced an
              out-of-memory error when using these settings.7


              -Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000
              -Dsun.rmi.dgc.server.gcInterval=3600000
              -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled
              -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m
              -Xverify:none



              There are ramifications of using the Concurrent Mark Sweep (CMS) garbage collector,
              such as a longer startup time, so I wouldn’t blindly apply these settings to production.
              However, I have found them to be sufficient for development purposes