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!
本文介绍了解决Glassfish部署应用时因未正确配置数据库连接导致的问题。通过直接修改配置文件的方式,详细展示了如何设置jdbc-connection-pool和jdbc-resource,确保应用能够成功部署。
8万+

被折叠的 条评论
为什么被折叠?



