2016-05-23 13 views
0

私はEJBのMessage Driven Beanの例について取り組んでいます。 weblogic serverにデプロイされたEJBプロジェクトとJNDI名でMDBにメッセージを送るClientプロジェクトを作成しました。私はまた、weblogicコンソールにJMS QueueとQueue ConnectionFactoryを作成しました。WeblogicのQueueとQueueConnectionFactoryのJNDI名を解決できません

しかし、問題はクライアント側ではキューのJNDI名を識別できません。

Weblogic Console

EJBプロジェクト

@MessageDriven(activationConfig = { 
    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), 
    @ActivationConfigProperty(propertyName = "destination", propertyValue = "jms/weblogic.wsee.DefaultQueue") 
    }, 
    mappedName = "mdb") 
public class QueueListenerMDB implements IQueueListenerMDB{ 
public QueueListenerMDB() { 
} 

public void onMessage(Message message) { 
    try { 
     if (message instanceof TextMessage) { 
      System.out.println("Queue: I received a TextMessage at " 
        + new Date()); 
      TextMessage msg = (TextMessage) message; 
      System.out.println("Message is : " + msg.getText()); 
     } else if (message instanceof ObjectMessage) { 
      System.out.println("Queue: I received an ObjectMessage at " 
        + new Date()); 
      ObjectMessage msg = (ObjectMessage) message; 
      Employee employee = (Employee) msg.getObject(); 
      System.out.println("Employee Details: "); 
      System.out.println(employee); 
     } else { 
      System.out.println("Not valid message for this Queue MDB"); 
     } 
    } catch (JMSException e) { 
     e.printStackTrace(); 
    } 
} 

}

QueueSenderDemo.java上OueueListenerMDB.javaクライアントプロジェクトの

public class QueueSenderDemo { 
private static final String PROVIDER_URL = "t3://localhost:7002/"; 

private static final String INITIAL_CONTEXT_FACTORY = "weblogic.jndi.WLInitialContextFactory"; 

private static Context initialContext; 

private static final String QUEUE_LOOKUP = "jms/weblogic.wsee.DefaultQueue"; 
private static final String CONNECTION_FACTORY = "jms/weblogic.jms.ConnectionFactory"; 

public static void main(String[] args) throws NamingException { 
    sendMessageToQueue(); 
} 

public static void sendMessageToQueue() { 
    try { 
     Context context = getInitialContextForClient(); 

     QueueConnectionFactory factory = (QueueConnectionFactory) context.lookup(CONNECTION_FACTORY); 

     QueueConnection connection = factory.createQueueConnection(); 
     QueueSession session = connection.createQueueSession(false, 
       QueueSession.AUTO_ACKNOWLEDGE); 
     Queue queue = (Queue) context.lookup(QUEUE_LOOKUP); 

     QueueSender sender = session.createSender(queue); 
     TextMessage message = session.createTextMessage("Welcome to EJB3 Message Driven Bean."); 
     sender.send(message); 
     session.close(); 
    } catch (NamingException e) { 
     e.printStackTrace(); 
    } catch (JMSException e) { 
     e.printStackTrace(); 
    } 
} 

public static Context getInitialContextForClient() 
     throws NamingException { 
    if (initialContext == null) { 
     Properties prop = new Properties(); 
     prop.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY); 
     prop.put(Context.PROVIDER_URL, PROVIDER_URL); 
     initialContext = new InitialContext(prop); 
    } 
    return initialContext; 
} 
} 

このようなクライアントプログラムを実行中にエラーが表示されます。

javax.naming.NameNotFoundException: While trying to lookup 'jms.weblogic.wsee.DefaultQueue' didn't find subcontext 'wsee'. Resolved 'jms.weblogic' [Root exception is javax.naming.NameNotFoundException: While trying to lookup 'jms.weblogic.wsee.DefaultQueue' didn't find subcontext 'wsee'. Resolved 'jms.weblogic']; remaining name 'wsee/DefaultQueue' 
at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:234) 
at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:348) 
at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259) 
at weblogic.jndi.internal.ServerNamingNode_1035_WLStub.lookup(Unknown Source) 
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:423) 
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:411) 
at javax.naming.InitialContext.lookup(Unknown Source) 
at com.mdbclient.utility.QueueSenderDemo.sendMessageToQueue(QueueSenderDemo.java:36) 
at com.mdbclient.utility.QueueSenderDemo.main(QueueSenderDemo.java:27) 
Caused by: javax.naming.NameNotFoundException: While trying to lookup 'jms.weblogic.wsee.DefaultQueue' didn't find subcontext 'wsee'. Resolved 'jms.weblogic' 
at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139) 
at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:247) 
at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182) 
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206) 
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:214) 
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:214) 
at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source) 
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:667) 
at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230) 
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:522) 
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363) 
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146) 
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:518) 
at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118) 
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209) 
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178) 
at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:252) 
at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182) 
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206) 
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:214) 
at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source) 
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:667) 
at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230) 
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:522) 
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363) 
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146) 
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:518) 
at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118) 
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209) 
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178) 

答えて

0

サブデプロイメント/ターゲティングが正しいサーバーを指していることを確認してください。キューが管理対象サーバー上でホストされている可能性があり、間違った管理対象サーバーまたは管理サーバーでルックアップしようとしています。ターゲティングやjndiツリーを表示できたら、助けが簡単になります。

+0

Miguelさん、ありがとうございました。 –

+0

問題ありません。少し助けてほしかった:)。 – Miguel

関連する問題