私は以下を使用しています:
NetBeansを使用してRESTfulWebサービスを作成し、NetBeansの下にデプロイしたところ、正常に機能しました。
そこで、生成された.warファイルを以下を使用する別のマシンにコピーしました。
.warファイルをデプロイしたい場合、次のエラーが表示されます。
リモートエラー:デプロイ中にエラーが発生しました:アプリの準備中に例外が発生しました:無効なリソース:webservice__pm。詳細についてはserver.logを参照してください。コマンドデプロイに失敗しました。
ここに私のglassfish-resources.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>
これが私のpersistence.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を使用する必要があることをたくさん読みましたが、うまくいきませんでした!!!他に何か提案はありますか?
今、私は解決策を持っています。 JDBCリソースを忘れました:Glassfish-Server Webインターフェイスを開き、[リソース]-> [JDBC]-> [JDBCリソース]に移動して、適切な接続プールを使用して新しいリソースを作成します。リソースと接続プールがない場合、展開は失敗します!!! Java:app/webserviceなしで私のために働いた...
私はこれと同じ問題を抱えていましたが、実際の問題とはまったく関係のないさまざまな奇妙な例外の大きなホラバルーに現れました。
何らかの理由で、jdbc/[your resource name]
のリソースがGlassFishで作成されておらず、ソースとしてjdbc/[your resource name]__[generated thing, like "pm"]
がスローされます。
これを修正する1つの方法(私が使用した方法)は、ブラウザのlocalhost:4848
でGlassFish管理コンソールに手動で移動し、左側のメニューでResources
に移動して、その中のツリーをたどることです。 :JDBC > JDBC resources
。 JDBC Resources
タブで、新しいリソースを作成し、jdbc/[your resource name]
という名前を付けます。__[generated thing, like "pm"]
は必要ありません。
これはまさに私に起こったことであり、依存関係フォルダーでDBドライバーを見つめていても、突然DBドライバーが見つからなかったなど、奇妙な例外が発生し始めた場所です。
NetBeansを再起動し、GlassFishを更新して、必要に応じて再起動します。プロジェクトを実行すると、デプロイされます。
(MDBに関する例外から問題の原因を見つけました。それを削除すると、追加したリソースで突然機能し、名前が変更できました。 GlassFishの一致するリソース。GlassFishのMDBJNDI設定も確認し、それらのリソースを手動で作成する必要がある場合があります)
<jta-data-source>
タグを書き込むと、NetBeansは既存のリソースをオートコンプリートします。オートコンプリートしない場合は、おそらく存在しません。