0

我正在尝试在 Weblogic 10.3 中使用 WorkManagers。我在 weblogic-ejb-jar.xml 中定义了工作管理器。我在 ejb-jar.xml 中声明了 commonj.work.WorkManager 的资源引用,其 res-ref-name 与 weblogic-ejb-jar.xml 中定义的 Work manager 相同。我在这里发布代码

多边开发银行

package test;

import javax.annotation.Resource;
import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;
import javax.jms.TextMessage;

import commonj.work.WorkManager;


@MessageDriven(mappedName="TEST_Q", name="MDBWithWorkManager",  activationConfig = {
@javax.ejb.ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue  = "Auto-acknowledge"),
@javax.ejb.ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@javax.ejb.ActivationConfigProperty(propertyName = "transactionType", propertyValue = "Container")
 })
    public class MDBWithWorkManager implements MessageListener {

    @Resource(mappedName="TestWorkManager")
    private WorkManager workManager;
    @Override
    public void onMessage(Message arg0) {
      System.out.println("onMessage() called ");
      System.out.println("workManager : "+workManager);
      if(arg0 instanceof TextMessage){
      TextMessage msg= (TextMessage)arg0;
      try {
        System.out.println("Message received-->"+msg.getText());
      } catch (JMSException e) {    
     e.printStackTrace();
  }
 }


}

    }

ejb-jar.xml

<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                    http://java.sun.com/xml/ns/j2ee/ejb-jar_3_0.xsd"
 version="3.0">
 <enterprise-beans>
   <message-driven>
    <ejb-name>MDBWithWorkManager</ejb-name>
    <ejb-class>test.MDBWithWorkManager
    </ejb-class>   
    <resource-ref>
     <description>Test work manager</description>
     <res-ref-name>TestWorkManager</res-ref-name>
     <res-type>commonj.work.WorkManager</res-type>
    <res-auth>Container</res-auth>
   </resource-ref>
   </message-driven>
   </enterprise-beans>
  </ejb-jar>

weblogic-ejb-jar.xml

<?xml version = '1.0'?>
<weblogic-ejb-jar xmlns="http://www.bea.com/ns/weblogic/weblogic-ejb-jar"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-ejb-jar.xsd">
<weblogic-enterprise-bean>
  <ejb-name>MDBWithWorkManager</ejb-name>  
</weblogic-enterprise-bean>
<work-manager>
  <name>TestWorkManager</name>
  <fair-share-request-class>
<name>TestWorkShare</name>
<fair-share>70</fair-share>
</fair-share-request-class>
<min-threads-constraint>
 <name>TestMinThread</name>
 <count>1</count>
</min-threads-constraint>
<max-threads-constraint>
 <name>TestMaxThread</name>
 <count>8</count>
</max-threads-constraint>
</work-manager>
</weblogic-ejb-jar>

部署时出现以下错误

无法从 MDBWithWorkManager.jar 部署 EJB:MDBWithWorkManager:

[EJB:011026]The EJB container failed while creating the java:/comp/env namespace for  this EJB deployment.
weblogic.deployment.EnvironmentException: [EJB:010176]The resource-env- ref 'test.MDBWithWorkManager/workManager' declared in the ejb-jar.xml descriptor or an
notation has no JNDI name mapped to it. The resource-ref must be mapped to a JNDI name   using the resource-description element of the weblogic-ejb-jar.xml des
criptor or corresponding annotation.
    at weblogic.ejb.container.deployer.EnvironmentBuilder.addResourceEnvReferences (EnvironmentBuilder.java:639)
    at weblogic.ejb.container.deployer.EJBDeployer.setupEnvironmentContext (EJBDeployer.java:247)
    at weblogic.ejb.container.deployer.EJBDeployer.setupEnvironmentFor(EJBDeployer.java:1014)
    at weblogic.ejb.container.deployer.EJBDeployer.setupBeanInfos(EJBDeployer.java:908)
    at weblogic.ejb.container.deployer.EJBDeployer.prepare(EJBDeployer.java:1188)
    at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:425)
    at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)
    at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:387)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
    at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:58)
    at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:42)
    at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:615)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
    at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:191)
    at weblogic.application.internal.SingleModuleDeployment.prepare(SingleModuleDeployment.java:16)
    at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:155)
    at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:197)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:89)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:723)
    at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1190)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:248)
    at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:157)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:12)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:45)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

任何人都可以帮忙。

提前致谢!!!!

4

2 回答 2

0

believe what you need is to define a "map"-element called <dispatch-policy> within your bean def - like:

    <weblogic-enterprise-bean>
  <ejb-name>MDBWithWorkManager</ejb-name>  
</weblogic-enterprise-bean>

change it to:

<weblogic-enterprise-bean>
  <ejb-name>MDBWithWorkManager</ejb-name>
  <dispatch-policy>TestWorkManager</dispatch-policy>  
</weblogic-enterprise-bean>
于 2013-11-19T15:40:39.653 回答
0

尝试在 weblogic-ejb-jar.xml 中为 MDBWithWorkManager 添加 res-ref 到实际的 jndi 名称映射

像这样的东西,

    <resource-description>
        <res-ref-name>TestWorkManager</res-ref-name>
        <jndi-name>jndiNameOfTestWorkManager</jndi-name>
    </resource-description>
于 2010-04-13T13:25:34.400 回答