7 Replies Latest reply on Sep 5, 2007 12:25 PM by goldrimtang

    EJB 2.1 and 3 coexisting?

    goldrimtang

      Hi there,

      Can you have some EJB's 2.1 and some 3.0 (all session beans, many stateless, one statefull), in the same JAR file? Is that deployable? I don't have problems deploying the JAR file when all the EJBs are 2.1, but when one is 'switched' to 3, then there is plenty of exceptions at deployment time.

      Thanks in advance.

        • 1. Re: EJB 2.1 and 3 coexisting?
          wolfc

          Yes. Make sure you're using AS 4.2.1.GA, if so bring on the exceptions.

          • 2. Re: EJB 2.1 and 3 coexisting?
            goldrimtang

            Yes, I am using 4.2.1 GA. The exception I'm getting is posted here:
            http://www.jboss.com/index.html?module=bb&op=viewtopic&t=117754

            The class that is not being found is passed as a parameter to a session bean (stateless, remote). Note that even when I changed myClass[] for Object[] I get the same exception (it'd read java.lang.ClassNotFoundException: No ClassLoaders found for: java.lang.Object[]).

            Then I changed that parameter to Vector, and I did not get the error any more. Still, it'd no deploy well. I got another error about a class cast exception for the context... This is all very odd because the exact same application would deploy perfectly well (and pass a massive amount of junit tests), as long as it was ALL EJB 2.1. As soon as a single @Stateless annotation was introduced, the exceptions started.

            Thanks for any help.

            • 3. Re: EJB 2.1 and 3 coexisting?
              wolfc

              Have you got by any chance a deployment descriptor containing a transaction attribute override on the setAgeingSteps method?
              If so, try the following method parameter: [Lcom.xxx.yyy.server.process.MyClass;
              Or try without any method parameters.

              • 4. Re: EJB 2.1 and 3 coexisting?
                goldrimtang

                Hi Wolf,

                Thanks for your reply. Yes, the method has a transaction attribute (RequiresNew). If I change the parameter from an array (Object[]) to a type 'Vector', it stops complaining about this during deployment type. I can live with that ... the problem is that then another exception happens, also at deployment time:

                2007-09-03 14:58:50,737 WARN [org.jboss.system.ServiceController] Problem starting service jboss.j2ee:ear=jbilling.ear,jar=jbilling.jar,name=com/xxx/yyy/server/item/ItemSession,service=EJB3
                
                java.lang.ClassCastException: $Proxy76 cannot be cast to javax.naming.Context
                
                 at org.jboss.util.naming.Util.createSubcontext(Util.java:69)
                
                 at org.jboss.util.naming.Util.rebind(Util.java:125)
                
                 at org.jboss.util.naming.Util.rebind(Util.java:113)
                
                 at org.jboss.ejb3.stateless.StatelessRemoteProxyFactory.start(StatelessRemoteProxyFactory.java:115)
                


                Which makes me wonder why all these problems just because a totally unrelated stateless session bean EJB 3 is being deployed.

                Thanks again for your time.


                • 5. Re: EJB 2.1 and 3 coexisting?
                  goldrimtang

                  OK, so after much effort, (frustration), and time, I can confirm that it does not work. I'm giving up on JBoss 4.2.1. We'll stick to 3.2.6 until an stable release EJB3/Java EE 5 is made.

                  I hope this helps the JBoss team to improve their product.

                  • 6. Re: EJB 2.1 and 3 coexisting?
                    wolfc

                    As for the first problem, I think there is a bug in the deployment descriptor processing.
                    Could you post your deploment descriptor?

                    The second problem is a bean trying to bind it's home interface over a JNDI name that's already taken.
                    In EJB 3 a stateful session bean can be created directly via a loopup on it's business interface. By default this one is bound to <ejb-name>/remote (or /local). The home interface is bound to <ejb-name>/home (or /localHome). If you override the JNDI name for the bean by <ejb-name> then this exception occurs. The log file should show "Binding proxy for <ejb-name> in JNDI at <jndi-name>" just before this happens. Can you confirm this scenario?

                    http://jira.jboss.com/jira/browse/EJBTHREE-1045

                    • 7. Re: EJB 2.1 and 3 coexisting?
                      goldrimtang

                      Wolf,

                      It looks like, when there are EJB3 beans involved, everything is processed by the EJB3 deployer. We actually tried migrating all the session beans to EJB3. It still fails, this time because it doesn't find the entity (2.1) beans. But we can't go on and migrate the entity beans to JPA, there's just too many of them. And in any case, we expected EJB 2.1 and 3 to be able to coexist.

                      We'll wait for JBoss 5...

                      Thanks for your time. Cheers!