【问题标题】:JDBC resource name being modified by container ('_pm' being appended to it)容器正在修改的 JDBC 资源名称(“_pm”被附加到它)
【发布时间】:2013-02-10 12:27:59
【问题描述】:

我正在尝试将一个非常简单的 Web 应用程序部署到 CloudBees 上的 JavaEE Web Profile 堆栈。我已经创建了一个将被使用的数据库。

我创建了我的 WAR 文件,并将其部署到 Glassfish3 配置文件中,但它出错了。我也尝试过 JBoss ,但也失败了,但出现了不同的错误。我已经使用 SDK(而不是 CloudBees XML 文件(因为这听起来像是已弃用)将数据库绑定到应用程序。但无论应用程序仍然无法部署(即使在重新启动后)出现此错误:

[#|2013-02-25T11:03:57.584+0000|SEVERE|glassfish3.1.2|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=12;_ThreadName=AutoDeployer;|Exception while preparing the app : Invalid resource : jdbc/resmandb__pm
com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Invalid resource : jdbc/resmandb__pm
    at com.sun.enterprise.connectors.service.ConnectorResourceAdminServiceImpl$MyDataSource.validateResource(ConnectorResourceAdminServiceImpl.java:274)
    at com.sun.enterprise.connectors.service.ConnectorResourceAdminServiceImpl$MyDataSource.setResourceInfo(ConnectorResourceAdminServiceImpl.java:255)
    at com.sun.enterprise.connectors.service.ConnectorResourceAdminServiceImpl.lookupDataSourceInDAS(ConnectorResourceAdminServiceImpl.java:245)
    at com.sun.enterprise.connectors.ConnectorRuntime.lookupDataSourceInDAS(ConnectorRuntime.java:538)
    at com.sun.enterprise.connectors.ConnectorRuntime.lookupPMResource(ConnectorRuntime.java:469)
    at org.glassfish.persistence.common.PersistenceHelper.lookupPMResource(PersistenceHelper.java:63)
    at org.glassfish.persistence.jpa.ProviderContainerContractInfoBase.lookupDataSource(ProviderContainerContractInfoBase.java:71)
    at org.glassfish.persistence.jpa.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:108)
    at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:155)
    at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:120)
    at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:224)
    at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:495)
    at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:233)
    at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:168)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:871)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:410)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:353)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
    at org.glassfish.deployment.autodeploy.AutoOperation.run(AutoOperation.java:145)
    at org.glassfish.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:575)
    at org.glassfish.deployment.autodeploy.AutoDeployer.deployAll(AutoDeployer.java:461)
    at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:389)
    at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:380)
    at org.glassfish.deployment.autodeploy.AutoDeployService$1.run(AutoDeployService.java:220)
    at java.util.TimerThread.mainLoop(Timer.java:512)
    at java.util.TimerThread.run(Timer.java:462)
|#]

我不明白的是,它为什么要寻找资源jdbc/resmandb__pm。它采用我绑定的任何名称(在本例中为 resman)并添加一个 _pm

我做错了什么?这个应用程序没有太多内容,它在 Glassfish 3 服务器中运行。

编辑:我一直在一个独立的 glassfish 环境中玩一些游戏。而且,当我在 glassfish-web.xml 中没有 jdbc 资源条目时,看起来 JPA 提供程序(在本例中为 EclipseLink)正在寻找两个 jdbc 资源:jdbc/_pm 和 jdbc /_nontx,这里是web.xml中声明的资源名称。

所以,我还没有尝试过,但看起来我需要在 bees-web.xml 中定义它,CloudBees 自己的文档试图让人们不要使用它。不幸的是,资源绑定在 GlassFish 3 环境中效果不佳。这就是我目前所发现的。

【问题讨论】:

    标签: java jdbc cloudbees


    【解决方案1】:

    将资源绑定到应用程序时,必须使用 --alias 参数来配置它将在应用程序中使用的逻辑名称。对于数据源,如果您在 wen.xml 中有一个资源引用:

       <resource-ref>
            <res-ref-name>jdbc/myDB</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
        </resource-ref>
    

    然后将数据源绑定为:

    bees app:bind --database  myDatabase --alias myDB
    

    【讨论】:

    • 嗯。我刚试过这个。这并没有什么不同。仍然收到以下错误:(
    • [#|2013-03-01T22:44:35.336+0000|SEVERE|glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=12 ;_ThreadName=AutoDeployer;|准备应用程序时出现异常|#] [#|2013-03-01T22:44:35.337+0000|SEVERE|glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3 .server|_ThreadID=12;_ThreadName=AutoDeployer;|无效资源:jdbc/resmandb__pm java.lang.RuntimeException:无效资源:com.sun.enterprise.connectors.ConnectorRuntime.lookupDataSourceInDAS(ConnectorRuntime.java:540) 处的 jdbc/resmandb__pm
    • 而且,我的代码中没有任何地方使用 __pm 作为 jdbc 地址,我使用了别名。我被难住了
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-10
    • 2014-10-27
    • 1970-01-01
    • 1970-01-01
    • 2011-11-07
    • 1970-01-01
    相关资源
    最近更新 更多