users@glassfish.java.net

Problems on EJB reference on Glassfish.

From: <glassfish_at_javadesktop.org>
Date: Fri, 09 Oct 2009 01:53:59 PDT

Hi all , i'm developing some EJB 3.0 under Glassfish Enterprise Server v2.1
And i'm encountering some problems aobut EJB reference.


The error is :
[b]Caused by: java.lang.RuntimeException: Warning : Unable to determine local business vs. remote business designation for EJB 3.0 ref
Unresolved Ejb-Ref SessionJMS_at_jndi: SessionJMS_at_null@null_at_Session@SessionJMS[/b]

Here how the descriptor is configured:
ejb-jar.xml:
[b]<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
        version="3.0">
        <display-name>GlassfishEJB3.0</display-name>
        <enterprise-beans>
<session>
                        <ejb-name>SessionJMS</ejb-name>
                        <ejb-class>com.mdb.testsuite.JMSSessionBean</ejb-class>
                        <env-entry>
                                <env-entry-name>ProviderUrl</env-entry-name>
                                <env-entry-type>java.lang.String</env-entry-type>
                                <env-entry-value>http://externalProvier</env-entry-value>
                        </env-entry>
                        <env-entry>
                                <env-entry-name>Queue</env-entry-name>
                                <env-entry-type>java.lang.String</env-entry-type>
                                <env-entry-value>QueueName</env-entry-value>
                        </env-entry>
                </session>
                <message-driven>
                        <ejb-name>MDBInsert</ejb-name>
                        <transaction-type>Bean</transaction-type>
                        <env-entry>
                                <env-entry-name>DataSourceName</env-entry-name>
                                <env-entry-type>java.lang.String</env-entry-type>
                                <env-entry-value>jdbc/OracleDS</env-entry-value>
                        </env-entry>
                        <env-entry>
                                <env-entry-name>Enqueuer</env-entry-name>
                                <env-entry-type>java.lang.String</env-entry-type>
                                <env-entry-value>SessionJMS</env-entry-value>
                        </env-entry>
                        <ejb-local-ref>
                                <ejb-ref-name>SessionJMS</ejb-ref-name>
                                <ejb-ref-type>Session</ejb-ref-type>
                                <ejb-link>SessionJMS</ejb-link>
                        </ejb-local-ref>
                </message-driven>
                </enterprise-beans>
</ejb-jar>
[/b]

The Glassfish descriptor:
[b]<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd">
<sun-ejb-jar>
        <enterprise-beans>
                <ejb>
                        <ejb-name>SessionJMS</ejb-name>
                        <jndi-name>SessionJMS</jndi-name>
                </ejb>
                <ejb>
                        <ejb-name>MDBInsert</ejb-name>
                        <jndi-name>MDBInsert</jndi-name>
                        <ejb-ref>
                                        <ejb-ref-name>SessionJMS</ejb-ref-name>
                                        <jndi-name>SessionJMS</jndi-name>
                        </ejb-ref>
                        <mdb-resource-adapter>
                                <resource-adapter-mid>genericra</resource-adapter-mid>
                                <activation-config>
                                        <activation-config-property>
                                                <activation-config-property-name>DestinationJndiName</activation-config-property-name>
                                                <activation-config-property-value>QueueName</activation-config-property-value>
                                        </activation-config-property>
                                        <activation-config-property>
                                                <activation-config-property-name>ConnectionFactoryJndiName</activation-config-property-name>
                                                <activation-config-property-value>CFactoryName</activation-config-property-value>
                                        </activation-config-property>
                                </activation-config>
                        </mdb-resource-adapter>
                </ejb>
                </enterprise-beans>
</sun-ejb-jar>[/b]
Here some Java code:
The local interface for the Session(statless) EJB:

[b][i]@Local[/i]
public interface JMSSessionBeanLocal {
        ....

}[/b]

The implementation of the EJB:

[b][i]@TransactionManagement[/i] (TransactionManagementType.BEAN)
[i]@Local[/i](JMSSessionBeanLocal.class)
[i]@Stateless[/i] public class JMSSessionBean implements JMSSessionBeanLocal {

        [i]@Resource[/i](name="ProviderUrl")
        private String jms_provider;
        [i]@Resource[/i](name="Queue")
        private String queue_update;
        
        
        public JMSSessionBean() {}
        ....
}[/b]

The MDB EJB that need to lookup the session described before:
[b][i]@MessageDriven[/i](
                activationConfig = {
                                [i]@ActivationConfigProperty[/i](propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
                },name="MDBInsert")
                @TransactionManagement (TransactionManagementType.BEAN)
        public class MDBInsert implements MessageListener {

        @Resource(name="Enqueuer")
        private String en;
        @Resource(name="DataSourceName")
        private String ds;
        
        /**
         * Default constructor.
         */
        public MDBInsert() {}

        private JMSSessionBeanLocal getSessionBean() throws NamingException {
                try {
                        //en is the name of session EJB retrieved via Env-entry value specified in the descriptor
                        return(JMSSessionBeanLocal)new InitialContext().lookup("java:comp/env/"+en);
                } catch (NamingException e) {
                        e.printStackTrace();
                }

                return null;
        }[/b]
        
        Tried with Injection via @EJB, the Exception is the same.
        Anyway i need to have configure the referenced EJB with the descriptor xml and not with annotation.
        The @Resources are working perfectly retrieving the <env-entry> values, for data source and the name
        specified for the EJB Session.
        
  I tried many configurations with annotations or descriptors but not one is working.
        Glassfish throw this exception when i try to deploy the jar.
        Both session and MDB are in the same jar, and i'm deploying a jar not an EAR on Glassfish.
        There is any idea about how to solve this problem or anyone see an error in my configuration?

        
        Thanks for any help or tip in advance.
        T.
        
        
        P.S.
        here the full stack trace:
[b][#|2009-10-08T14:48:30.834+0200|WARNING|sun-appserver2.1|org.apache.coyote.tomcat5.CoyoteRequest|_ThreadID=17;
_ThreadName=httpWorkerThread-4848-2;_RequestID=8e6ca07e-6803-4e8b-ada1-278210c1b8d5;|PWC4011:
Unable to set request character encoding to UTF-8 from context , because request parameters have already been read,
 or ServletRequest.getReader() has already been called|#]

[#|2009-10-08T14:48:32.368+0200|SEVERE|sun-appserver2.1|javax.enterprise.system.tools.deployment|_ThreadID=153;
_ThreadName=Thread-29515;_RequestID=1f972918-883e-45db-a24e-8610adb35a19;|Exception occured in J2EEC
 Phasejava.lang.RuntimeException: Warning : Unable to determine local business vs. remote business
  designation for EJB 3.0 ref Unresolved Ejb-Ref SessionJMS_at_jndi: SessionJMS_at_null@null_at_Session@SessionJMS
com.sun.enterprise.deployment.backend.IASDeploymentException: Error loading deployment descriptors for module [GlassfishEJB3.0] -- Warning : Unable to determine local business vs. remote business designation for EJB 3.0 ref Unresolved Ejb-Ref SessionJMS_at_jndi: SessionJMS_at_null@null_at_Session@SessionJMS
        at com.sun.enterprise.deployment.backend.Deployer.loadDescriptors(Deployer.java:406)
        at com.sun.enterprise.deployment.backend.ModuleDeployer.loadDescriptors(ModuleDeployer.java:426)
        at com.sun.enterprise.deployment.backend.EjbModuleDeployer.deploy(EjbModuleDeployer.java:141)
        at com.sun.enterprise.deployment.backend.ModuleDeployer.doRequestFinish(ModuleDeployer.java:182)
        at com.sun.enterprise.deployment.phasing.J2EECPhase.runPhase(J2EECPhase.java:208)
        at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:108)
        at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:966)
        at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:283)
        at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:835)
        at com.sun.enterprise.management.deploy.DeployThread.deploy(DeployThread.java:187)
        at com.sun.enterprise.management.deploy.DeployThread.run(DeployThread.java:225)
Caused by: java.lang.RuntimeException: Warning : Unable to determine local business vs. remote business
 designation for EJB 3.0 ref Unresolved Ejb-Ref SessionJMS_at_jndi: SessionJMS_at_null@null_at_Session@SessionJMS
        at com.sun.enterprise.deployment.util.EjbBundleValidator.accept(EjbBundleValidator.java:583)
        at com.sun.enterprise.deployment.EjbDescriptor.visit(EjbDescriptor.java:2069)
        at com.sun.enterprise.deployment.EjbBundleDescriptor.visit(EjbBundleDescriptor.java:735)
        at com.sun.enterprise.deployment.archivist.EjbArchivist.validate(EjbArchivist.java:190)
        at com.sun.enterprise.deployment.archivist.ApplicationArchivist.openArchive(ApplicationArchivist.java:840)
        at com.sun.enterprise.deployment.archivist.ApplicationArchivist.openArchive(ApplicationArchivist.java:794)
        at com.sun.enterprise.deployment.backend.Deployer.loadDescriptors(Deployer.java:365)
        ... 10 more
|#][/b]
[Message sent by forum member 'toriton' (toritondruid_at_gmail.com)]

http://forums.java.net/jive/thread.jspa?messageID=367384