Uploaded image for project: 'Seam 2'
  1. Seam 2
  2. JBSEAM-1023

Looking up a filtered SMPC in non-faces servlet throws NPE

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 1.3.0.ALPHA
    • Component/s: Core
    • Labels:
      None

      Description

      My servlet does:

      EntityManager em = ((EntityManager)org.jboss.seam.Component.getInstance("entityManager"));
      em.joinTransaction();

      file = (!"".equals(id)) ? em.find(File.class, Long.parseLong(id)) : null;

      This worked OK, but after I enabled this filter:

      <core:filter name="accessLevelFilter">
      <core:name>accessLevelFilter</core:name>
      <core:parameters>
      <key>currentAccessLevel</key>
      <value>#

      {currentAccessLevel}</value>
      </core:parameters>
      </core:filter>

      <core:managed-persistence-context name="entityManager"
      auto-create="true"
      entity-manager-factory="#{wikiEntityManagerFactory}">
      <core:filters><value>#{accessLevelFilter}</value></core:filters>
      </core:managed-persistence-context>

      It fails with:

      Caused by: java.lang.NullPointerException: facesContext
      at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:379)
      at org.jboss.seam.core.Expressions$1.getValue(Expressions.java:57)
      at org.jboss.seam.persistence.HibernatePersistenceProvider.enableFilter(HibernatePersistenceProvider.java:60)
      at org.jboss.seam.core.ManagedPersistenceContext.initEntityManager(ManagedPersistenceContext.java:85)
      at org.jboss.seam.core.ManagedPersistenceContext.getEntityManager(ManagedPersistenceContext.java:105)
      at sun.reflect.GeneratedMethodAccessor1775.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
      at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:121)
      at org.jboss.seam.Component.callComponentMethod(Component.java:1834)
      at org.jboss.seam.Component.unwrap(Component.java:1860)
      at org.jboss.seam.Component.getInstance(Component.java:1657)
      at org.jboss.seam.Component.getInstance(Component.java:1610)
      at org.jboss.seam.Component.getInstance(Component.java:1604)
      at org.jboss.seam.wiki.core.ui.FileServlet.doGet(FileServlet.java:70)

      The expression "#{currentAccessLevel}

      " can either be resolved to a variable in the SESSION context or to a factory method on one of my components.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                gavin.king Gavin King
                Reporter:
                christian.bauer Christian Bauer
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: