log4j.rootCategory=INFO, console, file
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{dd MMM yy HH:mm:ss} %c{1} %-5p %x - %m%n
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.File=/msgs/logs/project.log
log4j.appender.file.File.DatePattern='.'yyyy-MM-dd
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{dd-MM-yyyy HH:mm:ss} %-5p %c{1}:%L - %m%n
Tuesday, November 1, 2016
Log4J - log file name with date (each day have one log file)
This is the log4j.properties file I used.
Wednesday, June 29, 2016
Jquery - disable the default action, reload datatables, and others
When I worked on a form submit, I would like to use the js code to submit the form. But I found out it submitted twice. Then I realized I need to disable the default action from the form.
Also after finished the action, I would like the data table to be reloaded again. The code is as below.
$("button").click(function(e)
{
e.preventDefault(); // default form action of the event will not be triggered
var data = {
'id[]' : []
};
$.each($("input[name='id[]']:checked"), function()
{
data['id[]'].push($(this).val());
});
$.ajax({
url : contextPath
+ "/reloadTranscepta", type : "POST", dataType : "json", data : data, success : function(data)
{
table.ajax.reload(null, false); // Reload the table
$('#transcepta-select-all').prop('checked', false);
if (data.status == '200 OK')
{
$("#result").html('<strong>Success!</strong> The POs you selected have been sent successfully.');
$("#result").attr('class', 'alert alert-success');
}
else
{
$("#result").html('<strong>Error!</strong> A problem has been occurred while sending POs to Transcepta.');
$("#result").attr('class', 'alert alert-danger alert-error');
}
}, error : function(xhr, textStatus, errorThrown)
{
$("#result").html('<strong>Error!</strong> A problem has been occurred while sending POs to Transcepta.');
$("#result").attr('class', 'alert alert-danger alert-error');
}
});
});
Wednesday, April 13, 2016
DB2 Table Reorg - DB2 SQL Error: SQLCODE=-668, SQLSTATE=57016, SQLERRMC=7;
I got db2 error message when I ran a web application.
After doing some research, I found out I need to reorg the table it mentioned in the error message.
I tried to just run the reorg command in Aqua Data Studio, but I got error message. After consulted with our DBA, this reorg command is not a sql command. The way to run it in Aqua Data studio is as below.
DB2 SQL Error: SQLCODE=-668, SQLSTATE=57016, SQLERRMC=7;
After doing some research, I found out I need to reorg the table it mentioned in the error message.
I tried to just run the reorg command in Aqua Data Studio, but I got error message. After consulted with our DBA, this reorg command is not a sql command. The way to run it in Aqua Data studio is as below.
call sysproc.admin_cmd('reorg table TABLE_NAME')
Tuesday, March 15, 2016
How to change an existing Java application to dynamic web application in Eclipse and deploy it to tomcat server?
I have an old application to enhance and want to convert it into dynamic web application in Eclipse.
1. Open the java application in eclipse. Right click on the project name, and then choose "properties".
2. Choose Project Facets on the left side. On the right side, check "Dynamic Web Module" and "Java" box. Then click OK button.
3. Now this project is a dynamic web project.
4. Deploy the application to local tomcat server. Go to properties again as step 1.
Choose Deployment Assembly on the left side, then in the right side, add the real source directory and deploy path. Then click ok.
5. Add web module into tomcat 8 server.
Right click the Tomcat server and choose Add and Remove, the in the pop up window, add left side application to the right side. Now we can restart tomcat server, the new application will be deployed to the server side and run.
1. Open the java application in eclipse. Right click on the project name, and then choose "properties".
3. Now this project is a dynamic web project.
4. Deploy the application to local tomcat server. Go to properties again as step 1.
Choose Deployment Assembly on the left side, then in the right side, add the real source directory and deploy path. Then click ok.
5. Add web module into tomcat 8 server.
Right click the Tomcat server and choose Add and Remove, the in the pop up window, add left side application to the right side. Now we can restart tomcat server, the new application will be deployed to the server side and run.
Thursday, March 3, 2016
WSO2 ESB ERROR - ClientUtils The system cannot infer the transport information
After I tested my proxy service in ESB, I got the following error when it tried to save the message into a file.
The source code I am using is as below:
After research, I found the error is I need to enable vfs transport in the configuration file.
I enabled the following lines in wso2esb-4.9.0\repository\conf\axis2\axis.xml file. Then it works.
ERROR - ClientUtils The system cannot infer the transport information from the vfs:file:///C:/Temp URL.
The source code I am using is as below:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="saveToFS" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<property
expression="fn:concat(get-property('SYSTEM_DATE', 'yyMMddHHmmss'), '-', get-property('filename'), '.xml')"
name="transport.vfs.ReplyFileName" scope="transport" type="STRING"/>
<property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
<call>
<endpoint>
<address trace="disable" uri="vfs:file:///c:/Temp"/>
</endpoint>
</call>
<log level="custom">
<property name="msg" value="File Saved to Disk"/>
</log>
</sequence>
After research, I found the error is I need to enable vfs transport in the configuration file.
I enabled the following lines in wso2esb-4.9.0\repository\conf\axis2\axis.xml file. Then it works.
<transportReceiver name="vfs" class="org.apache.synapse.transport.vfs.VFSTransportListener"/>
......
<transportSender name="vfs" class="org.apache.synapse.transport.vfs.VFSTransportSender"/>
Tuesday, February 23, 2016
Understanding WSO2 ESB Architecture from a Messaging Perspective
I found this diagram from http://supunk.blogspot.com/2009/07/wso2-esb-high-level-architectural.html?view=sidebar. It is very helpful for me to understand how messages work inside ESB.
An application sends a message to the ESB.
The message is picked up by the ESB transport.
Transport sends the message through a message pipe. Quality of service aspects like Security and reliable messaging of the message is taken care in this pipe. Internally this pipe is the in-flow and out-flow of Axis2. ESB can operate in two modes. Message mediation or proxy services. In case of message mediation a single pipe is used. In case of proxy services we can think of separate pipes connecting transport to different proxy services.
Message transformation + routing can be seen as a single unit. As the diagram specifies there is no clear separation between message transformation components and routing components. WSO2 ESB call this the mediation framework. Some transformations happens before routing decision has taken. Some transformations happens after the the routing decision has taken. This part is the Synapse implementation.
After this message is injected to the separate pipes depending on the destinations. Here again quality of service aspects of the messages is determined.
At the end there is a transport layer. This transport layer takes care of the transport protocol transformations required by the ESB.
How to get response back immediately after WSO2 ESB Proxy Service get the message?
I send a message to ESB proxy service, and I would like to get response immediately after the service receive the content and put into the message queue. That means the proxy service will send back response message before it gets processed.
WSO2 ESB provides properties as a way to control different aspects of the messages flowing through the mediation engine. They will not change the content (payload) of the message but they will be used to change the behavior of the message flowing through the ESB.
FORCE_SC_ACCEPTED is the property we could use for this purpose.
FORCE_SC_ACCEPTED
When set to true, this property forces a 202 HTTP response to the client so that it stops waiting for a response.
( 202 HTTP is for the request has been accepted for processing, but the processing has not been completed. )
We can set this property as below.
<property name="FORCE_SC_ACCEPTED" scope="axis2" value="true"/>
This property can be used in scenarios where client send a message to the ESB and ESB will store the message in a persistent store like a message store. In this scenario, client will wait until the timeout if ESB do not send any response. In this kind of scenario, we can use this property and send a 202 Accepted response to the client. Here is an example configuration where ESB store a message in a message store.
<inSequence>
<property name="FORCE_SC_ACCEPTED" scope="axis2" type="STRING" value="true"/>
<store messageStore="POInbound"/>
</inSequence>
Labels:
202 http response,
accepted,
ESB,
force_sc_accepted,
property,
response,
WSO2
Monday, February 22, 2016
Use WSO2 ESB Developer Studio to Create my first project (2) - Deployment
1. Create Composite Application project
WSO2 DevStudio allows you to package your artifacts into a Composite Application aRchive (CAR) and deploy it to WSO2 servers.
1) Click on Composite Application Project in Developer Studio Dashboard.
2) Enter composite project name.
3) Click finish button.
2. Add WSO2 ESB server in Developer Studio
We've installed WSO2 ESB server in my machine. Here we would like to add ESB server to Developer Studio. For detail on how to install WSO2 ESB server, please see my previous blog.
Setup WSO2 ESB server and ActiveMQ server (Part 1) - Installation
Setup WSO2 ESB server and ActiveMQ server (Part 2)
Setup WSO2 ESB server and ActiveMQ server (Part 3) - WSO2 ESB and ActiveMQ connection
1) Click on Add Server - Server in Developer Studio Dashboard.
2) Choose the server type.
3) Click Finish button.
4) Now you can see the WSO2 ESB server showing under servers tab.
3. Run Composite application on ESB server.
1) Right click on the composite application name, and choose Export composite Application Project.
2) Enter export destination, then click next button.
3) Select artifact to include in the CAR file.
4) Right click on the composite application, and choose Run As , then Run on Server.
5) Choose the server
6) Click on Finish button.
7) Server is running now. We may go to WSO2 ESB server to check if the services created in the developer studio have been deployed to the ESB server.
WSO2 DevStudio allows you to package your artifacts into a Composite Application aRchive (CAR) and deploy it to WSO2 servers.
1) Click on Composite Application Project in Developer Studio Dashboard.
2) Enter composite project name.
3) Click finish button.
2. Add WSO2 ESB server in Developer Studio
We've installed WSO2 ESB server in my machine. Here we would like to add ESB server to Developer Studio. For detail on how to install WSO2 ESB server, please see my previous blog.
Setup WSO2 ESB server and ActiveMQ server (Part 1) - Installation
Setup WSO2 ESB server and ActiveMQ server (Part 2)
Setup WSO2 ESB server and ActiveMQ server (Part 3) - WSO2 ESB and ActiveMQ connection
1) Click on Add Server - Server in Developer Studio Dashboard.
2) Choose the server type.
3) Click Finish button.
4) Now you can see the WSO2 ESB server showing under servers tab.
3. Run Composite application on ESB server.
1) Right click on the composite application name, and choose Export composite Application Project.
2) Enter export destination, then click next button.
3) Select artifact to include in the CAR file.
4) Right click on the composite application, and choose Run As , then Run on Server.
5) Choose the server
6) Click on Finish button.
7) Server is running now. We may go to WSO2 ESB server to check if the services created in the developer studio have been deployed to the ESB server.
Thursday, February 18, 2016
Use WSO2 ESB Developer Studio to Create my first project (1) - Installation, Project Setup
1. Go to the following website to download the latest developer studio.
http://wso2.com/products/developer-studio/
2. Install developer studio in my local machine.
3. Click Eclipse I just installed and get into Eclipse.
5. Click Maven Multi Module project
6. Enter group id and artifact id, then click on finish button.
8. Choose new esb config project.
9. Enter ESB project name, click Finish.
10. Now I would like to create a new proxy service.
11. Choose create a new proxy service, click on next.
12. Enter the service name, click finish.
13. Now the proxy service xml file is generated and opened in the IDE as below.
http://wso2.com/products/developer-studio/
2. Install developer studio in my local machine.
3. Click Eclipse I just installed and get into Eclipse.
5. Click Maven Multi Module project
6. Enter group id and artifact id, then click on finish button.
9. Enter ESB project name, click Finish.
10. Now I would like to create a new proxy service.
11. Choose create a new proxy service, click on next.
12. Enter the service name, click finish.
13. Now the proxy service xml file is generated and opened in the IDE as below.
From here, we can drag Mediators or Endpoints from left side of palette to the design diagram.
Wednesday, February 17, 2016
How to send xml message through servlet http post?
I want to send an xml file to a service through servlet http post. After I did some research and I found a way to easily do this.
1. I chose to use Apache HttpComponents.
2. Download the latest HttpClient jars from https://hc.apache.org/downloads.cgi
3. In my servlet, I import the following classes.
4. In the doPost method, I add the following code.
HttpClient really provides a simply way to do the job.
1. I chose to use Apache HttpComponents.
2. Download the latest HttpClient jars from https://hc.apache.org/downloads.cgi
3. In my servlet, I import the following classes.
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
4. In the doPost method, I add the following code.
// HTTP post xml document to outside service
HttpPost post = new HttpPost("https://testserviceurl");
post.setHeader("Content-Type", "application/xml");
post.setEntity(new StringEntity(xmlString));
HttpClient client = HttpClientBuilder.create().build();
HttpResponse resp = client.execute(post);
String result = EntityUtils.toString(resp.getEntity());
System.out.println("post result:" + result);
HttpClient really provides a simply way to do the job.
Subscribe to:
Posts (Atom)