[JBoss ESB Development] - Exception handling between actions and ftp-listener
by Phillip Schulte
Phillip Schulte [http://community.jboss.org/people/phillip.schulte] created the discussion
"Exception handling between actions and ftp-listener"
To view the discussion, visit: http://community.jboss.org/message/564097#564097
--------------------------------------------------------------
Hello.
Thats one service in my jboss-esb.xml
<service category="de.eskalon.kn.garuda.invoice.HistoricalExchangeRates" name="HistoricalExchangeRateImporter" description="Imports historical exchange rates from ftp directory files" invmScope="GLOBAL">
<service category="de.eskalon.kn.garuda.invoice.HistoricalExchangeRates" name="HistoricalExchangeRateImporter" description="Imports historical exchange rates from ftp directory files" invmScope="GLOBAL">
<listeners>
<ftp-listener busidref="currency-ftp-in" is-gateway="true" maxThreads="2" name="ftp-listener-gateway" scheduleidref="everyminute" />
</listeners>
<actions mep="OneWay">
<action name="transform" class="org.jboss.soa.esb.actions.converters.ByteArrayToString">
<property name="encoding" value="UTF-8" />
</action>
<action name="properties" class="de.eskalon.kn.garuda.esb.GetPropertiesFromMessage"> </action>
<action class="org.jboss.soa.esb.actions.EJBProcessor" name="callPersist">
<property name="ejb3" value="true" />
<property name="jndi-name" value="garuda-invoicing/HistoricalExchangeRatesManagerBean/remote" />
<property name="initial-context-factory" value="org.jnp.interfaces.NamingContextFactory" />
<property name="provider-url" value="localhost:1099" />
<property name="method" value="persistRate" />
<property name="ejb-params">
<arg0 type="java.lang.String">FILE_NAME</arg0>
<arg1 type="java.lang.String">org.jboss.soa.esb.message.defaultEntry</arg1>
</property>
</action>
</actions>
</service>
<listeners>
And here my ftp-provider
<ftp-provider hostname="${currency.ftp.host}" name="currency-provider">
<ftp-bus busid="currency-ftp-in">
<ftp-message-filter directory="${currency.ftp.directory}" error-delete="false" error-suffix=".HAS_ERROR"
input-suffix=".csv"
passive="true" password="${currency.ftp.password}" post-delete="false" post-rename="true"
post-suffix=".COMPLETE" username="${currency.ftp.username}" work-suffix=".garudaWorking" />
</ftp-bus>
</ftp-provider>
So its possible tthat something goes wrong in my persistRate method. But in any case the ftp-listener will rename the file to <filename>.COMPLETE independently of throwing an exception in my method. So my question is how do I handle this correctly. What I want to have is, if anything goes wrong rename the file to <filename>.HAS_ERROR
Best regards
Phillip
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/564097#564097]
Start a new discussion in JBoss ESB Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years, 2 months
[JBoss Messaging Development] - Failed to write property - java.lang.NullPointerException - infinity messages
by Alexei J
Alexei J [http://community.jboss.org/people/a_subscriber] created the discussion
"Failed to write property - java.lang.NullPointerException - infinity messages"
To view the discussion, visit: http://community.jboss.org/message/565750#565750
--------------------------------------------------------------
JBoss AS 5.1 - success started
I have a simple jms application
private void run(String customerName) throws Exception {
try {
Context initial = new InitialContext();
ConnectionFactory cf = (ConnectionFactory) initial.lookup("/ConnectionFactory");
Destination notifyTopic = (Destination) initial.lookup("topic/testTopic");
Destination requestTopic = (Destination) initial.lookup("topic/testDurableTopic");
logger.trace("Creating Connection...");
connection = cf.createConnection();
connection.setClientID(customerName);
logger.trace("Creating Session...");
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
logger.trace("Creating MessageProducer to send messages to the specified destination. ...");
producer = session.createProducer(requestTopic);
logger.trace("Creating a MessageConsumer for the specified destination. ...");
consumer = session.createConsumer(notifyTopic);
logger.trace("Starts (or restarts) a connection's delivery of incoming messages...");
connection.start();
for (;;) {
listen(customerName);
}
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
} finally {
if (connection != null)
connection.close();
}
}
jndi.properties file:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=jnp://localhost:1099
I create jar and deploy it to the %JBOSS_HOME%/server/default/messaging/myapplication/customers/Xavier/
run application on the jboss:
java -cp myproject.jar;%JBOSS_HOME%/client/jbossall-client.jar com.mycompany.myproject.Customer Xavier
and I get infinity the next messages:
[11 ieo 2010 12:03:00.963] com.mycompany.myproject.Customer.main(Customer.java:123) TRACE:
Start customer
[11 ieo 2010 12:03:01.041] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
createSocket, hostAddr: localhost/127.0.0.1, port: 1099, localAddr: null, localPort: 0, timeout: 0
[11 ieo 2010 12:03:01.713] org.jboss.logging.Logger.trace(Logger.java:160) TRACE:
org.jboss.aop.classpool.AOPClassPool@1389188011 [class path: sun.misc.Launcher$AppClassLoader@3326b249;] - dcl:sun.misc.Launcher$AppClassLoader@3326b249 creating pool for loader sun.misc.Launcher$AppClassLoader@3326b249 searchStrategy:org.jboss.aop.classpool.AOPClassPool$SearchAllRegisteredLoadersSearchStrategy@26302a05 isTemp:false
[11 ieo 2010 12:03:01.776] com.mycompany.myproject.Customer.run(Customer.java:69) TRACE:
Creating Connection...
[11 ieo 2010 12:03:01.807] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
Remoting version: 2.5.3.SP1 (Flounder)
[11 ieo 2010 12:03:01.822] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
Client[1699270891:5c4o56o-d5cpbk-gf547yym-1-gf547yym-2].connect(null)
[11 ieo 2010 12:03:01.822] org.jboss.logging.Logger.trace(Logger.java:160) TRACE:
Client[1699270891:5c4o56o-d5cpbk-gf547yym-1-gf547yym-2]: metadata = null
[11 ieo 2010 12:03:01.885] org.jboss.logging.Logger.trace(Logger.java:160) TRACE:
Mapping properties for bean: SocketClientInvoker[2afa14cb, bisocket://127.0.0.1:4457]
[11 ieo 2010 12:03:01.885] org.jboss.logging.Logger.trace(Logger.java:160) TRACE:
Property editor found for: marshaller, editor: java.beans.PropertyDescriptor@40f7af00, setter: public void org.jboss.remoting.MicroRemoteClientInvoker.setMarshaller(org.jboss.remoting.marshal.Marshaller)
[11 ieo 2010 12:03:01.901] org.jboss.logging.Logger.trace(Logger.java:160) TRACE:
Failed to find property editor for: marshaller
[11 ieo 2010 12:03:01.901] org.jboss.logging.Logger.trace(Logger.java:171) TRACE:
Failed to write property
java.lang.NullPointerException
at org.jboss.util.propertyeditor.PropertyEditors.mapJavaBeanProperties(PropertyEditors.java:377)
at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.mapJavaBeanProperties(MicroSocketClientInvoker.java:1359)
at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.setup(MicroSocketClientInvoker.java:533)
at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.<init>(MicroSocketClientInvoker.java:292)
at org.jboss.remoting.transport.socket.SocketClientInvoker.<init>(SocketClientInvoker.java:78)
at org.jboss.remoting.transport.bisocket.BisocketClientInvoker.<init>(BisocketClientInvoker.java:166)
at org.jboss.remoting.transport.bisocket.TransportClientFactory.createClientInvoker(TransportClientFactory.java:44)
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.remoting.InvokerRegistry.loadClientInvoker(InvokerRegistry.java:460)
at org.jboss.remoting.InvokerRegistry.createClientInvoker(InvokerRegistry.java:359)
at org.jboss.remoting.Client$6.run(Client.java:724)
at java.security.AccessController.doPrivileged(Native Method)
at org.jboss.remoting.Client.connect(Client.java:720)
at org.jboss.remoting.Client.connect(Client.java:668)
at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate.createClient(ClientConnectionFactoryDelegate.java:343)
at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate.org$jboss$jms$client$delegate$ClientConnectionFactoryDelegate$getClientAOPStack$aop(ClientConnectionFactoryDelegate.java:246)
at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate.getClientAOPStack(ClientConnectionFactoryDelegate.java)
at org.jboss.jms.client.ClientAOPStackLoader.load(ClientAOPStackLoader.java:75)
at org.jboss.jms.client.JBossConnectionFactory.createConnectionInternal(JBossConnectionFactory.java:192)
at org.jboss.jms.client.JBossConnectionFactory.createConnection(JBossConnectionFactory.java:87)
at org.jboss.jms.client.JBossConnectionFactory.createConnection(JBossConnectionFactory.java:82)
at com.mycompany.myproject.Customer.run(Customer.java:70)
at com.mycompany.myproject.Customer.main(Customer.java:127)
[11 ieo 2010 12:03:01.901] org.jboss.logging.Logger.trace(Logger.java:160) TRACE:
Property editor found for: timeout, editor: java.beans.PropertyDescriptor@5f20829f, setter: null
[11 ieo 2010 12:03:01.901] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
SocketClientInvoker[2afa14cb, bisocket://127.0.0.1:4457] setting client socket wrapper class name to org.jboss.jms.client.remoting.ClientSocketWrapper
[11 ieo 2010 12:03:01.901] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
SocketClientInvoker[2afa14cb, bisocket://127.0.0.1:4457] setting shouldCheckConnection to false
[11 ieo 2010 12:03:01.901] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
SocketClientInvoker[2afa14cb, bisocket://127.0.0.1:4457] setting timeout to 300000
[11 ieo 2010 12:03:01.901] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
SocketClientInvoker[2afa14cb, bisocket://127.0.0.1:4457] constructed
[11 ieo 2010 12:03:01.916] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
SocketClientInvoker[2afa14cb, bisocket://127.0.0.1:4457] setting client socket wrapper class name to org.jboss.jms.client.remoting.ClientSocketWrapper
[11 ieo 2010 12:03:01.916] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
SocketClientInvoker[2afa14cb, bisocket://127.0.0.1:4457] setting shouldCheckConnection to false
[11 ieo 2010 12:03:01.916] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
SocketClientInvoker[2afa14cb, bisocket://127.0.0.1:4457] setting timeout to 300000
[11 ieo 2010 12:03:01.916] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
SocketClientInvoker[2afa14cb, bisocket://127.0.0.1:4457] connecting
[11 ieo 2010 12:03:01.916] org.jboss.logging.Logger.debug(Logger.java:228) DEBUG:
Creating semaphore with size 50
[11 ieo 2010 12:03:01.932] org.jboss.logging.Logger.trace(Logger.java:160) TRACE:
SocketClientInvoker[2afa14cb, bisocket://127.0.0.1:4457] added new pool ([]) as ServerAddress[127.0.0.1:4457, NO enableTcpNoDelay timeout 300000 ms, maxPoolSize=50]
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/565750#565750]
Start a new discussion in JBoss Messaging Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years, 2 months
[JBoss ESB Development] - Re: httprouter issues with GET/POST WADL Services and Web Routing
by Luke Samad
Luke Samad [http://community.jboss.org/people/luke.samad] created the discussion
"Re: httprouter issues with GET/POST WADL Services and Web Routing"
To view the discussion, visit: http://community.jboss.org/message/601696#601696
--------------------------------------------------------------
I found this post extremely useful and I managed this by writing a custom action. I figured it might help others. Thank you guys for the great start.
<service category="Case" description="CRUD on docket" invmScope="GLOBAL" invmTransacted="true" name="Docket">
<listeners>
<http-gateway name="httpDocket" payloadAs="STRING" urlPattern="client/docket/*">
<property name="synchronousTimeout" value="150000" />
</http-gateway>
</listeners>
<actions mep="RequestResponse">
<action class="gov.usc.commons.soa.esb.actions.HttpRestProxyAction" name="DocketAction">
<property name="endpointUrl" value="${client.docket.war.url}" />
<property name="logDebug" value="${log.case}" />
</action>
</actions>
</service>
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.jboss.soa.esb.actions.AbstractActionLifecycle;
import org.jboss.soa.esb.actions.ActionProcessingException;
import org.jboss.soa.esb.actions.BeanConfiguredAction;
import org.jboss.soa.esb.http.HttpHeader;
import org.jboss.soa.esb.http.HttpRequest;
import org.jboss.soa.esb.message.Message;
public class HttpRestProxyAction extends AbstractActionLifecycle implements BeanConfiguredAction {
private static final Logger log = Logger.getLogger(HttpRestProxyAction.class);
private String endpointUrl;
private String logDebug;
private Boolean debug = Boolean.FALSE;
public Message process(Message message) throws ActionProcessingException {
debug = (logDebug != null && logDebug.equalsIgnoreCase("true")) ? Boolean.TRUE : Boolean.FALSE;
HttpRequest request = HttpRequest.getRequest(message);
String outputXml = null;
String inputXml = null;
Object defaultLocation = message.getBody().get();
if (defaultLocation != null && !defaultLocation.getClass().getSimpleName().equals("byte[]")) {
log.info("defaultLocation class type " + defaultLocation.getClass().getSimpleName());
inputXml = (String) defaultLocation;
}
if(debug && inputXml != null){
log.info("#############################");
log.info("Input XML >>>> \n"+inputXml);
log.info("#############################");
}
HashMap<String, String> headers = populateHeaders(request.getHeaders());
HashMap<String, String> params = populateParameters(request.getQueryParams());
if (request.getMethod().equals("GET")) {
if (!headers.isEmpty() && !params.isEmpty()) {
outputXml = HttpClientUtil.executeGet(endpointUrl, params, headers);
message.getBody().add(outputXml);
} else if (headers.isEmpty() && !params.isEmpty()) {
outputXml = HttpClientUtil.executeGet(endpointUrl, params);
message.getBody().add(outputXml);
} else {
outputXml = HttpClientUtil.executeGet(endpointUrl);
message.getBody().add(outputXml);
}
} else if (request.getMethod().equals("POST")) {
if (!headers.isEmpty() && !params.isEmpty()) {
outputXml = HttpClientUtil.executePost(inputXml, endpointUrl, params, headers);
message.getBody().add(outputXml);
} else if (headers.isEmpty() && !params.isEmpty()) {
outputXml = HttpClientUtil.executePost(inputXml, endpointUrl, params);
message.getBody().add(outputXml);
} else {
outputXml = HttpClientUtil.executePost(inputXml, endpointUrl);
message.getBody().add(outputXml);
}
} else if (request.getMethod().equals("PUT")) {
if (!headers.isEmpty() && !params.isEmpty()) {
outputXml = HttpClientUtil.executePut(inputXml, endpointUrl, params, headers);
message.getBody().add(outputXml);
} else if (headers.isEmpty() && !params.isEmpty()) {
outputXml = HttpClientUtil.executePut(inputXml, endpointUrl, params);
message.getBody().add(outputXml);
} else {
outputXml = HttpClientUtil.executePut(inputXml, endpointUrl);
message.getBody().add(outputXml);
}
} else if (request.getMethod().equals("DELETE")) {
if (!headers.isEmpty() && !params.isEmpty()) {
outputXml = HttpClientUtil.executeDelete(endpointUrl, params, headers);
message.getBody().add(outputXml);
} else if (headers.isEmpty() && !params.isEmpty()) {
outputXml = HttpClientUtil.executeDelete(endpointUrl, params);
message.getBody().add(outputXml);
} else {
outputXml = HttpClientUtil.executeDelete(endpointUrl);
message.getBody().add(outputXml);
}
}
if(debug && outputXml != null){
log.info("#############################");
log.info("Output XML \n"+outputXml);
log.info("#############################");
}
return message;
}
private HashMap<String, String> populateHeaders(List<HttpHeader> requestHeaders) {
HashMap<String, String> headers = new HashMap<String, String>();
if (requestHeaders != null && !requestHeaders.isEmpty()) {
if (debug) {
log.debug("****************** Request Headers ******************");
}
for (HttpHeader header : requestHeaders) {
if (debug) {
log.info("key: " + header.getName() + " " + "value: " + header.getValue());
}
headers.put(header.getName(), header.getValue());
}
}
return headers;
}
private HashMap<String, String> populateParameters(Map<String, String[]> requestParameters) {
HashMap<String, String> params = new HashMap<String, String>();
if (requestParameters != null && !requestParameters.isEmpty()) {
if (debug) {
log.info("******************Request parameters ******************");
}
for (String s : requestParameters.keySet()) {
String[] value = requestParameters.get(s);
if (debug) {
log.info("key " + s + " " + "value " + value[0]);
}
params.put(s, value[0]);
}
}
return params;
}
public void setEndpointUrl(String endpointUrl) {
this.endpointUrl = endpointUrl;
}
public void setLogDebug(String logDebug) {
this.logDebug = logDebug;
}
}
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.DeleteMethod;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.PutMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.httpclient.util.URIUtil;
import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;
public class HttpClientUtil {
public static final Logger log = Logger.getLogger(HttpClientUtil.class);
public static String executeGet(String url){
log.info("entering HTTP GET with no parameters and no headers");
log.info("URL >> "+url);
String xml = null;
GetMethod method = null;
try{
HttpClient httpClient = new HttpClient();
method = new GetMethod(url);
int httpStatusCode = httpClient.executeMethod(method);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
logHTTPStatusCode(httpStatusCode);
InputStream response = method.getResponseBodyAsStream();
xml = new String(IOUtils.toByteArray(response), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xml;
}
public static String executeGet(String url, HashMap<String, String> parameters){
log.info("entering HTTP GET with parameters and no headers");
log.info("URL >> "+url);
String xml = null;
GetMethod method = null;
try{
HttpClient httpClient = new HttpClient();
method = new GetMethod(url);
if(parameters!=null && parameters.size() > 0){
NameValuePair[] params = buildQueryParameters(parameters);
method.setQueryString(params);
}
int httpStatusCode = httpClient.executeMethod(method);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
logHTTPStatusCode(httpStatusCode);
InputStream response = method.getResponseBodyAsStream();
xml = new String(IOUtils.toByteArray(response), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xml;
}
public static String executeGet(String url, HashMap<String, String> parameters, HashMap<String, String> headers ){
log.info("entering HTTP GET with parameters and headers");
log.info("URL >> "+url);
String xml = null;
GetMethod method = null;
try{
HttpClient httpClient = new HttpClient();
method = new GetMethod(url);
if(parameters!=null && parameters.size() > 0){
NameValuePair[] params = buildQueryParameters(parameters);
method.setQueryString(params);
}
if(headers!=null && headers.size() > 0){
setRequestHeaders(method, headers);
}
int httpStatusCode = httpClient.executeMethod(method);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
logHTTPStatusCode(httpStatusCode);
InputStream response = method.getResponseBodyAsStream();
xml = new String(IOUtils.toByteArray(response), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xml;
}
public static String executePut(String xml, String url){
log.info("entering HTTP PUT with no parameters and no headers");
log.info("URL >> "+url);
String xmlReturn = null;
PutMethod method = null;
try{
HttpClient httpClient = new HttpClient();
method = new PutMethod(url);
method.setRequestEntity(new StringRequestEntity(xml, "application/xml", "UTF8"));
int httpStatusCode = httpClient.executeMethod(method);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
logHTTPStatusCode(httpStatusCode);
InputStream updateResponse = method.getResponseBodyAsStream();
xmlReturn = new String(IOUtils.toByteArray(updateResponse ), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xmlReturn;
}
public static String executePut(String xml, String url, HashMap<String, String> parameters){
log.info("entering HTTP PUT with parameters and no headers");
log.info("URL >> "+url);
String xmlReturn = null;
PutMethod method = null;
try{
HttpClient httpClient = new HttpClient();
method = new PutMethod(url);
if(parameters!=null && parameters.size() > 0){
NameValuePair[] params = buildQueryParameters(parameters);
if(params!= null)
method.setQueryString(params);
}
method.setRequestEntity(new StringRequestEntity(xml, "application/xml", "UTF8"));
int httpStatusCode = httpClient.executeMethod(method);
logHTTPStatusCode(httpStatusCode);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
InputStream updateResponse = method.getResponseBodyAsStream();
xmlReturn = new String(IOUtils.toByteArray(updateResponse ), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xmlReturn;
}
public static String executePut(String xml, String url, HashMap<String, String> parameters, HashMap<String, String> headers ){
log.info("entering HTTP PUT with parameters and headers");
log.info("URL >> "+url);
String xmlReturn = null;
PutMethod method = null;
try{
HttpClient httpClient = new HttpClient();
method = new PutMethod(url);
if(parameters!=null && parameters.size() > 0){
NameValuePair[] params = buildQueryParameters(parameters);
if(params!= null)
method.setQueryString(params);
}
if(headers!=null && headers.size() > 0){
setRequestHeaders(method, headers);
}
method.setRequestEntity(new StringRequestEntity(xml, "application/xml", "UTF8"));
int httpStatusCode = httpClient.executeMethod(method);
logHTTPStatusCode(httpStatusCode);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
InputStream updateResponse = method.getResponseBodyAsStream();
xmlReturn = new String(IOUtils.toByteArray(updateResponse ), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xmlReturn;
}
public static String executePost(String xml, String url){
log.info("entering HTTP POST with no parameters and no headers");
log.info("URL >> "+url);
String xmlReturn = null;
PostMethod method = null;
try{
HttpClient httpClient = new HttpClient();
method = new PostMethod(url);
method.setRequestEntity(new StringRequestEntity(xml, "application/xml", "UTF8"));
int httpStatusCode = httpClient.executeMethod(method);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
logHTTPStatusCode(httpStatusCode);
InputStream response = method.getResponseBodyAsStream();
xmlReturn = new String(IOUtils.toByteArray(response), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xmlReturn;
}
public static String executePost(String xml, String url, HashMap<String, String> parameters){
log.info("entering HTTP POST with parameters and no headers");
log.info("URL >> "+url);
String xmlReturn = null;
PostMethod method = null;
try{
HttpClient httpClient = new HttpClient();
method = new PostMethod(url);
if(parameters!=null && parameters.size() > 0){
NameValuePair[] params = buildQueryParameters(parameters);
if(params!= null)
method.setQueryString(params);
}
method.setRequestEntity(new StringRequestEntity(xml, "application/xml", "UTF8"));
int httpStatusCode = httpClient.executeMethod(method);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
logHTTPStatusCode(httpStatusCode);
InputStream response = method.getResponseBodyAsStream();
xmlReturn = new String(IOUtils.toByteArray(response), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xmlReturn;
}
public static String executePost(String xml, String url, HashMap<String, String> parameters, HashMap<String, String> headers ){
log.info("entering HTTP POST with parameters and headers");
log.info("URL >> "+url);
String xmlReturn = null;
PostMethod method = null;
try{
HttpClient httpClient = new HttpClient();
method = new PostMethod(url);
if(parameters!=null && parameters.size() > 0){
NameValuePair[] params = buildQueryParameters(parameters);
if(params!= null)
method.setQueryString(params);
}
if(headers!=null && headers.size() > 0){
setRequestHeaders(method, headers);
}
method.setRequestEntity(new StringRequestEntity(xml, "application/xml", "UTF8"));
int httpStatusCode = httpClient.executeMethod(method);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
logHTTPStatusCode(httpStatusCode);
InputStream response = method.getResponseBodyAsStream();
xmlReturn = new String(IOUtils.toByteArray(response), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xmlReturn;
}
public static String executeDelete(String url){
log.info("entering HTTP DELETE with no parameters and no headers");
log.info("URL >> "+url);
DeleteMethod method = null;
String xml = null;
try{
HttpClient httpClient = new HttpClient();
method = new DeleteMethod(url);
int httpStatusCode = httpClient.executeMethod(method);
logHTTPStatusCode(httpStatusCode);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
InputStream response = method.getResponseBodyAsStream();
xml = new String(IOUtils.toByteArray(response), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xml;
}
public static String executeDelete(String url, HashMap<String, String> parameters){
log.info("entering HTTP DELETE with parameters and no headers");
log.info("URL >> "+url);
String xml = null;
DeleteMethod method = null;
try{
HttpClient httpClient = new HttpClient();
method = new DeleteMethod(url);
if(parameters!=null && parameters.size() > 0){
NameValuePair[] params = buildQueryParameters(parameters);
if(params!= null)
method.setQueryString(params);
}
int httpStatusCode = httpClient.executeMethod(method);
logHTTPStatusCode(httpStatusCode);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
InputStream response = method.getResponseBodyAsStream();
xml = new String(IOUtils.toByteArray(response), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xml;
}
public static String executeDelete(String url, HashMap<String, String> parameters, HashMap<String, String> headers ){
log.info("entering HTTP DELETE with parameters and headers");
log.info("URL >> "+url);
String xml = null;
DeleteMethod method = null;
try{
HttpClient httpClient = new HttpClient();
method = new DeleteMethod(url);
if(parameters!=null && parameters.size() > 0){
NameValuePair[] params = buildQueryParameters(parameters);
if(params!= null)
method.setQueryString(params);
}
if(headers!=null && headers.size() > 0){
setRequestHeaders(method, headers);
}
int httpStatusCode = httpClient.executeMethod(method);
logHTTPStatusCode(httpStatusCode);
assert (httpStatusCode == 200 || httpStatusCode == 204) ;
InputStream response = method.getResponseBodyAsStream();
xml = new String(IOUtils.toByteArray(response), method.getResponseCharSet());
}catch (Exception e) {
String exception = getExceptionStackTraceAsString(e);
log.error(exception);
}finally{
method.releaseConnection();
}
return xml;
}
private static void setRequestHeaders(HttpMethod method , HashMap<String, String> headers ){
log.info(" ************** headers ************** ");
if(headers != null && headers.size() > 0){
for(String s : headers.keySet()) {
log.info("header="+s+" valkue="+headers.get(s));
method.setRequestHeader(s, headers.get(s));
}
}
}
private static NameValuePair[] buildQueryParameters(HashMap<String, String> parameters ) throws Exception{
log.info(" ************** parameters ************** ");
NameValuePair[] params = null;
if (parameters != null) {
params = new NameValuePair[parameters.size()];
int i = 0;
for (String s : parameters.keySet()) {
log.info("parameter="+s+" value="+parameters.get(s));
params[i] = new NameValuePair(s, URIUtil.encodeQuery(parameters.get(s)));
i++;
}
}
return params;
}
private static String getExceptionStackTraceAsString(Exception exception) {
StringWriter sw = new StringWriter();
exception.printStackTrace(new PrintWriter(sw));
return sw.toString();
}
private static void logHTTPStatusCode(int code ){
log.info("HTTP Status code is >> "+code);
}
}
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/601696#601696]
Start a new discussion in JBoss ESB Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years, 5 months
[JBoss ESB Development] - Stuck in BRMS
by starfish15
starfish15 [http://community.jboss.org/people/starfish15] created the discussion
"Stuck in BRMS"
To view the discussion, visit: http://community.jboss.org/message/602414#602414
--------------------------------------------------------------
Hello every1,
I am doing the needful with the BRMS after coding and learning JBoss ESB. However i am stuck terribly in the same. I did the following
* Unzipped the brms-deployable-5.1.0.zip
* Next unzipped the jboss-brms-manager
* Placed the jboss-brms.war at *D:\JBoss SOA\jboss-soa-p.5.0.0\jboss-as\server\default\deploy\*
* In the properties-service.xml file, added *drools.serialization.sign=false* at attribute *Properties* like mentioned below
<attribute name="Properties">
drools.serialization.sign=false
</attribute>
* Next at *D:\JBoss SOA\jboss-soa-p.5.0.0\jboss-as\server\default\deploy\jboss-brms.war\WEB-INF,* added the following in components.
* <security:role-based-permission-resolver enable-role-based-authorization="true"/>*
* Then on a web browser tried hitting http://localhost:8080/jboss-brms/
* The Login Page asking the User Name and Password came up
* Tried logging in using admin/admin for both
* Pop -Up saying incorrect username and password came up.
Also someone told me to do this "uncomment the user and roles settings in the configuration. Check the conf/props and open the brms-users.properties and brms-groups.properties files." Now the catch is i am unable to find both these files absolutely anywhere within the server folder in jboss-as of jboss-soa-p.5.0.0.
Kinldy assist at the earliest and do let me know if i am mistaken absolutely anywhere.
Regards,
Starfish
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/602414#602414]
Start a new discussion in JBoss ESB Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years, 6 months
[JBoss Transactions Development] - org.jboss.messaging.core.impl.tx.TransactionException: Cannot find entry forxid:MessagingXid
by prahlad reddy
prahlad reddy [http://community.jboss.org/people/prahlads] created the discussion
"org.jboss.messaging.core.impl.tx.TransactionException: Cannot find entry forxid:MessagingXid"
To view the discussion, visit: http://community.jboss.org/message/579465#579465
--------------------------------------------------------------
In production server we have encountered this exception, Needmore information
Exception Stack Trace ::
[2010-07-21 06:02:10,139] [ERROR][org.jboss.messaging.util.ExceptionUtil]ConnectionEndpoint[au-s6wk5vbg-1-3add5vbg-sqfpjn-v10t2a] sendTransaction[v8f-zi7d
nvbg-1-3add5vbg-sqfpjn-v10t2a]
org.jboss.messaging.core.impl.tx.TransactionException: Cannot find entry forxid:MessagingXid (36214490bq:97.54.53.48.48.52.51.58.101.98.49.53.58.52.99.52.5
3.102.98.50.102.58.97.50.57.99.57 formatID:131075gtxid:103.98.115.108.105.118.101.49.45.97.54.53.48.48.52.51.58.101.98.49.53.58.52.99.52.53.102.98.50.102.58
.97.50.56.48.48
atorg.jboss.messaging.core.impl.tx.TransactionRepository.getPreparedTx(TransactionRepository.java:223)
atorg.jboss.jms.server.endpoint.ServerConnectionEndpoint.sendTransaction(ServerConnectionEndpoint.java:526)
atorg.jboss.jms.server.endpoint.advised.ConnectionAdvised.org$jboss$jms$server$endpoint$advised$ConnectionAdvised$sendTransaction$aop(ConnectionAdvi
sed.java:101)
at org.jboss.jms.server.endpoint.advised.ConnectionAdvised$sendTransaction_N3268650789275322226.invokeNext(ConnectionAdvised$sendTransaction_N3268650
789275322226.java)
>From googling I have get the snippet of code for TransactoinRepository.java for Jboss application server
Snippet of code of TransactoinRepository.java from jboss::
public Transaction getPreparedTx(Xid xid) throws Exception
218 {
219 Transaction tx =(Transaction)map.get(xid);
220
221 if (tx == null)
222 {
223 throw newTransactionException("Cannot find entry for xid:" + xid);
224 }
225 if (tx.getState() !=Transaction.STATE_PREPARED)
226 {
227 throw newTransactionException("Transaction with xid " + xid + " is not inprepared state");
228 }
229 return tx;
230 }
Exception happened at 223 line no , my question in above code Transaction object getting from map with xid
Transactiontx = (Transaction)map.get(xid);
Object returned from map as null for the same reason above exception encountered in my case .
What are the possible for occurring this kind of exception, need more information about the exception.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/579465#579465]
Start a new discussion in JBoss Transactions Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
13 years, 6 months