简体   繁体   English

EJB客户端找不到在WebLogic管理控制台中成功测试的数据源

[英]EJB client can't find a DataSource that tests successfully in WebLogic admin console

Disclaimer: I'm completely new to Java EE/EJB and all that, so bear with me. 免责声明:我对Java EE / EJB和所有这些都是全新的,所以请耐心等待。

I have a simple EJB that I can successfully deploy using JDeveloper 11g's integrated WebLogic server and a remote database connection (JDBC). 我有一个简单的EJB,可以使用JDeveloper 11g的集成WebLogic服务器和远程数据库连接(JDBC)成功进行部署。 I have a DataSource named "PGY2" defined in WebLogic, and I can test it successfully from the admin console. 我在WebLogic中定义了一个名为“ PGY2”的数据源,可以从管理控制台成功对其进行测试。

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 ): 这是我尝试使用的客户端代码(完全由JDev生成,除了adminManager的三个方法调用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): 但是,当我尝试运行此命令时,在adminManager.addAdmin的行上(即在查找之后)出现以下错误:

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. 编辑:在部署过程中,我仔细查看了WebLogic的输出,发现了这一点。 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
> 

Actually, it's not the EJB client that can't find the DataSource, it's the code running inside the container and using JPA. 实际上,不是EJB客户端找不到数据源,而是代码在容器内运行并使用JPA。 More precisely, it's the JPA provider - EclipseLink here - that can't find it. 更准确地说,是JPA提供程序-此处的EclipseLink-找不到它。 Double check that the datasource name defined in your persistence.xml (in the <jta-data-source> ) matches the JNDI name of the PGY2 DataSource. 仔细检查您在persistence.xml定义的数据源名称(在<jta-data-source> )是否与PGY2数据源的JNDI名称匹配。

WebLogic provides a JNDI browser (to browse the JNDI tree), use it if required to see under which name your datasource is registrered. WebLogic提供了一个JNDI浏览器(用于浏览JNDI树),如果需要,可以使用它来查看您的数据源是以哪个名称注册的。

Update: Could you have linebreaks in the JNDI name field of the datasource (see this blog post )? 更新:您能否在数据源的JNDI名称字段中使用换行符(请参阅此博客文章 )?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM