[JBoss Web Services] - NullPointerException in JBossXSEntityResolver.getXMLInputSource still happening in 5.1.0
by Andre Zelenkovas
Andre Zelenkovas [http://community.jboss.org/people/jbonham100] created the discussion
"NullPointerException in JBossXSEntityResolver.getXMLInputSource still happening in 5.1.0"
To view the discussion, visit: http://community.jboss.org/message/551814#551814
--------------------------------------------------------------
Hi
I thought this was a fixed problem in JBoss 5.1.0, but I still got this when trying to consume a SOAP service provided by a .NET server. The exception occurs in the client service constructor. I used wsconsume to create the stub. I noticed the WSDL has a <s:import/> clause, but I removed that and still got the problem.
Any ideas would be greatly appreciated.
Here is the exception.
java.lang.NullPointerException
at org.jboss.ws.metadata.wsdl.xmlschema.JBossXSEntityResolver.getXMLInputSource(JBossXSEntityResolver.java:170)
at org.jboss.ws.metadata.wsdl.xmlschema.JBossXSEntityResolver.resolveEntity(JBossXSEntityResolver.java:136)
at org.apache.xerces.impl.XMLEntityManager.resolveEntity(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.resolveDocument(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.resolveSchema(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.constructTrees(Unknown Source)
at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
at org.jboss.ws.tools.JavaToXSD.parseSchema(JavaToXSD.java:181)
at org.jboss.ws.tools.wsdl.WSDL11Reader.processTypes(WSDL11Reader.java:451)
at org.jboss.ws.tools.wsdl.WSDL11Reader.processDefinition(WSDL11Reader.java:180)
at org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory.parse(WSDLDefinitionsFactory.java:129)
at org.jboss.ws.metadata.umdm.ServiceMetaData.getWsdlDefinitions(ServiceMetaData.java:293)
at org.jboss.ws.metadata.builder.jaxws.JAXWSClientMetaDataBuilder.buildMetaData(JAXWSClientMetaDataBuilder.java:84)
at org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.<init>(ServiceDelegateImpl.java:138)
at org.jboss.ws.core.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:63)
at javax.xml.ws.Service.<init>(Service.java:79)
at com.navteq.atg.lpup.targeting.cms.ws.client.Nmap.<init>(Nmap.java:41)
at com.navteq.atg.lpup.targeting.cms.ws.client.CMSDataServiceClient.obtainServicePort(CMSDataServiceClient.java:73)
at com.navteq.atg.lpup.targeting.cms.ws.client.CMSDataServiceClient.fetchConfigurationFromCMS(CMSDataServiceClient.java:24)
at com.navteq.atg.lpup.targeting.cache.ws.CacheRefreshService.refreshConfiguration(CacheRefreshService.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.wsf.container.jboss50.invocation.InvocationHandlerJSE.invoke(InvocationHandlerJSE.java:108)
at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:222)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:474)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:295)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:205)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:131)
at org.jboss.wsf.common.servlet.AbstractEndpointServlet.service(AbstractEndpointServlet.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Here is the WSDL:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:s=" http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema" xmlns:soap12=" http://schemas.xmlsoap.org/wsdl/soap12/ http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:mime=" http://schemas.xmlsoap.org/wsdl/mime/ http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns=" http://navteq.com/ http://navteq.com/" xmlns:soap=" http://schemas.xmlsoap.org/wsdl/soap/ http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm=" http://microsoft.com/wsdl/mime/textMatching/ http://microsoft.com/wsdl/mime/textMatching/" xmlns:http=" http://schemas.xmlsoap.org/wsdl/http/ http://schemas.xmlsoap.org/wsdl/http/" xmlns:soapenc=" http://schemas.xmlsoap.org/soap/encoding/ http://schemas.xmlsoap.org/soap/encoding/" targetNamespace=" http://navteq.com/ http://navteq.com/" xmlns:wsdl=" http://schemas.xmlsoap.org/wsdl/ http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace=" http://navteq.com/ http://navteq.com/">
<s:import />
<s:element name="GetNmapTargetingXml">
<s:complexType />
</s:element>
<s:element name="GetNmapTargetingXmlResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" ref="GetNmapTargetingXmlResult" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetAdvertisementNmapTargetingXmlMapping">
<s:complexType />
</s:element>
<s:element name="GetAdvertisementNmapTargetingXmlMappingResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" ref="GetAdvertisementNmapTargetingXmlMappingResult" />
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
<s:schema elementFormDefault="qualified">
<s:element name="GetNmapTargetingXmlResult">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="element">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="allowedValue">
<s:complexType>
<s:attribute name="description" type="s:string" />
<s:attribute name="value" type="s:string" />
</s:complexType>
</s:element>
</s:sequence>
<s:attribute name="description" type="s:string" />
<s:attribute name="name" type="s:string" />
<s:attribute default="true" name="allowManyValuesInQuery" type="s:boolean" />
<s:attribute default="false" name="allowManyValuesInRequest" type="s:boolean" />
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetAdvertisementNmapTargetingXmlMappingResult">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="advertisement">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" form="unqualified" name="id" type="s:long" />
<s:element minOccurs="0" maxOccurs="1" name="targetProfileList" type="ArrayOfTargetProfile" />
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ArrayOfTargetProfile">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="targetProfile">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" form="unqualified" name="required" type="s:boolean" />
<s:element minOccurs="0" maxOccurs="1" form="unqualified" name="name" type="s:string" />
<s:element minOccurs="0" maxOccurs="unbounded" form="unqualified" name="value" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
<s:element name="targeting">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="element">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="allowedValue">
<s:complexType>
<s:attribute name="description" type="s:string" />
<s:attribute name="value" type="s:string" />
</s:complexType>
</s:element>
</s:sequence>
<s:attribute name="description" type="s:string" />
<s:attribute name="name" type="s:string" />
<s:attribute default="true" name="allowManyValuesInQuery" type="s:boolean" />
<s:attribute default="false" name="allowManyValuesInRequest" type="s:boolean" />
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="advertisementList">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="advertisement">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" form="unqualified" name="id" type="s:long" />
<s:element minOccurs="0" maxOccurs="1" name="targetProfileList" type="ArrayOfTargetProfile" />
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="GetNmapTargetingXmlSoapIn">
<wsdl:part name="parameters" element="tns:GetNmapTargetingXml" />
</wsdl:message>
<wsdl:message name="GetNmapTargetingXmlSoapOut">
<wsdl:part name="parameters" element="tns:GetNmapTargetingXmlResponse" />
</wsdl:message>
<wsdl:message name="GetAdvertisementNmapTargetingXmlMappingSoapIn">
<wsdl:part name="parameters" element="tns:GetAdvertisementNmapTargetingXmlMapping" />
</wsdl:message>
<wsdl:message name="GetAdvertisementNmapTargetingXmlMappingSoapOut">
<wsdl:part name="parameters" element="tns:GetAdvertisementNmapTargetingXmlMappingResponse" />
</wsdl:message>
<wsdl:message name="GetNmapTargetingXmlHttpGetIn" />
<wsdl:message name="GetNmapTargetingXmlHttpGetOut">
<wsdl:part name="Body" element="targeting" />
</wsdl:message>
<wsdl:message name="GetAdvertisementNmapTargetingXmlMappingHttpGetIn" />
<wsdl:message name="GetAdvertisementNmapTargetingXmlMappingHttpGetOut">
<wsdl:part name="Body" element="advertisementList" />
</wsdl:message>
<wsdl:message name="GetNmapTargetingXmlHttpPostIn" />
<wsdl:message name="GetNmapTargetingXmlHttpPostOut">
<wsdl:part name="Body" element="targeting" />
</wsdl:message>
<wsdl:message name="GetAdvertisementNmapTargetingXmlMappingHttpPostIn" />
<wsdl:message name="GetAdvertisementNmapTargetingXmlMappingHttpPostOut">
<wsdl:part name="Body" element="advertisementList" />
</wsdl:message>
<wsdl:portType name="NmapSoap">
<wsdl:operation name="GetNmapTargetingXml">
<wsdl:input message="tns:GetNmapTargetingXmlSoapIn" />
<wsdl:output message="tns:GetNmapTargetingXmlSoapOut" />
</wsdl:operation>
<wsdl:operation name="GetAdvertisementNmapTargetingXmlMapping">
<wsdl:input message="tns:GetAdvertisementNmapTargetingXmlMappingSoapIn" />
<wsdl:output message="tns:GetAdvertisementNmapTargetingXmlMappingSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:portType name="NmapHttpGet">
<wsdl:operation name="GetNmapTargetingXml">
<wsdl:input message="tns:GetNmapTargetingXmlHttpGetIn" />
<wsdl:output message="tns:GetNmapTargetingXmlHttpGetOut" />
</wsdl:operation>
<wsdl:operation name="GetAdvertisementNmapTargetingXmlMapping">
<wsdl:input message="tns:GetAdvertisementNmapTargetingXmlMappingHttpGetIn" />
<wsdl:output message="tns:GetAdvertisementNmapTargetingXmlMappingHttpGetOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:portType name="NmapHttpPost">
<wsdl:operation name="GetNmapTargetingXml">
<wsdl:input message="tns:GetNmapTargetingXmlHttpPostIn" />
<wsdl:output message="tns:GetNmapTargetingXmlHttpPostOut" />
</wsdl:operation>
<wsdl:operation name="GetAdvertisementNmapTargetingXmlMapping">
<wsdl:input message="tns:GetAdvertisementNmapTargetingXmlMappingHttpPostIn" />
<wsdl:output message="tns:GetAdvertisementNmapTargetingXmlMappingHttpPostOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="NmapSoap" type="tns:NmapSoap">
<soap:binding transport=" http://schemas.xmlsoap.org/soap/http http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="GetNmapTargetingXml">
<soap:operation soapAction=" http://navteq.com/GetNmapTargetingXml http://navteq.com/GetNmapTargetingXml" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetAdvertisementNmapTargetingXmlMapping">
<soap:operation soapAction=" http://navteq.com/GetAdvertisementNmapTargetingXmlMapping http://navteq.com/GetAdvertisementNmapTargetingXmlMapping" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="NmapSoap12" type="tns:NmapSoap">
<soap12:binding transport=" http://schemas.xmlsoap.org/soap/http http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="GetNmapTargetingXml">
<soap12:operation soapAction=" http://navteq.com/GetNmapTargetingXml http://navteq.com/GetNmapTargetingXml" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetAdvertisementNmapTargetingXmlMapping">
<soap12:operation soapAction=" http://navteq.com/GetAdvertisementNmapTargetingXmlMapping http://navteq.com/GetAdvertisementNmapTargetingXmlMapping" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="NmapHttpGet" type="tns:NmapHttpGet">
<http:binding verb="GET" />
<wsdl:operation name="GetNmapTargetingXml">
<http:operation location="/GetNmapTargetingXml" />
<wsdl:input>
<http:urlEncoded />
</wsdl:input>
<wsdl:output>
<mime:mimeXml part="Body" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetAdvertisementNmapTargetingXmlMapping">
<http:operation location="/GetAdvertisementNmapTargetingXmlMapping" />
<wsdl:input>
<http:urlEncoded />
</wsdl:input>
<wsdl:output>
<mime:mimeXml part="Body" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="NmapHttpPost" type="tns:NmapHttpPost">
<http:binding verb="POST" />
<wsdl:operation name="GetNmapTargetingXml">
<http:operation location="/GetNmapTargetingXml" />
<wsdl:input>
<mime:content type="application/x-www-form-urlencoded" />
</wsdl:input>
<wsdl:output>
<mime:mimeXml part="Body" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetAdvertisementNmapTargetingXmlMapping">
<http:operation location="/GetAdvertisementNmapTargetingXmlMapping" />
<wsdl:input>
<mime:content type="application/x-www-form-urlencoded" />
</wsdl:input>
<wsdl:output>
<mime:mimeXml part="Body" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Nmap">
<wsdl:port name="NmapSoap" binding="tns:NmapSoap">
<soap:address location=" http://intlbabe4.ilapqa.local/nmapcms/nmap.asmx http://intlbabe4.ilapqa.local/nmapcms/nmap.asmx" />
</wsdl:port>
<wsdl:port name="NmapSoap12" binding="tns:NmapSoap12">
<soap12:address location=" http://intlbabe4.ilapqa.local/nmapcms/nmap.asmx http://intlbabe4.ilapqa.local/nmapcms/nmap.asmx" />
</wsdl:port>
<wsdl:port name="NmapHttpGet" binding="tns:NmapHttpGet">
<http:address location=" http://intlbabe4.ilapqa.local/nmapcms/nmap.asmx http://intlbabe4.ilapqa.local/nmapcms/nmap.asmx" />
</wsdl:port>
<wsdl:port name="NmapHttpPost" binding="tns:NmapHttpPost">
<http:address location=" http://intlbabe4.ilapqa.local/nmapcms/nmap.asmx http://intlbabe4.ilapqa.local/nmapcms/nmap.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Thanks
Andre
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/551814#551814]
Start a new discussion in JBoss Web Services at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years, 11 months
Re: [jboss-user] [Beginner's Corner] - How can I stop a running mdb?
by J Sanz A
J Sanz A [http://community.jboss.org/people/eskuai] replied to the discussion
"How can I stop a running mdb?"
To view the discussion, visit: http://community.jboss.org/message/551809#551809
--------------------------------------------------------------
package paq;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
/**
* Message-Driven Bean implementation class for: EjbMDB
*
*/
@MessageDriven(
activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "/queue/OrderQueue"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")
},
mappedName = "/queue/OrderQueue")
public class EjbMDB implements MessageListener {
/**
* Default constructor.
*/
public EjbMDB() {
// TODO Auto-generated constructor stub
}
/**
* @see MessageListener#onMessage(Message)
*/
public void onMessage(Message message) {
System.out.println("----------------");
System.out.println("Received message");
System.out.println(message);
TextMessage tm = (TextMessage) message;
try {
System.out.println(tm.getText());
} catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("----------------");
}
}
/*------------------------------------------------------*/
package paq;
import javax.ejb.Remote;
@Remote
public interface SessionEJBRemote {
public void stopMDB();
public void starMDB();
}
/*-----------------------------*/
package paq;
import javax.ejb.Stateless;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import org.jboss.ejb3.mdb.MessagingDelegateWrapperMBean;
import org.jboss.mx.util.MBeanProxy;
import org.jboss.mx.util.MBeanProxyCreationException;
import org.jboss.mx.util.MBeanServerLocator;
/**
* Session Bean implementation class SessionEJB
*/
@Stateless
public class SessionEJB implements SessionEJBRemote {
/**
* Default constructor.
*/
public SessionEJB() {
// TODO Auto-generated constructor stub
}
public void stopMDB() {
String mbean = "jboss.j2ee:jar=StopMDB.jar,name=EjbMDB,service=EJB3";
MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
MessagingDelegateWrapperMBean invoker;
try {
invoker = (MessagingDelegateWrapperMBean)
MBeanProxy.get(MessagingDelegateWrapperMBean.class, new ObjectName(mbean), mbeanServer);
invoker.stopDelivery();
} catch (MalformedObjectNameException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MBeanProxyCreationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NullPointerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void starMDB() {
String mbean = "jboss.j2ee:jar=StopMDB.jar,name=EjbMDB,service=EJB3";
MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
MessagingDelegateWrapperMBean invoker;
try {
invoker = (MessagingDelegateWrapperMBean)
MBeanProxy.get(MessagingDelegateWrapperMBean.class, new ObjectName(mbean), mbeanServer);
invoker.startDelivery();
} catch (MalformedObjectNameException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MBeanProxyCreationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NullPointerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/*----------------------------------*/
package paq;
import java.util.Properties;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class ClientMDB {
public static void main(String [] args) {
//ClientMDB.sendMessage();
//ClientMDB.stopMdb();
ClientMDB.startMdb();
}
public static void stopMdb() {
ServiceLocator.getSessionEJBRemote().stopMDB();
}
public static void startMdb() {
ServiceLocator.getSessionEJBRemote().starMDB();
}
public static void sendMessage() {
try {
ConnectionFactory connectionFactory = null;
Connection connection = null;
Session session = null;
Destination destination = null;
MessageProducer messageProducer = null;
TextMessage message = null;
connectionFactory = ServiceLocator.getJmsConnectionFactory("/XAConnectionFactory");
connection = connectionFactory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
destination = ServiceLocator.getJmsDestination("/queue/OrderQueue");
messageProducer = session.createProducer(destination);
message = session.createTextMessage("HOLA JUAN");
messageProducer.send(message);
System.out.println("Message sent to messageProducer");
messageProducer.close();
session.close();
connection.close();
} catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/*-----------------------------------*/
package paq;
import java.util.Hashtable;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class ServiceLocator {
private static Hashtable<String, String> props = new Hashtable<String, String>();
static {
props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
props.put("java.naming.provider.url", "localhost:1099");
}
private ServiceLocator() {}
public static ConnectionFactory getJmsConnectionFactory(String jmsConnectionFactoryJndiName)
throws Exception {
ConnectionFactory jmsConnectionFactory = null;
try {
Context ctx = new InitialContext(props);
jmsConnectionFactory = (ConnectionFactory) ctx.lookup(jmsConnectionFactoryJndiName);
} catch (ClassCastException cce) {
throw new Exception(cce);
} catch (NamingException ne) {
throw new Exception(ne);
}
return jmsConnectionFactory;
}
public static Destination getJmsDestination(String jmsDestinationJndiName)
throws Exception {
Destination jmsDestination = null;
try {
Context ctx = new InitialContext(props);
jmsDestination = (Destination) ctx.lookup(jmsDestinationJndiName);
} catch (ClassCastException cce) {
throw new Exception(cce);
} catch (NamingException ne) {
throw new Exception(ne);
}
return jmsDestination;
}
public static SessionEJBRemote getSessionEJBRemote() {
Context context;
SessionEJBRemote remote = null;
try {
context = new InitialContext(props);
remote = (SessionEJBRemote)context.lookup("SessionEJB/remote");
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return remote;
}
}
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/551809#551809]
Start a new discussion in Beginner's Corner at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years, 11 months