Skip to main content

Posts

Build Wine rpm with 32 bit application support

Wine is a software to allow running Windows applications in Linux, MAC etc. platforms. It is available for installation from package managers like yum (RHEL, CentOS) and apt (Ubuntu). You can find more details on how it works in Wine wiki . But the default Wine package available from package manager does not have support for 32 bit Windows applications. This was the case for me. In Redhat Enterprise Linux 7.3, the wine package did not contain support for 32 bit windows applications. So the only option was to build a separate rpm of wine which will include this support. All the steps are executed on a RHEL 7.3 VM (x86_64). Step 1 Download and run shell script which will make wine 64 and 32 support for RHEL: https://github.com/zma/usefulscripts/blob/master/script/install-wine-i686-centos7.sh It accepts a version no. as CLI parameter e.g. 2.0.3 The script installs wine in /usr/local/ directory by default. We can verify the files that are being copied for wine using "...

Flexigrid table becomes read only when no rows returned from server - solution

Flexigrid is a popular jQuery plugin which builds multipurpose data grid in web pages. It is a light weight plugin with rich controls. I have used Flexigrid heavily in my project. While using the plugin I faced one problem. It disables the grid when there are no rows in it. This looks like a proper behavior until you need the buttons in the table (Add) to be enabled for the first row to be added. To clarify the requirement I had, there is a grid with Add and Delete buttons in it. The first row in the grid will be added through the add button. So, when the table loads for the first time, there is no row and this makes the grid read only. Now, we can not click the add button. It becomes a recursive problem. The Flexigrid code that does this - I have devised a dirty fix for this problem - Use this code in your document.ready() function. I tried asking the problem in the Flexigrid mailing list also, but could not get any other solution. So, currently this is the only working so...

Resolve Hibernate connection timeout issue with MySQL server

This problem has been faced by many of the developers but the fix is not very common. I had to do some research to find out the problem and solve it. If you are using a MySQL server, the default connection timeout is 8 hours (tested on MySQL 5.2). This causes a problem in production environment as the database could not be connected overnight. Below is the log trace of the problem - org.hibernate.util.JDBCExceptionReporter: The last packet successfully received from the server was 56697 seconds ago. The last packet sent successfully to the server was 56697 seconds ago, which  is longer than the server configured value of ‘wait_timeout’. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property ‘autoReconnect=true’ to avoid this problem. As the description says, we can increase the wait_timeout property of MySQL server but it is...

A simple REST based web service

REST stands for Representational State Transfer. Roy Fielding, the father of HTTP protocol, had coined the term in his doctoral thesis. REST is not a software, rather it is a concept or an architecture. The biggest use of REST architecture is in WWW (World Wide Web). The services that conforms to REST standard are termed as RESTful services. REST based services contain a client and a server. The server contains resources that can be represented by various states. A client initiates the request to server when it is ready to transition it's state. The server responds with the required state. The REST based web service is quite popular now. This type of web service is called RESTful web service. In RESTful web service we represent a service by an URI. Common HTTP methods are used to request for a specific state transfer. Create PUT Update POST Read GET Remove DELETE I have used an open source java library called Jersey  for creating this simple RESTful web service. ...

Using web service client behind a http proxy server

Web service is a popular medium of communication between devices over a network. But most of the time you find yourself behind a http proxy server to connect to the network. Proxy servers are often found in company networks. The main reasons for their introduction are - security, resource caching, auditing etc. But ultimately they block unauthorized access to internet from the inside network. This leads to the problem we are going to solve now. We are going to use w3schools temperature converter service ( WSDL download ) for testing. Make sure you are actually running this code behind a http proxy server. You also need to know the proxy server's host name and the port no.  I'll assume that you can generate the client stubs using JAX-WS (or some other tool). I have used wsconsume tool to generated my stubs. In my case,  com.w3schools.TempConvert is the implementation class and  com.w3schools.TempConvertSoap is the interface. Then I have a com.w3schools.client.WSClie...

Write your first JAXWS web service

Today I'll try to explain how easily one can build a JAX-WS web service. Web Services are very popular now-a-days. They are used every where. But I found it difficult to write my first web service with jax-ws, partly because I was trying myself and partly because I could not get a simple explanation of steps. That is why I'll try to show the simplest web service possible using jaxws. First thing first, what do you need to build your first jax-ws web service. JDK 1.6 (I used update 23) Eclipse IDE (you can use some other IDE as well) Are you kidding? nothing else. JAX-WS 2.0 is actually Sun's (now Oracle) reference implementation of Web Service stack. It is bundled with JDK 6 and above. First you need to create a Java project in Eclipse. Then create a class called com.ws.HelloService . This will be our web service class. Have a public method in this class which will be exposed as web service. Below is the code - The catch here is the @WebService annotation. Thi...

Get JSON data response with JQuery Form plugin for a file upload form

My latest project involves JQuery for UI development. Frankly speaking, I did not have much idea of JQuery before. But I found it very easy to understand. All APIs are well documented with lots of examples available on Internet. The best feature of JQuery is its plugins. There are thousands of plugins available to play with. For every need of my web app I could find a plugin. In my web app I am using JQuery Form plugin to submit the forms through AJAX. The return from my servlet is JSON object. The form plugin works great for all my forms. Well almost all, there is a HTML form which has a file upload box along with other input fields. This form was not able to get the response in JSON format. Though it worked in Google Chrome, but Firefox was presenting me with a file save dialog box. I did a lot of googling to find out whats going on. Finally I observed that the problem is with HTTP headers that the form submit request has. Here are the headers captured by Chrome Request heade...

log4j.xml - A sample configuration

I could not post anything last month though all the time I was dying to post something. The reason behind this was I change in my profession profile. Actually, I changed my employer. All of the last month I was busy in official work and to settle down in my new office. The last week of the year is normally a holiday in the new company. So, I could rest a while in my home and able to write the blog post. Though I had a couple of other topics in mind but writing them will take more time which I don't want to spend during the festivities. So, I'll discuss about a simple but useful thing. How many of us in Java sphere use log4j for logging? You know the answer. log4j is a very popular logging framework. Configuring log4j is quite simple. Still when you get the task of doing it, you try to find an example (I do the same). That is why I'll show a simple log4j configuration to print to a file. There are 2 ways to configure log4j, log4j.properties and log4j.xml. I prefer the...