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

本文介绍了解决Glassfish部署应用时因未正确配置数据库连接导致的问题。通过直接修改配置文件的方式,详细展示了如何设置jdbc-connection-pool和jdbc-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!
对于ESP32出现发送错误errno 118和接收错误errno 9,可参考以下可能的解决办法: ### 发送错误errno 118 errno 118通常表示无法连接/触及到目标地址和端口,这可能是由于网络连接问题、目标服务器未运行或地址端口配置错误等原因导致。 - **检查网络连接**:确保ESP32已成功连接到网络。可以通过在代码中添加网络连接状态检查,如在`WiFi_connect()`函数调用后,检查返回值或网络连接状态标志,以确认网络连接正常。例如: ```c // 连接网络 if (WiFi_connect() != ESP_OK) { // 处理网络连接失败 while(1); } ``` - **检查目标地址和端口**:确认目标服务器的IP地址和端口号是否正确。可以使用网络工具(如ping命令、telnet命令)测试目标服务器是否可达。例如,在终端中使用`ping 192.168.10.100`检查IP地址是否可达,使用`telnet 192.168.10.100 8080`检查端口是否开放。 - **检查服务器状态**:确保目标服务器正在运行,并且监听指定的端口。可以在服务器端查看日志或使用工具检查服务器的运行状态。 - **重试机制**:在连接失败时,可以实现重试机制,多次尝试连接目标服务器。例如: ```c int max_retries = 5; int retries = 0; while (retries < max_retries) { int c_sock = create_sock("192.168.10.100", 8080); if (sock_connect(c_sock) == ESP_OK) { break; } retries++; vTaskDelay(pdMS_TO_TICKS(1000)); // 等待1秒后重试 } if (retries == max_retries) { // 处理连接失败 while(1); } ``` ### 接收错误errno 9 errno 9通常表示文件描述符无效,这可能是由于socket未正确创建或已关闭导致。 - **检查socket创建**:确保socket已正确创建,并且返回的文件描述符有效。可以在创建socket后,检查返回值是否为有效的文件描述符。例如: ```c int c_sock = create_sock("192.168.10.100", 8080); if (c_sock < 0) { // 处理socket创建失败 while(1); } ``` - **检查socket状态**:在接收数据前,确保socket处于打开状态。可以在接收数据前,检查socket的状态标志或使用`getsockopt()`函数检查socket的状态。 - **避免重复关闭**:确保在使用socket期间,不会重复关闭socket。可以在代码中添加标志位,记录socket的关闭状态。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值