Hi!
I am trying to use WorkManagers in Weblogic 10.3. I have defined work managers in weblogic-ejb-jar.xml. I declared a resource reference for commonj.work.WorkManager in ejb-jar.xml with the res-ref-name same as the Work manager defined in weblogic-ejb-jar.xml. Here I am posting the code
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>
Getting the following error while deploying
Unable to deploy EJB: MDBWithWorkManager from MDBWithWorkManager.jar:
[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)
Can any one please help out.
Thanks in Advance!!!!