Добрый день пытаюсб подружить GF и Websphere MQ.
В Glassfish развернул адаптер wmq.jmsra.rar создал Connector connection pool,Connector resource и admin object resource . В domain.xml получилось следующее:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
<admin-object-resource>
<resource-adapter-config thread-pool-ids="" resource-adapter-name="wmq.jmsra">
<property name="timestampsEnabled" value="true"></property>
<property name="maxConnections" value="10"></property>
<property name="traceLevel" value="3"></property>
<property name="reconnectionRetryCount" value="5"></property>
<property name="logWriterEnabled" value="true"></property>
<property name="connectionConcurrency" value="5"></property>
<property name="traceEnabled" value="false"></property>
<property name="reconnectionRetryInterval" value="300000"></property>
<property name="traceDestination" value="wmq_jms.trc"></property>
</resource-adapter-config>
<connector-connection-pool name="wmqCF" resource-adapter-name="wmq.jmsra" connection-definition-name="javax.jms.QueueConnectionFactory" transaction-support="LocalTransaction">
<property name="port" value="2414"></property>
<property name="CCSID" value="866"></property>
<property name="username" value="testuser"></property>
<property name="hostName" value="190.XXX.XXX.XX"></property>
<property name="queueManager" value="QM_DO"></property>
<property name="channel" value="SrvConnDO"></property>
<property name="transportType" value="CLIENT"></property>
</connector-connection-pool>
<admin-object-resource enabled="true" res-adapter="wmq.jmsra" res-type="javax.jms.Queue" jndi-name="wmqQueue" class-name="com.ibm.mq.connector.outbound.MQQueueProxy">
<property name="priority" value="APP"></property>
<property name="failIfQuiesce" value="true"></property>
<property name="baseQueueManagerName" value="QM_DO"></property>
<property name="CCSID" value="1208"></property>
<property name="persistence" value="APP"></property>
<property name="encoding" value="NATIVE"></property>
<property name="baseQueueName" value="DO"></property>
<property name="targetClient" value="MQ"></property>
<property name="expiry" value="APP"></property>
</admin-object-resource>
Ping в Connector Connection factory есть.
С помощью NetBeans (7.1) создал J2EE приложение, в нем message bean и сервлет.
В WEB-INF имею glassfish-web.xml с таким содержимым:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app error-url="">
<resource-ref>
<res-ref-name>wmqCF</res-ref-name>
<jndi-name>wmqCF</jndi-name>
</resource-ref>
<message-destination-ref>
<message-destination-ref-name>wmqQueue</message-destination-ref-name>
<jndi-name>wmqQueue</jndi-name>
</message-destination-ref>
<class-loader delegate="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java code.</description>
</property>
</jsp-config>
</glassfish-web-app>
В сервлете пытаюсь положить сообщение в очередь:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
public class NewServlet extends HttpServlet {
@Resource(mappedName = "wmqQueue")
private Queue wmqQueue;
@Resource(mappedName = "wmqCF")
private ConnectionFactory wmqCF;
......
private void sendJMSMessageToWmqQueue(Object messageData) throws JMSException {
Connection connection = null;
Session session = null;
try {
connection = wmqCF.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer messageProducer = session.createProducer(wmqQueue);
messageProducer.send(createJMSMessageForwmqQueue(session, messageData));
}catch(Exception e){
Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Cannot create session/connection", e);
} finally {
if (session != null) {
try {
session.close();
} catch (JMSException e) {
Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Cannot close session", e);
}
}
if (connection != null) {
connection.close();
}
}
}
Вроде все хорошо, но при запуске сервера выскакивают:
WARNING: This web app [/D:/PROJECTS/SandBox/MDB/MyMDB_wmqtest/MyMDB_wmqtest/MyMDB_wmqtest-war/build/web/] has no resource reference by the name of [wmqCF]
WARNING: This web app [/D:/PROJECTS/SandBox/MDB/MyMDB_wmqtest/MyMDB_wmqtest/MyMDB_wmqtest-war/build/web/] has no message destination reference by the name of [wmqQueue]
WARNING: DPL8007: Unsupported deployment descriptors element jndi-name value wmqQueue
При выполнении сервлета получаю:
авторCaused by: com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Res-Ref-Env-Property: com.web.NewServlet/
wmqCF@javax.jms.ConnectionFactory@ resolved as: jndi:
wmqCF@res principal:
null@mail: null
N
Добавляю в domain.xml секцию
1.
<connector-resource pool-name="wmqCF" description="connector resource because else javax.naming.NamingException: Lookup failed for 'wmqCF'" jndi-name="wmqCF"></connector-resource>
получаю:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class com.web.NewServlet
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:315)
at com.sun.enterprise.web.WebContainer.createServletInstance(WebContainer.java:717)
at com.sun.enterprise.web.WebModule.createServletInstance(WebModule.java:1959)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1263)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:1070)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:189)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:232)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:619)
Caused by: com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Unresolved Message-Destination-Ref com.web.NewServlet/wmqQueue@java.lang.String@null into class com.web.NewServlet: Lookup failed for 'java:comp/env/com.web.NewServlet/wmqQueue' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:703)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:470)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:142)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:128)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:310)
... 28 more
Caused by: javax.naming.NamingException: Lookup failed for 'java:comp/env/com.web.NewServlet/wmqQueue' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Lookup failed for 'wmqQueue' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming, com.sun.enterprise.naming.logicalName=java:comp/env/com.web.NewServlet/wmqQueue} [Root exception is javax.naming.NameNotFoundException: wmqQueue not found]]
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:599)
... 32 more
Caused by: javax.naming.NamingException: Lookup failed for 'wmqQueue' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming, com.sun.enterprise.naming.logicalName=java:comp/env/com.web.NewServlet/wmqQueue} [Root exception is javax.naming.NameNotFoundException: wmqQueue not found]
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.sun.enterprise.naming.util.JndiNamingObjectFactory.create(JndiNamingObjectFactory.java:82)
at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:776)
at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:744)
at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:172)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:498)
... 36 more
Caused by: javax.naming.NameNotFoundException: wmqQueue not found
at com.sun.enterprise.naming.impl.TransientContext.doLookup(TransientContext.java:248)
at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:215)
at com.sun.enterprise.naming.impl.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:77)
at com.sun.enterprise.naming.impl.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:119)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:505)
... 44 more
Подскажите где еще нужно прописать wmqCF и wmqQueue.
С Уважением, Алексей.