I don't see any obvious reasons why this should fail. I looked up a similar issue in JBoss JIRA and the comments there seemed to point to classloading issues. Maybe you too are running into a similar issue. What classes have you packaged in your client application? Do you have the MonitorBean packaged in your client application? If so, i would suggest removing that and having only the Monitor interface in the client application. See if that change helps. Let us know if it still doesn't work, we'll see what else might be the cause of this exception.
I have resolved the NullPointer issue. Actually, I changed the <jta-data-source>java:/OracleDS</jta-data-source> to <non-jta-data-source>java:/OracleDS</non-jta-data-source>, which created the problem.
Once I reverted back to <jta-data-source>java:/OracleDS</jta-data-source> in persistence.xml, everything worked fine.
However, I'd be grateful if you can answer my other queries/confusions.
Also the @PersistenceUnit and @PersistenceContext things are confusing
The PersistenceUnit and the PersistenceContext inject different 'types' of resources. The @PersistenceUnit is used to inject an EntityManagerFactory whereas the @PersistenceContext is used to inject an EntityManager. In one of the online documentation that i read, they had this detailed explanation:
The @PersistenceContext and @PersistenceUnit annotations perform a similar function: inject persistence context information into a variable; the main difference is the data type of the instance into which you inject the information. If you prefer to have full control over the lifecycle of the EntityManager in your session bean, then use @PersistenceUnit to inject into an EntityManagerFactory instance, and then write the code to manually create an EntityManager and later destroy when you are done, to release resources. If you prefer that the EJB container manage the lifecycle of the EntityManager, then use the @PersistenceContext annotation to inject directly into an EntityManager.
Your other question:
Do I have to use transactions??
It depends on what you are doing. EJBs let you define transactions on each method of the bean. Moreover, if you are using a EntityManager, then you will have to have a transaction. [ December 27, 2007: Message edited by: Jaikiran Pai ]