1 Reply Latest reply on May 23, 2003 11:31 AM by tschlemmer

    Servlet to EJB inter-JVM Communcation?

    tschlemmer Newbie

      Is there some magic required or something to get Servlets and EJBs that are in the same JVM to communicate properly? I've tried both JBoss 3.0.7 and 3.1.2 with the embedded version of Tomcat and I cannot seem to get any CMP entity beans to retrieve anything from the database. Everytime findByPrimaryKey() is called I always get ObjectNotFoundExceptions even though I know the PK I'm specifying should return something from the database.

      When I try my EJBs out by connecting to JBoss from a remote system or even a JVM that is separate from the JBoss/Tomcat JVM everything works. But when I try to retrieve data through the CMP container from a Servlet that runs within the same JVM I can't retrieve any data at all.

      We've followed a pattern where all entity beans have local interfaces only and our remote session beans have remote interfaces. All access to entity beans is done through the session beans. On the servlet side of things I can get a Home reference to a session bean and create a remote interface and make method calls but when the session bean attempts to perform a findByPrimaryKey method invocation on any entity bean I'm always getting ObjectNotFoundExceptions.

      Other strange things I notice is that when I used to deploy my EJBs I'd see the actual SQL table name each entity bean mapped to. Now all of a sudden the table names are appearing as the entity bean names instead and all of the DEBUG level SQL statement messages use the entity bean names rather than the actual Oracle table names.



        • 1. Re: Servlet to EJB inter-JVM Communcation?
          tschlemmer Newbie

          Problem Solved...

          What appears to have happened is someone in our team made a gratuitous change to one of our build.xml files. The change affected what XML deployment descriptors get placed in each bean's JAR file. The missing piece was that the jbosscmp-jdbc.xml file wasn't getting included in any JAR files anymore.

          We hadn't seen this behavior before since we've been using XDoclet for all of our boiler plate stuff and we've had an Oracle datasource defined from the beginning of our project. Since we weren't providing the appropriate mappings to the DB tables the bean container took it upon itself and generated tables named after our entity beans.

          I guess we might have discovered this problem sooner but it looks like the principal we're using for our OracleDbRealm in the login-config.xml file has the ability to create tables. I'm thinking for security reasons we probably do not want our Oracle principal having the ability to create tables from JBoss.