title: java.lang.IllegalArgumentException: NamedQuery of name: MY_FUNCTION not found in EJB
body: <p>I am facing an issue in my EJB code. The following is my code, which is deployed on Weblogic 10.3.3:</p>
  
  <pre><code>@Entity
  @NamedStoredFunctionQuery(name = "MY_FUNCTION", functionName = "apipay",
      parameters = {
          @StoredProcedureParameter(
              queryParameter = "consubflag", name = "consubflag", direction = Direction.IN, type=String.class),
          @StoredProcedureParameter(
              queryParameter = "contrno", name = "contrno", direction = Direction.IN, type=String.class),
          @StoredProcedureParameter(
              queryParameter = "username", name = "username", direction = Direction.IN, type=String.class)
      },
      returnParameter = 
          @StoredProcedureParameter(
              queryParameter = "paymentid", type = String.class)
  )
  public class MyPayment implements Serializable {
  
      @Id
      String paymentid;
      String consubflag;
      String contrno;
      String username;
  }
  </code></pre>
  
  <p>Following is the EJB code from which I am calling:</p>
  
  <pre><code>Query q = tabsEntityManager.createNamedQuery("MY_FUNCTION");
  q.setParameter("consubflag", "S");
  q.setParameter("contrno", contrno);
  q.setParameter("username", "ATMGTW");
  
  paymentId = (String) q.getSingleResult();
  </code></pre>
  
  <p>Following is my persistence.xml:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;persistence-unit name="PU1" transaction-type="JTA"&gt;
      &lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;/provider&gt;
          &lt;jta-data-source&gt;jdbc/myDS1&lt;/jta-data-source&gt;
          &lt;class&gt;com.MyPayment&lt;/class&gt;
  &lt;/persistence-unit&gt;
  &lt;persistence-unit name="PU2" transaction-type="JTA"&gt;
      &lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;/provider&gt;
          &lt;jta-data-source&gt;jdbc/myDS2&lt;/jta-data-source&gt;
          &lt;class&gt;com.MyRequest&lt;/class&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>The complete error stack trace is:</p>
  
  <pre><code>java.lang.IllegalArgumentException: NamedQuery of name: My_FUNCTION not found.
          at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getDatabaseQueryInternal(EJBQueryImpl.java:545)
          at org.eclipse.persistence.internal.jpa.EJBQueryImpl.setParameterInternal(EJBQueryImpl.java:1145)
          at org.eclipse.persistence.internal.jpa.EJBQueryImpl.setParameter(EJBQueryImpl.java:1032)
          at org.eclipse.persistence.internal.jpa.EJBQueryImpl.setParameter(EJBQueryImpl.java:71)
          at com.warid.es.onelink.facade.TopUpControllerBean.postPaidPayment(TopUpControllerBean.java:594)
  </code></pre>
  
  <p>I tried the same code in a Java SE app and it's working fine.</p>