当前位置: 首页 > 知识库问答 >
问题:

Glassfish Server部署. war时出错:部署期间发生错误:准备应用程序时出现异常:资源无效

有骏祥
2023-03-14

我正在使用以下内容:

  • NetBeans IDE 7.3(构建:201306052037)
  • Java:1.7.0_17;Java热点(TM)64位服务器VM 23.7-b01
  • NetBeans集成GlassFish服务器开源版3.1.2.2(构建5)

我用NetBeans创建了一个RESTful Web服务,并将其部署在NetBeans下,效果良好。

因此,我将生成的.war文件复制到另一台机器,该机器使用:

  • Oracle GlassFish服务器3.1.2.2
  • java version"1.7.0_21"JavaHotSpot(TM)Client VM(build 23.21-b01,混合模式)

当我想部署.war文件时,我收到以下错误:

远程失败:部署期间发生错误:准备应用时出现异常:资源无效:webservice__pm。请参阅server.log了解更多详细信息。命令部署失败。

这是我的玻璃鱼资源.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
    <jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="webservice" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
        <property name="portNumber" value="3306"/>
        <property name="databaseName" value="webservice"/>
        <property name="User" value="webservice"/>
        <property name="Password" value="webservice"/>
        <property name="URL" value="jdbc:mysql://localhost:3306/webservice?zeroDateTimeBehavior=convertToNull"/>
        <property name="Url" value="jdbc:mysql://localhost:3306/webservice?zeroDateTimeBehavior=convertToNull"/>
        <property name="driverClass" value="com.mysql.jdbc.Driver"/>
    </jdbc-connection-pool>
    <jdbc-resource enabled="true" jndi-name="webservice" object-type="user" pool-name="webservice"/>
</resources>

这是我的坚持.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
  <persistence-unit name="DatensammlerPU" transaction-type="JTA">
    <jta-data-source>webservice</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
    </properties>
  </persistence-unit>
</persistence>

以下是来自server.log的错误消息:

[#|2013-06-19T17:52:55.064+0200|SEVERE|oracle-glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=68;_ThreadName=Thread-2;|Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method|#]

[#|2013-06-19T17:52:55.064+0200|SEVERE|oracle-glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=68;_ThreadName=Thread-2;|Exception while preparing the app|#]

[#|2013-06-19T17:52:55.065+0200|SEVERE|oracle-glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=68;_ThreadName=Thread-2;|Invalid resource : webservice__pm
java.lang.RuntimeException: Invalid resource : webservice__pm
        at com.sun.enterprise.connectors.ConnectorRuntime.lookupDataSourceInDAS(ConnectorRuntime.java:540)
        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:348)
        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 com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
        at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
        at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
        at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
        at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
        at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
        at java.lang.Thread.run(Thread.java:722)
Caused by: com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Invalid resource : webservice__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)
        ... 40 more
|#]

[#|2013-06-19T17:52:55.070+0200|WARNING|oracle-glassfish3.1.2|javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.deployer|_ThreadID=111;_ThreadName=Thread-2;|The log message is empty or null. Please log an issue against the component in the logger field.|#]

[#|2013-06-19T17:52:55.082+0200|WARNING|oracle-glassfish3.1.2|javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.deployer|_ThreadID=111;_ThreadName=Thread-2;|The log message is empty or null. Please log an issue against the component in the logger field.|#]

[#|2013-06-19T17:52:55.083+0200|WARNING|oracle-glassfish3.1.2|javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.deployer|_ThreadID=111;_ThreadName=Thread-2;|The log message is empty or null. Please log an issue against the component in the logger field.|#]

[#|2013-06-19T17:52:55.083+0200|SEVERE|oracle-glassfish3.1.2|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=68;_ThreadName=Thread-2;|Exception while preparing the app : Invalid resource : webservice__pm
com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Invalid resource : webservice__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:348)
        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 com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
        at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
        at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
        at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
        at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
        at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
        at java.lang.Thread.run(Thread.java:722)

我读了很多,我应该使用java:app/webservice,但它对我不起作用!!!还有其他建议吗?

共有2个答案

常永长
2023-03-14

我有同样的问题,它表现在各种奇怪的例外中,与我的实际问题完全无关。

由于某种原因,jdbc/[您的资源名称]的资源尚未在 GlassFish 中创建,它会向您抛出一个 jdbc/[您的资源名称]__[生成的东西,如“pm”] 作为源。

解决此问题的一种方法(我使用的一种方法是在localhost:4848的浏览器中手动进入GlassFish管理控制台,然后在左侧菜单中转到资源并按照其中的树进行操作:JDBC

这正是发生在我身上的事情,这也是我开始得到奇怪的异常的地方,比如它怎么突然找不到我的DB驱动程序,即使我在依赖文件夹中盯着它。

重新启动NetBeans,刷新GlassFish并在必要时重新启动它。运行项目,它应该会部署。

(我从关于MDB的异常中找到了我的问题的根源,当我删除它时,它突然与我添加的资源一起工作,然后只要GlassFish中有匹配的资源,我就可以将其重命名为我想要的任何内容。您可能还需要在 GlassFish 中查看 MDB JNDI 设置,并手动为它们创建资源)

当您编写时,NetBeans将自动完成现有资源

柳威
2023-03-14

现在我有了解决方案。我忘记了JDBC资源:打开Glassfish服务器Web界面并导航到资源-

 类似资料:
  • 部署过程中出错:部署应用程序[EnterpriseApplication1]时出现异常:UnsupportedClassVersionError:类mn.interactive.module.meta.dao.MetadataDao的主要或次要版本号不受支持,这些版本号大于Java Runtime Environment版本1.7.0_02中的版本号。有关详细信息,请参阅server.log。 将

  • 我开发了一个springboot war文件来部署到服务器中,但是由于某些原因,我不得不将它部署到xampp的tomcat中,但是我得到了如下错误。我怎么才能修好这个? 信息:validateJarFile(c:\xampp\tomcat\webapps\ipf-2.0.0.rc2\WEB-INF\lib\tomcat-embed-core-8.5.28.jar)-jar未加载。参见Servlet

  • 每次都会出现以下错误!有相同的修复方法吗? 2021-10-07T10:47:31.133956 00:00heroku[路由器]: at=错误代码=H10 desc="应用程序崩溃"方法=GET路径="/"主机=zturlshortener.herokuapp.comrequest_id=c2f90e55-52f5-4955-a1d6-4028456cfddb fwd="103.199.173.

  • 在“生产模式”(使用Vaadin 19.0.9和gradle)下生成“war”文件(大小为90 MB)后,Tomcat 9.0.52中的部署过程非常慢并显示此错误 这种错误经常发生,但并不总是如此。 tomcat服务器运行在Ubuntu 18上,内存为8gb。java版本为15.0.2(适用于此计算机和用于开发的计算机)。 知道吗?谢谢 PS:这是堆栈跟踪:

  • 我有一个Grails(2.5.3版)应用程序,当我通过选项:要部署的WAR文件在Tomcat中部署时,选择WAR文件,会出现以下错误。如果我尝试一个更简单的应用程序(大小、复杂度等),它运行得很好。 但是,如果在从manager运行应用程序时手动将war文件的内容复制到Tomcat路径:pathTomcat/webapps/myApplication,则效果良好。出现任何错误。 错误: Grail

  • 数据库为:MSSQL 2008 R2 OS=Windows Server 2008 R2 错误日志为: 2014年3月12日下午5:19:53 org.apache.catalina.realm.UserDatabaseRealm开始内部严重:异常查找键UserDatabase javax.naming.NameNotFoundException:Name[UserDatabase]下的UserD