gpt4 book ai didi

ejb - Weblogic 找不到用于绑定(bind)的 JNDI 名称为 "correct"的资源适配器

转载 作者:行者123 更新时间:2023-12-03 17:56:53 24 4
gpt4 key购买 nike

我正在尝试将我的消息驱动 bean 与 Weblogic 10.3.5 上的 Oracle JCA 文件适配器(包含在 SOA 套件中)绑定(bind)。这样当有任何 .txt 文件移动到特定目录时,我的 MDB 可以得到通知。

启动支持 SOA 功能的 Weblogic 域后,将自动部署文件适配器。在 Weblogic 控制台上我可以看到文件适配器被部署为“资源适配器”,运行状况为“OK”,状态为“Active”,如下图所示:

Deployed File Adapter in Weblogic

我还运行了文件适配器的测试,它们都通过了:

enter image description here

所以我认为文件适配器已正确部署并且应该可以正常工作。

然后我的消息驱动 bean 代码如下所示:

import java.util.logging.Logger;
import javax.ejb.MessageDriven;
import javax.resource.ResourceException;
import javax.resource.cci.MessageListener;
import javax.resource.cci.Record;

@MessageDriven
public class FileAdapterClientMDB implements MessageListener {

private Logger logger = Logger.getLogger(FileAdapterClientMDB.class.getName());

public FileAdapterClientMDB() {

}

@Override
public Record onMessage(Record record) throws ResourceException {
logger.info("Received record: " + record);
return record;
}
}

这是我的 的内容ejb-jar.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" version="3.0">
<display-name>MockEJB</display-name>
<enterprise-beans>
<message-driven>
<description>EMessage Driven Bean as File Adapter Client</description>
<display-name>FileAdapterClientMDB</display-name>
<ejb-name>FileAdapterClientMDB</ejb-name>
<ejb-class>com.test.FileAdapterClientMDB</ejb-class>
<messaging-type>javax.resource.cci.MessageListener</messaging-type>
<transaction-type>Container</transaction-type>
<activation-config>
<activation-config-property>
<activation-config-property-name>physicalDirectory</activation-config-property-name>
<activation-config-property-value>C:\dataDir</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>deleteFile</activation-config-property-name>
<activation-config-property-value>true</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>pollingFrequency</activation-config-property-name>
<activation-config-property-value>10</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>includeFiles</activation-config-property-name>
<activation-config-property-value>.*\.txt</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>minimumAge</activation-config-property-name>
<activation-config-property-value>0</activation-config-property-value>
</activation-config-property>
</activation-config>
</message-driven>
</enterprise-beans>
</ejb-jar>

还有我的 weblogic-ejb-jar.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-ejb-jar xmlns:wls="http://www.bea.com/ns/weblogic/weblogic-ejb-jar" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd http://www.bea.com/ns/weblogic/weblogic-ejb-jar http://www.bea.com/ns/weblogic/weblogic-ejb-jar/1.0/weblogic-ejb-jar.xsd">
<!--weblogic-version:10.3-->
<wls:weblogic-enterprise-bean>
<!--options:RESOURCE_ADAPTER_JNDI-->
<wls:ejb-name>FileAdapterClientMDB</wls:ejb-name>
<wls:message-driven-descriptor>
<wls:resource-adapter-jndi-name>eis/FileAdapter</wls:resource-adapter-jndi-name>
</wls:message-driven-descriptor>
<wls:jndi-name>FileAdapterClientMDB</wls:jndi-name>
<wls:local-jndi-name>FileAdapterClientMDB</wls:local-jndi-name>
</wls:weblogic-enterprise-bean>
</wls:weblogic-ejb-jar>

在部署 EAR 项目时,我收到以下消息:
<20.4.2012 22:42:11 CEST> <Warning> <EJB> <BEA-010221> <The Message-Driven EJB: 
FileAdapterClientMDB is unable to bind to the JCA resource adapter: eis/FileAdapter.
The Error was: No deployed ResourceAdapter with adapter JNDI name = 'eis/FileAdapter' was found.>

我不知道为什么 Weblogic 会提示这个,因为官方 user guide of the adapter 中提到了“eis/FileAdapter”JNDI 名称。 .我也可以在 Weblogic 的 JNDI 树中看到它:

enter image description here

更重要的是,当我在测试 Web 服务中运行以下代码时:
try {
final Context context = new InitialContext();
final Object obj = context.lookup("eis/FileAdapter");
System.out.println("eis/FileAdapter => " + obj);
} catch (NamingException e) {
e.printStackTrace();
}

它打印出“ eis/FileAdapter => oracle.tip.adapter.file.FileConnectionFactory@ff51dc ”,这意味着 JNDI 名称是正确的!

所以我的问题是, 为什么 Weblogic 找不到用于绑定(bind)的“正确”JNDI 名称的资源适配器? 有人可以给我一些关于如何解决它的想法吗?

最佳答案

只要您没有看到此警告重复出现,您就无需担心。它只是显示在部署 MDB 时的部署顺序中,它无法获取适配器。请注意,MDB 每 5 秒尝试连接一次,因此如果警告继续填满日志,则意味着 MDB 无法获取适配器,这意味着它无法正常工作,如果您只看到警告一次,您可以安全地忽略它或更改部署顺序并稍后推送 MDB。

关于ejb - Weblogic 找不到用于绑定(bind)的 JNDI 名称为 "correct"的资源适配器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10253774/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com