EJB client can't find a DataSource that tests successfully in WebLogic admin console
        Posted  
        
            by suszterpatt
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by suszterpatt
        
        
        
        Published on 2010-05-19T13:13:05Z
        Indexed on 
            2010/05/19
            23:20 UTC
        
        
        Read the original article
        Hit count: 513
        
Disclaimer: I'm completely new to JEE/EJB and all that, so bear with me.
I have a simple EJB that I can successfully deploy using JDeveloper 11g's integrated WebLogic server and a remote database connection (JDBC). I have a DataSource named "PGY2" defined in WebLogic, and I can test it successfully from the admin console.
Here's the code of the client I'm trying to test it with (generated entirely by JDev except for the three method calls on adminManager):
public class AdminManagerClient {
    public static void main(String [] args) {
        try {
            final Context context = getInitialContext();
            AdminManager adminManager = (AdminManager)context.lookup("Uran-AdminManager#hu.elte.pgy2.BACNAAI.UranEJB.AdminManager");
            adminManager.addAdmin("root", "root", "Kovács Isten");
            adminManager.addStudent("BACNAAI", "matt", "B Cs", 2005);
            adminManager.addTeacher("SIPKABT", "patt", "S P", "numanal", "Dr.");
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    private static Context getInitialContext() throws NamingException {
        Hashtable env = new Hashtable();
        // WebLogic Server 10.x connection details
        env.put( Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory" );
        env.put(Context.PROVIDER_URL, "t3://127.0.0.1:7101");
        return new InitialContext( env );
    }
}
But when I try to run this, I get the following error on the line with adminManager.addAdmin (that is, after the lookup):
javax.ejb.EJBException: EJB Exception: ; nested exception is: 
    Exception [EclipseLink-4002] (Eclipse Persistence Services - 1.0.2 (Build 20081024)): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Internal error: Cannot obtain XAConnection Creation of XAConnection for pool PGY2 failed after waitSecs:30 : java.sql.SQLException: Data Source PGY2 does not exist.
Why can't the client find the data source, and how do I make it find it?
EDIT: I took a closer look at WebLogic's output during deployment, and I found this. I have no idea what it means, but it may be relevant:
<2010.05.20. 0:50:43 CEST> <Error> <Deployer> <BEA-149231> <Unable to set the activation state to true for the application 'PGY2'.
weblogic.application.ModuleException: 
    at weblogic.jdbc.module.JDBCModule.activate(JDBCModule.java:349)
    at weblogic.application.internal.flow.ModuleListenerInvoker.activate(ModuleListenerInvoker.java:107)
    at weblogic.application.internal.flow.DeploymentCallbackFlow$2.next(DeploymentCallbackFlow.java:411)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
    at weblogic.application.internal.flow.DeploymentCallbackFlow.activate(DeploymentCallbackFlow.java:74)
    Truncated. see log file for complete stacktrace
weblogic.common.ResourceException:  is already bound
    at weblogic.jdbc.common.internal.RmiDataSource.start(RmiDataSource.java:387)
    at weblogic.jdbc.common.internal.DataSourceManager.createAndStartDataSource(DataSourceManager.java:136)
    at weblogic.jdbc.common.internal.DataSourceManager.createAndStartDataSource(DataSourceManager.java:97)
    at weblogic.jdbc.module.JDBCModule.activate(JDBCModule.java:346)
    at weblogic.application.internal.flow.ModuleListenerInvoker.activate(ModuleListenerInvoker.java:107)
    Truncated. see log file for complete stacktrace
> 
© Stack Overflow or respective owner