容器修改的JDBC资源名称('_pm'被附加到它)

时间:2013-02-25 11:12:53

标签: java jdbc cloudbees

我正在尝试将一个非常简单的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-web.xml中没有jdbc资源的条目时,看起来JPA提供程序(在本例中为EclipseLink)正在寻找两个jdbc资源:jdbc / _ pm和jdbc / _nontx,其中是web.xml中声明的资源的名称。

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

1 个答案:

答案 0 :(得分:0)

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

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

然后将datasource绑定为:

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