0
私はJMSの基本的な例を持っています: これはメッセージを送信するクラスです。 wildfly 10を使用します。STSに追加しました。JMS Wildfly 10 - javax.naming.NameNotFoundException
package com.configuration;
import java.util.Properties;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSContext;
import javax.naming.*;
public class Config {
private static final String CONNECTION_FACTORY = "jms/ConnectionFactory";
private static final String QUEUE_DESTINATION = "jms/testQueue";
private static final String INITIAL_CONTEXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";
private static final String PROVIDER_URL = "http-remoting://localhost:8080";
public static void main (String[] args) throws NamingException{
Context namingContext = null;
JMSContext context = null;
namingContext = getInitialContext();
ConnectionFactory connectionFactory = (ConnectionFactory)namingContext.lookup(CONNECTION_FACTORY);
Destination destination = (Destination) namingContext.lookup(QUEUE_DESTINATION);
context = connectionFactory.createContext("viruskimera", "pmhjpmhj1");
System.out.println("ENTERING JMS --- ");
context.createProducer().send(destination, "Hello message!!!");
System.out.println("MESSAGE SENT --- ");
System.out.println("EXITING JMS --- ");
}
public static Context getInitialContext() throws NamingException{
Context namingContext = null;
Properties props = new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY ,INITIAL_CONTEXT_FACTORY);
props.setProperty(Context.PROVIDER_URL, PROVIDER_URL);
props.setProperty(Context.SECURITY_PRINCIPAL, "user");
props.setProperty(Context.SECURITY_CREDENTIALS, "password");
props.put("jboss.naming.client.ejb.context", true);
namingContext = new InitialContext(props);
return namingContext;
}
}
これは私のスタックトレースです:私が試してみました は問題がある場合は必ずCONNECTION_FACTORYを変えなく。 btwスタンドアローンをフルバージョンに変更しました。
may 08, 2017 6:30:30 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.4.0.Final
may 08, 2017 6:30:30 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.4.0.Final
may 08, 2017 6:30:30 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 4.0.21.Final
may 08, 2017 6:30:30 PM org.jboss.ejb.client.remoting.VersionReceiver handleMessage
INFO: EJBCLIENT000017: Received server version 2 and marshalling strategies [river]
may 08, 2017 6:30:30 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
INFO: EJBCLIENT000013: Successful version handshake completed for receiver context EJBReceiverContext{[email protected], receiver=Remoting connection EJB receiver [connection=Remoting connection <6ad87bb3> on endpoint "config-based-naming-client-endpoint" <3108bc>,channel=jboss.ejb,nodename=viruskimera]} on channel Channel ID a2c74fcc (outbound) of Remoting connection 3701eaf6 to localhost/127.0.0.1:8080 of endpoint "config-based-naming-client-endpoint" <3108bc>
Exception in thread "main" javax.naming.NameNotFoundException: jms/ConnectionFactory -- service jboss.naming.context.java.jboss.exported.jms.ConnectionFactory
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:106)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:184)
at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:127)
at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:73)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
私は何か不足しているように見えますが、私はあなたの助けに感謝します。