0

Weblogic 10.3 で WorkManagers を使用しようとしています。weblogic-ejb-jar.xml でワーク マネージャを定義しました。weblogic-ejb-jar.xml で定義されているワーク マネージャと同じ res-ref-name を使用して、ejb-jar.xml で commonj.work.WorkManager のリソース参照を宣言しました。ここにコードを投稿しています

MDB

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>

デプロイ中に次のエラーが発生する

EJB をデプロイできません: MDBWithWorkManager.jar からの 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

<dispatch-policy>必要なのは、Bean 定義内で呼び出される「マップ」要素を定義することだと信じています-次のように:

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

次のように変更します。

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

MDBWithWorkManager の weblogic-ejb-jar.xml の実際の jndi 名マッピングに res-ref を追加してみてください。

このようなもの、

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