Solution:Error occurred during deployment: Exception while preparing the app : Invalid resource

Problems happened in Glassfish:

When trying to deploy it on my own machine which I used to develop my WS, the deployment successes. But when I try to deploy it on another machine, it fails with this error message:


"Error occurred during deployment: Exception while preparing the app : Invalid resource : java-appbc/movieDB__pm. Please see server.log for more details."

The reason for this error is that I haven't set up proper database connection (both jdbc-connection-pool and jdbc-resource) on the targeting Glassfish server.

The solution is following:

The Admin Console is not very user friendly, so the third way involves altering the configuration file directly.

First find out which data-source you are using: 

in the Projects view of Netbeans, open <YOUR PROJECT>->Configuration Files->persistence.xml and find the <jta-data-source> tag. The content of it is the data source you are using. for example, mine is: java-appbc/movieDB.

Second, locate your domain’s configuration file on your development machine. You can find it through Netbeans’ Services View. Find GlassFish Server, right click it and find properties. You will find your domain folder and domain name. Go to <your domain>->config, open domain.xml file.

Thirdly, copy related information from your development machine to the machine you want to deploy your WAR file. These information includes: jdbc-resource whose jndi-name is your data source and related jdbc-connection-pool, and resource-ref. For example, mine is:

<jdbc-connection-pool connection-validation-method="auto-commit" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" wrap-jdbc-objects="false" res-type="javax.sql.DataSource" name="mysql_id24695858_fit5192a1Pool">
      <property name="URL" value="jdbc:mysql://localhost:3306/id24695858?zeroDateTimeBehavior=convertToNull"></property>
      <property name="driverClass" value="com.mysql.jdbc.Driver"></property>
      <property name="portNumber" value="3306"></property>
      <property name="databaseName" value="id24695858"></property>
      <property name="User" value="fit5192a1"></property>
      <property name="serverName" value="localhost"></property>
      <property name="Password" value=""></property>
</jdbc-connection-pool>   

<jdbc-resource pool-name="mysql_id24695858_fit5192a1Pool" jndi-name="java-appbc/movieDB"></jdbc-resource>

They are under <resources> element.

And

<resource-ref ref="java-appbc/movieDB"></resource-ref>.

It’s under <servers> element.

Copy that information to the domain config file. Restart your GlassFish and Deploy it again.

It works!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值