9 Replies Latest reply on Sep 18, 2002 3:17 PM by Ryan Delano

    Do JBoss and Tomcat share a VM or one each?

    Ryan Delano Newbie

      I'm trying to understand why my CMP 2.0 beans are giving me trouble. The reason I need to know about the separate VMS is to know if I'll have to implement and use the REMOTE interface when accessing beans through a JSP. I'm getting an UndeclaredThrowableException java.rmi.ServerException error when trying to get a local home reference to an entity bean from my session bean. I'm wondering if this is because I should be using remote rather than local.

      I'm running the JBoss3.0.0/Tomcat4.0.3 bundle, developing on JBuilding7.0 with the Protegra JBoss 3.x setup wizard addin (http://www.protegra.com/javagroup.html)


        • 1. Re: Do JBoss and Tomcat share a VM or one each?
          Adrian Brock Master

          Try unwrapping the UndeclaredThrowableException to
          see the real error. You might have to unwrap a few
          times to get past ServerExceptions.

          EJBs and Tomcat should share the same VM.
          Make sure you are using
          InitialContext ic = new InitialContext();
          supplied by the server, you don't need to configure it,
          you might accidently send the request over RMI.

          If you get stuck, there are examples in the jboss
          testsuite for web apps using an ejb's local interface.

          Regards,
          Adrian

          • 2. Re: Do JBoss and Tomcat share a VM or one each?
            Ryan Delano Newbie

            Thanks Adrian for your reply,

            I confirmed that I was using a clean InitialContext, so long as this is the same then we are on the same page:
            jndiContext = new javax.naming.InitialContext();

            I did try the unwrapping technique per your advice but wasn't sure how to get through several layers. I feel like the stack trace is offering enough info already so I didn't fight to unwrap repeatedly. The reason for my original post and it's lack of code or stack trace is that I don't understand why rmi is involved when using local interfaces.

            A heavily trimmed stack looks like this:

            [BEGIN STACK]
            javax.ejb.EJBException: Undeclared throwable after one unwrap:
            Embedded Exception: null
            Embedded Exception
            $Proxy72; nested exception is:
            javax.ejb.EJBException: null
            Embedded Exception: $Proxy72
            at com.rydel.fys.UserSessionBean.isUseridAvailable(UserSessionBean.java:441)
            [HUGE SNIP]

            java.rmi.ServerException: null
            Embedded Exception
            $Proxy72; nested exception is:
            javax.ejb.EJBException: null
            Embedded Exception
            $Proxy72
            javax.ejb.EJBException: null
            Embedded Exception
            $Proxy72
            at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1148)
            [HUGE SNIP]

            java.lang.ClassCastException: $Proxy72
            at com.rydel.fys.UserBean$Proxy.ejbSelectTempUserByUserid()
            [END STACK]


            I just debugged deeper into my beans to find that I am unable to load a CMP2.0 entity bean. (My test client can create them no problem.) The code all executes fine if there is no matching data, but when I lookup an existing PK blam! As the stack indicates, the root of the problem appears to be a bad type cast, but I don't understand two things:

            1- Why am I getting any error in my stack via java.rmi.* when all my beans are local (and don't even have remote interfaces)?

            2- I'm using the Object type and not accessing any methods on the object (which is an existing entity bean) so I don't see why there'd be any casting issues.


            The cast that is failing is here:
            Object tempU = (Object)ejbSelectTempUserByUserid(userid);

            Declaration for my select method and it's EJB QL:
            public abstract UserBean ejbSelectTempUserByUserid(String userid) throws FinderException ;
            EJB QL: SELECT OBJECT(u) FROM User as u WHERE u.userid = ?1

            I will continue searching and repost if I get a handle on this. Thanks for your time, it is greatly appreciated.
            Ryan

            • 3. Re: Do JBoss and Tomcat share a VM or one each?
              Ryan Delano Newbie

              Thanks Adrian for your reply,

              I confirmed that I was using a clean InitialContext, so long as this is the same then we are on the same page:
              jndiContext = new javax.naming.InitialContext();

              I did try the unwrapping technique per your advice but wasn't sure how to get through several layers. I feel like the stack trace is offering enough info already so I didn't fight to unwrap repeatedly. The reason for my original post and it's lack of code or stack trace is that I don't understand why rmi is involved when using local interfaces.

              A heavily trimmed stack looks like this:

              [BEGIN STACK]
              javax.ejb.EJBException: Undeclared throwable after one unwrap:
              Embedded Exception: null
              Embedded Exception
              $Proxy72; nested exception is:
              javax.ejb.EJBException: null
              Embedded Exception: $Proxy72
              at com.rydel.fys.UserSessionBean.isUseridAvailable(UserSessionBean.java:441)
              [HUGE SNIP]

              java.rmi.ServerException: null
              Embedded Exception
              $Proxy72; nested exception is:
              javax.ejb.EJBException: null
              Embedded Exception
              $Proxy72
              javax.ejb.EJBException: null
              Embedded Exception
              $Proxy72
              at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1148)
              [HUGE SNIP]

              java.lang.ClassCastException: $Proxy72
              at com.rydel.fys.UserBean$Proxy.ejbSelectTempUserByUserid()
              [END STACK]


              I just debugged deeper into my beans to find that I am unable to load a CMP2.0 entity bean. (My test client can create them no problem.) The code all executes fine if there is no matching data, but when I lookup an existing PK blam! As the stack indicates, the root of the problem appears to be a bad type cast, but I don't understand two things:

              1- Why am I getting any error in my stack via java.rmi.* when all my beans are local (and don't even have remote interfaces)?

              2- I'm using the Object type and not accessing any methods on the object (which is an existing entity bean) so I don't see why there'd be any casting issues.


              The cast that is failing is here:
              Object tempU = (Object)ejbSelectTempUserByUserid(userid);

              Declaration for my select method and it's EJB QL:
              public abstract UserBean ejbSelectTempUserByUserid(String userid) throws FinderException ;
              EJB QL: SELECT OBJECT(u) FROM User as u WHERE u.userid = ?1

              I will continue searching and repost if I get a handle on this. Thanks for your time, it is greatly appreciated.
              Ryan

              • 4. Re: Do JBoss and Tomcat share a VM or one each?
                Ryan Delano Newbie

                Thanks Adrian for your reply,

                I confirmed that I was using a clean InitialContext, so long as this is the same then we are on the same page:
                jndiContext = new javax.naming.InitialContext();

                I did try the unwrapping technique per your advice but wasn't sure how to get through several layers. I feel like the stack trace is offering enough info already so I didn't fight to unwrap repeatedly. The reason for my original post and it's lack of code or stack trace is that I don't understand why rmi is involved when using local interfaces.

                A heavily trimmed stack looks like this:

                [BEGIN STACK]
                javax.ejb.EJBException: Undeclared throwable after one unwrap:
                Embedded Exception: null
                Embedded Exception
                $Proxy72; nested exception is:
                javax.ejb.EJBException: null
                Embedded Exception: $Proxy72
                at com.rydel.fys.UserSessionBean.isUseridAvailable(UserSessionBean.java:441)
                [HUGE SNIP]

                java.rmi.ServerException: null
                Embedded Exception
                $Proxy72; nested exception is:
                javax.ejb.EJBException: null
                Embedded Exception
                $Proxy72
                javax.ejb.EJBException: null
                Embedded Exception
                $Proxy72
                at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1148)
                [HUGE SNIP]

                java.lang.ClassCastException: $Proxy72
                at com.rydel.fys.UserBean$Proxy.ejbSelectTempUserByUserid()
                [END STACK]


                I just debugged deeper into my beans to find that I am unable to load a CMP2.0 entity bean. (My test client can create them no problem.) The code all executes fine if there is no matching data, but when I lookup an existing PK blam! As the stack indicates, the root of the problem appears to be a bad type cast, but I don't understand two things:

                1- Why am I getting any error in my stack via java.rmi.* when all my beans are local (and don't even have remote interfaces)?

                2- I'm using the Object type and not accessing any methods on the object (which is an existing entity bean) so I don't see why there'd be any casting issues.


                The cast that is failing is here:
                Object tempU = (Object)ejbSelectTempUserByUserid(userid);

                Declaration for my select method and it's EJB QL:
                public abstract UserBean ejbSelectTempUserByUserid(String userid) throws FinderException ;
                EJB QL: SELECT OBJECT(u) FROM User as u WHERE u.userid = ?1

                I will continue searching and repost if I get a handle on this. Thanks for your time, it is greatly appreciated.
                Ryan

                • 5. Re: Do JBoss and Tomcat share a VM or one each?
                  Ryan Delano Newbie

                  Thanks Adrian for your reply,

                  I confirmed that I was using a clean InitialContext, so long as this is the same then we are on the same page:
                  jndiContext = new javax.naming.InitialContext();

                  I did try the unwrapping technique per your advice but wasn't sure how to get through several layers. I feel like the stack trace is offering enough info already so I didn't fight to unwrap repeatedly. The reason for my original post and it's lack of code or stack trace is that I don't understand why rmi is involved when using local interfaces.

                  A heavily trimmed stack looks like this:

                  [BEGIN STACK]
                  javax.ejb.EJBException: Undeclared throwable after one unwrap:
                  Embedded Exception: null
                  Embedded Exception
                  $Proxy72; nested exception is:
                  javax.ejb.EJBException: null
                  Embedded Exception: $Proxy72
                  at com.rydel.fys.UserSessionBean.isUseridAvailable(UserSessionBean.java:441)
                  [HUGE SNIP]

                  java.rmi.ServerException: null
                  Embedded Exception
                  $Proxy72; nested exception is:
                  javax.ejb.EJBException: null
                  Embedded Exception
                  $Proxy72
                  javax.ejb.EJBException: null
                  Embedded Exception
                  $Proxy72
                  at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1148)
                  [HUGE SNIP]

                  java.lang.ClassCastException: $Proxy72
                  at com.rydel.fys.UserBean$Proxy.ejbSelectTempUserByUserid()
                  [END STACK]


                  I just debugged deeper into my beans to find that I am unable to load a CMP2.0 entity bean. (My test client can create them no problem.) The code all executes fine if there is no matching data, but when I lookup an existing PK blam! As the stack indicates, the root of the problem appears to be a bad type cast, but I don't understand two things:

                  1- Why am I getting any error in my stack via java.rmi.* when all my beans are local (and don't even have remote interfaces)?

                  2- I'm using the Object type and not accessing any methods on the object (which is an existing entity bean) so I don't see why there'd be any casting issues.


                  The cast that is failing is here:
                  Object tempU = (Object)ejbSelectTempUserByUserid(userid);

                  Declaration for my select method and it's EJB QL:
                  public abstract UserBean ejbSelectTempUserByUserid(String userid) throws FinderException ;
                  EJB QL: SELECT OBJECT(u) FROM User as u WHERE u.userid = ?1

                  I will continue searching and repost if I get a handle on this. Thanks for your time, it is greatly appreciated.
                  Ryan

                  • 6. Re: Do JBoss and Tomcat share a VM or one each?
                    Ryan Delano Newbie

                    Thanks Adrian for your reply,

                    I confirmed that I was using a clean InitialContext, so long as this is the same then we are on the same page:
                    jndiContext = new javax.naming.InitialContext();

                    I did try the unwrapping technique per your advice but wasn't sure how to get through several layers. I feel like the stack trace is offering enough info already so I didn't fight to unwrap repeatedly. The reason for my original post and it's lack of code or stack trace is that I don't understand why rmi is involved when using local interfaces.

                    A heavily trimmed stack looks like this:

                    [BEGIN STACK]
                    javax.ejb.EJBException: Undeclared throwable after one unwrap:
                    Embedded Exception: null
                    Embedded Exception
                    $Proxy72; nested exception is:
                    javax.ejb.EJBException: null
                    Embedded Exception: $Proxy72
                    at com.rydel.fys.UserSessionBean.isUseridAvailable(UserSessionBean.java:441)
                    [HUGE SNIP]

                    java.rmi.ServerException: null
                    Embedded Exception
                    $Proxy72; nested exception is:
                    javax.ejb.EJBException: null
                    Embedded Exception
                    $Proxy72
                    javax.ejb.EJBException: null
                    Embedded Exception
                    $Proxy72
                    at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1148)
                    [HUGE SNIP]

                    java.lang.ClassCastException: $Proxy72
                    at com.rydel.fys.UserBean$Proxy.ejbSelectTempUserByUserid()
                    [END STACK]


                    I just debugged deeper into my beans to find that I am unable to load a CMP2.0 entity bean. (My test client can create them no problem.) The code all executes fine if there is no matching data, but when I lookup an existing PK blam! As the stack indicates, the root of the problem appears to be a bad type cast, but I don't understand two things:

                    1- Why am I getting any error in my stack via java.rmi.* when all my beans are local (and don't even have remote interfaces)?

                    2- I'm using the Object type and not accessing any methods on the object (which is an existing entity bean) so I don't see why there'd be any casting issues.


                    The cast that is failing is here:
                    Object tempU = (Object)ejbSelectTempUserByUserid(userid);

                    Declaration for my select method and it's EJB QL:
                    public abstract UserBean ejbSelectTempUserByUserid(String userid) throws FinderException ;
                    EJB QL: SELECT OBJECT(u) FROM User as u WHERE u.userid = ?1

                    I will continue searching and repost if I get a handle on this. Thanks for your time, it is greatly appreciated.
                    Ryan

                    • 7. Re: Do JBoss and Tomcat share a VM or one each?
                      Ryan Delano Newbie

                      Thanks Adrian for your reply,

                      I confirmed that I was using a clean InitialContext, so long as this is the same then we are on the same page:
                      jndiContext = new javax.naming.InitialContext();

                      I did try the unwrapping technique per your advice but wasn't sure how to get through several layers. I feel like the stack trace is offering enough info already so I didn't fight to unwrap repeatedly. The reason for my original post and it's lack of code or stack trace is that I don't understand why rmi is involved when using local interfaces.

                      A heavily trimmed stack looks like this:

                      [BEGIN STACK]
                      javax.ejb.EJBException: Undeclared throwable after one unwrap:
                      Embedded Exception: null
                      Embedded Exception
                      $Proxy72; nested exception is:
                      javax.ejb.EJBException: null
                      Embedded Exception: $Proxy72
                      at com.rydel.fys.UserSessionBean.isUseridAvailable(UserSessionBean.java:441)
                      [HUGE SNIP]

                      java.rmi.ServerException: null
                      Embedded Exception
                      $Proxy72; nested exception is:
                      javax.ejb.EJBException: null
                      Embedded Exception
                      $Proxy72
                      javax.ejb.EJBException: null
                      Embedded Exception
                      $Proxy72
                      at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1148)
                      [HUGE SNIP]

                      java.lang.ClassCastException: $Proxy72
                      at com.rydel.fys.UserBean$Proxy.ejbSelectTempUserByUserid()
                      [END STACK]


                      I just debugged deeper into my beans to find that I am unable to load a CMP2.0 entity bean. (My test client can create them no problem.) The code all executes fine if there is no matching data, but when I lookup an existing PK blam! As the stack indicates, the root of the problem appears to be a bad type cast, but I don't understand two things:

                      1- Why am I getting any error in my stack via java.rmi.* when all my beans are local (and don't even have remote interfaces)?

                      2- I'm using the Object type and not accessing any methods on the object (which is an existing entity bean) so I don't see why there'd be any casting issues.


                      The cast that is failing is here:
                      Object tempU = (Object)ejbSelectTempUserByUserid(userid);

                      Declaration for my select method and it's EJB QL:
                      public abstract UserBean ejbSelectTempUserByUserid(String userid) throws FinderException ;
                      EJB QL: SELECT OBJECT(u) FROM User as u WHERE u.userid = ?1

                      I will continue searching and repost if I get a handle on this. Thanks for your time, it is greatly appreciated.
                      Ryan

                      • 8. Re: Do JBoss and Tomcat share a VM or one each?
                        Adrian Brock Master

                        What do you have you in your war?

                        If you have any JBoss client jars, especially
                        jnp-client.jar or jboss-client.jar remove them.

                        Regards,
                        Adrian

                        • 9. Found the cause / Re: Do JBoss and Tomcat share a VM
                          Ryan Delano Newbie

                          Hi Adrian,

                          Thanks again for time and effort here. And sorry for the 8 million posts - I didn't know that the forum could store a post but not display it for hours. When I thought I was unable to reply to this original thread I posted a follow up to a new thread of the same title (which showed up immediately in the forum despite my inability to post to this thread.)

                          If you look at my few lines of code you'll see that I was expecting a bean class back from my select method:
                          public abstract UserBean ejbSelectTempUserByUserid(String userid) throws FinderException ;What should have been there was a LOCAL bean. For some reason the "bean class" was offered in JBuilder's droplist when I created the method and I chose it. Once I switched the method declarations to UserLocal and adjusted dependent code everything worked and made sense. The cast error was happening internally in generated code (which is why my (Object) cast had nothing to do with it). I found it by adding debug statements in the entity bean interface methods. As soon as I found that the bean wasn't being created I knew the problem was between my code and the generator.

                          Painful lessons, but I'm learning.

                          Thank you so much for helping. (Even if I weren't such a 'tard) the answer to the shared VM was something I needed to know.
                          Ryan