XAException occurred. Error code is: XAER_RMERR


问题提出:ibm portal默认使用内置db2数据库,执行迁移操作到oracle后,无法正常停止portal进程,报如下错误信息:

[12/18/09 19:18:39:289 CST] 00000028 InternalOracl I DSRA8203I: Database product name : Oracle
[12/18/09 19:18:39:289 CST] 00000028 InternalOracl I DSRA8204I: Database product version : Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
[12/18/09 19:18:39:289 CST] 00000028 InternalOracl I DSRA8205I: JDBC driver name : Oracle JDBC driver
[12/18/09 19:18:39:290 CST] 00000028 InternalOracl I DSRA8206I: JDBC driver version : 10.2.0.1.0
[12/18/09 19:18:39:290 CST] 00000028 InternalOracl I DATA_STORE_HELPER_NAME
[12/18/09 19:18:39:290 CST] 00000028 WSRdbDataSour I DSRA8208I: JDBC driver type : ""
[12/18/09 19:18:39:294 CST] 00000028 WSRdbXaResour E DSRA0304E: XAException occurred. XAException contents and details are: The cause is : null.
[12/18/09 19:18:39:294 CST] 00000028 WSRdbXaResour E DSRA0302E: XAException occurred. Error code is: XAER_RMERR (-3). Exception is:
[12/18/09 19:18:39:295 CST] 00000028 XARminst E WTRN0037W: The transaction service encountered an error on an xa_recover operation. The resource was com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl@15d2dc71. The error code was XAER_RMERR. The exception stack trace follows: javax.transaction.xa.XAException at oracle.jdbc.xa.OracleXAResource.recover(OracleXAResource.java:526)
at com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl.recover(WSRdbXaResourceImpl.java:992)
at com.ibm.ws.Transaction.JTA.XARminst.recover(XARminst.java:137)
at com.ibm.ws.Transaction.JTA.XARecoveryData.recover(XARecoveryData.java:690)
at com.ibm.ws.Transaction.JTA.PartnerLogTable.recover(PartnerLogTable.java:514)
at com.ibm.ws.Transaction.JTA.RecoveryManager.resync(RecoveryManager.java:1896)
at com.ibm.ws.Transaction.JTA.RecoveryManager.run(RecoveryManager.java:2608)
at java.lang.Thread.run(Thread.java:571)

解决办法:

方法一:grant select on dba_pending_transactions to ; --------------------USER为你要连接oracle db 的用户名

方法二:更新jdbc驱动到10.2.0.4

 

 

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10537377/viewspace-623219/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10537377/viewspace-623219/

E:\大三下\物联网\pycharm_project\pythonProjec_1\venv1\Scripts\python.exe E:\大三下\物联网\pycharm_project\pythonProjec_1\shiyan4\MqttDemo.py Failed to connect. return code :134, reasonBad user name or password Disconnect to Mqtt Broker. topic: Topic_SmokeValue_42207708 Failed to connect. return code :134, reasonBad user name or password Disconnect to Mqtt Broker. topic: Topic_SmokeValue_42207708 Failed to connect. return code :134, reasonBad user name or password Disconnect to Mqtt Broker. topic: Topic_SmokeValue_42207708 Failed to connect. return code :134, reasonBad user name or password Disconnect to Mqtt Broker. topic: Topic_SmokeValue_42207708 Failed to connect. return code :134, reasonBad user name or password Disconnect to Mqtt Broker. topic: Topic_SmokeValue_42207708 Failed to connect. return code :134, reasonBad user name or password Disconnect to Mqtt Broker. topic: Topic_SmokeValue_42207708 Failed to connect. return code :134, reasonBad user name or password Disconnect to Mqtt Broker. topic: Topic_SmokeValue_42207708 Failed to connect. return code :134, reasonBad user name or password Disconnect to Mqtt Broker. topic: Topic_SmokeValue_42207708 Exception ignored in: <module 'threading' from 'F:\\python3.11\\Lib\\threading.py'> Traceback (most recent call last): File "F:\python3.11\Lib\threading.py", line 1629, in _shutdown lock.acquire() KeyboardInterrupt: Process finished with exit code 0 E:\大三下\物联网\pycharm_project\pythonProjec_1\venv1\Scripts\python.exe E:\大三下\物联网\pycharm_project\pythonProjec_1\shiyan4\MqttDemo.py Failed to connect. return code :134, reasonBad user name or password Disconnect to Mqtt Broker. topic: Topic_SmokeValue_42207708 Failed to connect. return code :134, reasonBad user name or password Disconnect to Mqtt Broker. topic: Topic_SmokeValue_42207708 Failed to connect. return code :134, reasonBad user name or password Disconnect to Mqtt Broker. topic: Topic_SmokeValue_42207708 Failed to connect. return code :134, reasonBad user name or password Disconnect to Mqtt Broker. topic: Topic_SmokeValue_42207708 Failed to connect. return code :134, reasonBad user name or password Disconnect to Mqtt Broker. topic: Topic_SmokeValue_42207708 Failed to connect. return code :134, reasonBad user name or password Disconnect to Mqtt Broker. topic: Topic_SmokeValue_42207708 Failed to connect. return code :134, reasonBad user name or password Disconnect to Mqtt Broker. topic: Topic_SmokeValue_42207708 Failed to connect. return code :134, reasonBad user name or password Disconnect to Mqtt Broker. topic: Topic_SmokeValue_42207708 Exception ignored in: <module 'threading' from 'F:\\python3.11\\Lib\\threading.py'> Traceback (most recent call last): File "F:\python3.11\Lib\threading.py", line 1629, in _shutdown lock.acquire() KeyboardInterrupt: Process finished with exit code 0
最新发布
06-24
### MQTT 连接失败返回代码 134 的解决方案及线程异常处理 在 Python 中,当使用 MQTT 协议进行通信时,如果连接失败并返回错误代码 `134`,通常表示用户名或密码错误。以下是一个完整的解决方案,包括如何处理此问题以及如何优雅地管理线程以应对异常退出。 #### 错误代码分析 错误代码 `134` 对应于 `Bad user name or password`,表明客户端提供的认证信息无效[^1]。需要确保用户名和密码正确无误,并且服务器端已启用认证功能。 #### MQTT 客户端配置与连接示例 以下是基于 `paho-mqtt` 库的 MQTT 客户端配置与连接代码示例: ```python import paho.mqtt.client as mqtt import threading import signal import sys # 全局事件对象用于线程间通信 exit_event = threading.Event() def on_connect(client, userdata, flags, rc): if rc == 0: print("Connected to MQTT Broker!") else: print(f"Failed to connect, return code {rc}") def mqtt_thread(): try: client = mqtt.Client() client.username_pw_set(username="your_username", password="your_password") client.on_connect = on_connect print("Attempting to connect to MQTT Broker...") client.connect("broker_address", 1883, 60) client.loop_start() while not exit_event.is_set(): time.sleep(1) print("Exiting MQTT thread gracefully...") client.disconnect() client.loop_stop() except Exception as e: print(f"An error occurred in the MQTT thread: {e}", file=sys.stderr) finally: print("MQTT thread has terminated.") def signal_handler(signum, frame): print("\nCtrl-C detected. Initiating graceful shutdown...") exit_event.set() # 注册信号处理器 signal.signal(signal.SIGINT, signal_handler) # 创建并启动 MQTT 线程 mqtt_th = threading.Thread(target=mqtt_thread) mqtt_th.start() try: while not exit_event.is_set(): if not mqtt_th.is_alive(): break time.sleep(0.5) # 避免忙等待 except KeyboardInterrupt: print("Main thread caught KeyboardInterrupt. Setting exit event...", file=sys.stderr) exit_event.set() if mqtt_th.is_alive(): print("Waiting for MQTT thread to terminate...") mqtt_th.join(timeout=5) # 设置超时时间以防止阻塞 if mqtt_th.is_alive(): print("MQTT thread did not terminate gracefully within timeout.", file=sys.stderr) print("Program exited gracefully.") ``` #### 代码解析 - 使用 `paho-mqtt` 库实现 MQTT 客户端功能[^2]。 - 在 `on_connect` 回调函数中检查连接状态,若返回代码非 `0`,则输出错误信息。 - 使用 `threading.Event` 对象作为线程间的通信机制,允许主线程通过设置事件标志通知子线程退出[^3]。 - 通过 `signal.signal` 注册信号处理器,捕获 `SIGINT`(由 `Ctrl+C` 触发)并设置退出事件[^4]。 - 子线程定期检查事件状态,确保能够响应主线程发出的退出信号[^1]。 - 主线程在等待子线程退出时避免忙等待,通过适当的时间间隔调用 `time.sleep` 减少 CPU 占用[^3]。 - 在子线程未及时退出的情况下,设置超时时间以防止主线程无限期阻塞[^3]。 #### 异常处理与线程管理 - 捕获 `KeyboardInterrupt` 并通过 `exit_event` 设置标志位,确保所有线程能够优雅退出[^5]。 - 在 `finally` 块中释放资源(如断开 MQTT 连接),保证程序终止时不会留下未清理的资源[^6]。 --- ###
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值