0 Replies Latest reply on Dec 20, 2005 10:29 PM by Andrew Swan

    When exactly does JBoss load any classes referenced by EJBs?

    Andrew Swan Newbie

      I've found a quirk when deploying an EJB. If a class appears in a method signature, JBoss loads that class at deploy time, i.e. the bean will fail to deploy if the class can't be found. For example, if the Foo class isn't available, a bean containing this method won't deploy, even though the method is private:

      private void doFoo(Foo foo) {
       // do foo stuff
       }


      But if the class is only used within the method, then JBoss only seems to load the class when the method is invoked. So the following code does allow the bean to deploy, even if the Foo class isn't available yet:

      private void doFoo(Object o) {
       Foo foo = (Foo) o;
       // do foo stuff
       }


      And as long as the Foo class gets loaded before the method is invoked (e.g. when the EJB containing the Foo class is deployed), everything works fine.

      I've observed the above while using JBoss 3.2.5 and Java 1.5.0_04 on WinXP Pro. Can someone please tell me:
      - is this a JBoss thing or a Java thing?
      - can I rely on it?
      - is it likely to change in a future version?

      The background is that I have an EJB JAR file that references classes in an EAR file. I can't guarantee the order in which JBoss deploys these two artifacts when it starts up, so I'm keen to know if the workaround I've described above will continue to work.