1
votes

Does Does GlassFish 5.0.1 (with Java 8) supports EJB 2.1 and EJB 3.1 ?

I installed GlassFish with Payara and tried to deploy my .EAR application with EJB 3.1 Entity and session beans and it hangs up on ServletContext.log():Initializing Spring root WebApplicationContext

I waited for hours and nothing. Yes i know, EJB is dead and i should migrated to spring... im just looking for alternatives where to keep my old EJB based apps without any migration.

Full last log lines:

...
[2020-06-11T16:22:27.773+0300] [Payara 5.201] [INFO] [AS-EJB-00054] [javax.enterprise.ejb.container] [tid: ThreadID=101 ThreadName=admin-thread-pool::admin-listener(1)] [timeMillis: 1591881747773] [levelValue: 800] [[
  Portable JNDI names for EJB WulogEJB: [java:global/CCC-ear-RAYAPP-1.0.1-SNAPSHOT-payaraora/CCC-ejb-entity-in-payara-1.0.1-SNAPSHOT/WulogEJB, java:global/CCC-ear-RAYAPP-1.0.1-SNAPSHOT-payaraora/CCC-ejb-entity-in-payara-1.0.1-SNAPSHOT/WulogEJB!com.Tree.common.entityejb.WulogEntityHome]]]

[2020-06-11T16:22:27.922+0300] [Payara 5.201] [INFO] [] [javax.enterprise.web] [tid: ThreadID=101 ThreadName=admin-thread-pool::admin-listener(1)] [timeMillis: 1591881747922] [levelValue: 800] [[
  WebModule[/TreeOnline-RAYAPP] ServletContext.log():No Spring WebApplicationInitializer types detected on classpath]]

[2020-06-11T16:22:28.011+0300] [Payara 5.201] [INFO] [jsf.config.listener.version] [javax.enterprise.resource.webcontainer.jsf.config] [tid: ThreadID=101 ThreadName=admin-thread-pool::admin-listener(1)] [timeMillis: 1591881748011] [levelValue: 800] [[
  Initializing Mojarra |version.string| for context '/TreeOnline-RAYAPP']]

[2020-06-11T16:22:28.471+0300] [Payara 5.201] [INFO] [] [javax.enterprise.web] [tid: ThreadID=101 ThreadName=admin-thread-pool::admin-listener(1)] [timeMillis: 1591881748471] [levelValue: 800] [[
  WebModule[/TreeOnline-RAYAPP] ServletContext.log():Initializing Spring root WebApplicationContext]]
  • I made glassfish-web.xml to add in EAR
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
  <security-domain>java:/TreeSecurityDomain</security-domain>
  <resource-ref>
    <res-ref-name>jdbc/treeDataSource</res-ref-name>
    <jndi-name>treeDataSource</jndi-name>
  </resource-ref>
</glassfish-web-app>

I previously used Wildfly but its removed EJB Entity support after Version 9. I have compiled my app on JAVA 8 with EJB 3.1 Entity and session beans. + created connection under -> JDBC connection pools -> with JNDI property + disabled portable jndi names with set server.ejb-container.property.disable-nonportable-jndi-names="true"

Maybe my glassfish-ejb-jar.xml are with incorrect syntax?

<?xml version="1.0" encoding="UTF-8"?>
<glassfish-ejb-jar xmlns:jboss="http://www.jboss.com/xml/ns/javaee"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:s="urn:security:1.1"
    xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-ejb3-2_0.xsd
                     http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"
    version="3.1" impl-version="2.1">
    <assembly-descriptor>
        <s:security>
            <ejb-name>*</ejb-name>
            <s:security-domain>TreeSecurityDomain</s:security-domain>
            <s:missing-method-permissions-deny-access>false</s:missing-method-permissions-deny-access>
        </s:security>
        <container-transaction>
            <method>
                <ejb-name>*</ejb-name>
                <method-name>*</method-name>
            </method>
            <trans-attribute>Supports</trans-attribute>
        </container-transaction>
    </assembly-descriptor>

    <enterprise-beans>
        <entity>
            <ejb-name>AminataEJB</ejb-name>
            <resource-ref>
                <res-ref-name>jdbc/treeDataSource</res-ref-name>
                <jndi-name>java:treeDataSource</jndi-name>
            </resource-ref>
        </entity>
        <entity>
            <ejb-name>AmeliaEJB</ejb-name>
            <resource-ref>
                <res-ref-name>jdbc/treeDataSource</res-ref-name>
                <jndi-name>java:treeDataSource</jndi-name>
            </resource-ref>
        </entity>
    </enterprise-beans>
</glassfish-ejb-jar>

Could it be because of describing tags?

xmlns:jboss="http://www.jboss.com/xml/ns/javaee"

and

xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-ejb3-2_0.xsd
                     http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"

?

1
EJB is not dead! And yes they are supported by Glassfish. Can you try to create a minimal example?Simon Martinelli
updated my question with glassfish-ejb.jar.xml exampleeman
You're confusing "EJB 2.1" with "EJB" when you said "EJB is dead". EJB 2.1 is indeed dead. Look, it has been succeeded by EJB 3.x more than a decade ago. But EJB itself is not dead at all. It's still present in current versions of JEE. See also stackoverflow.com/q/7295096 to refresh yourself.BalusC
So, Then GlassFish 5.1 still supports EJB 2.1 too ?eman

1 Answers

0
votes

Enabled debug level and saw a lot of this:

DEBUG o.s.jndi.JndiObjectFactoryBean - Converted JNDI name [java:comp/env/TREE/treeDataSource] not found - trying original name [TREE/treeDataSource]. javax.naming.NamingException: Lookup failed for 'java:comp/env/TREE/treeDataSource' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitTreeFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: No object bound to name java:comp/env/TREE/treeDataSource]

Does this means I need to edit all my JNDI bindings from java:treeDataSource to java:comp/env/TREE/treeDataSource ?