Weblogic could not find resource adapter with “correct” JNDI name for binding

十年热恋 提交于 2019-12-06 03:11:08

问题


I am trying to bind my message driven bean with Oracle JCA file adapter (which is included in the SOA suite) on Weblogic 10.3.5. So that my MDB can get notified when there is any .txt file is moved to specific directory.

After launching a Weblogic domain with SOA features supported, the file adapter is automatically deployed. On Weblogic console I can see the file adapter is deployed as a "Resource Adapter", health is "OK", state is "Active", as shown below:

Also I run the tests of the file adapter, and they all passed:

So I think the file adapter is correctly deployed and should be functional.

Then my message driven bean code looks like this:

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;
    }
}

Here are the content of my ejb-jar.xml file:

<?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>

And my weblogic-ejb-jar.xml file:

<?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>

While deploying the EAR project, I got this message:

<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.>

I have no idea why Weblogic complain this, since the "eis/FileAdapter" JNDI name is mentioned in the official user guide of the adapter. Also I can see it in Weblogic's JNDI tree:

What's more, when I run the code below in my testing web service:

try {
    final Context context = new InitialContext();
    final Object obj = context.lookup("eis/FileAdapter");
    System.out.println("eis/FileAdapter => " + obj);
} catch (NamingException e) {
    e.printStackTrace();
}

It prints out "eis/FileAdapter => oracle.tip.adapter.file.FileConnectionFactory@ff51dc", which means the JNDI name is correct!

So my question is, why Weblogic could not find resource adapter with a "correct" JNDI name for binding? Could someone give me some ideas on how to solve it?


回答1:


as long as you don't see this warning repeating you have nothing to worry. It just shows that in the order of deployment when the MDB was getting deployed it could not get the adapter. Note an MDB keeps trying to connect every 5 secs so if the warning continues to fill the log then that means the MDB has not been able to get the adapter meaning its not working, if you saw the warning only once you can safely ignore it or change the order of deployment and push the MDB little later.



来源:https://stackoverflow.com/questions/10253774/weblogic-could-not-find-resource-adapter-with-correct-jndi-name-for-binding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!