Wednesday, September 28, 2011

ජීවිතයට පුංචි දෙයක්....










Tuesday, September 27, 2011

How to wrap the maven script with ant ?

Most of the time people need to do the other way around.
That mean to wrap ant scripts with maven scripts. But ,
in some rare situations there are people who want to wrap
maven scripts with ant scripts.

It is very easy to do this. You need to have maven
installed and set the MVN_HOME for this.


<project default="buildProject">
  <property name="source.dir" value="."/>
<target name="buildProject" description="Wrapper for the maven script">
<exec dir="${source.dir}" executable="mvn">
<arg line="clean install" />
</exec>
</target>
</project>


place this code segment in your build.xml file. Place
that build.xml file in the folder which you have the
maven script (pom.xml). Go to the folder with command
prompt. Execute "ant" command. Thats all...!

Thursday, September 22, 2011

error=24, Too many open files

Many users have experience in getting this error when building with maven.

The way to over come this problem is to increase the file limit of the OS.

First, in order to set this options automatically you have to edit the etc/security/limits.conf file.

$sudo gedit /etc/security/limits.conf

with the above command you can open the "limits.conf" file with gedit.
We need to set the nofile option meaning maximum number of open files.If you want to change the number of files of user, you should add this line in the limits.conf file.

Lets say our user name is "foo"

Then the entry should be

foo soft nofile 9000

foo hard nofile 65000




If you want to set the nofile only for superuser you just write root instead of user.


root soft nofile 9000

root hard nofile 65000



Now after rebooting you can see in the terminal with ulimit -a the change.

Wednesday, September 21, 2011

How to disable the web administration console? http://localhost:8080/axis2/axis2-admin/

How to disable the web administration console? http://localhost:8080/axis2/axis2-admin/

Environment:
Axis2-1.6.0

This is a common problem that many users asks and most of them thinks
that this can be done by changing a property in axis2.xml file.

There are more than one way to carry out this task. First we need to
say that axis2.xml has no control on disabling this admin console.
Because of that, changing the properties of axis2.xml file will not
effect on this requirement.

Here i ll specify two different ways to fulfill your requirement.
Both of them will prevent accessing the JSP file which is required to
load the Web Admin Console.

01: Changing the web.xml file

You can find this file at : webapps/axis2/WEB-INF folder.
In this file , you will find the following entry

<servlet-mapping>
<servlet-name>AxisAdminServlet</servlet-name>
<url-pattern>/axis2-admin/*</url-pattern>
</servlet-mapping>

You can comment this entry like

<!--servlet-mapping>
<servlet-name>AxisAdminServlet</servlet-name>
<url-pattern>/axis2-admin/*</url-pattern>
</servlet-mapping-->


This will prevent the page redirection and it will solve your problem.

02: Renaming or Deleting the Login.jsp file

You can find this file at : webapps/axis2/axis2-web folder.
you can delete or rename this file to any other name.
This will prevent access to Login page and it will solve your problem.

Friday, August 5, 2011

Hector Client Exception : InvalidRequestException(why:Expected 8 or 0 byte long (9))

We are getting the following kind of exception due to a small mistake that we do in creating column families in cassandra. I had created the column family with providing
comparator type as LONG.

But once i try to insert columns having String values as column names it throws this error.

Solution: Drop the created column family using cassandra-cli
create the Column Family with appropriate comparator type


me.prettyprint.hector.api.exceptions.HInvalidRequestException: InvalidRequestException(why:Expected 8 or 0 byte long (9))
at me.prettyprint.cassandra.service.ExceptionsTranslatorImpl.translate(ExceptionsTranslatorImpl.java:42)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl$1.execute(KeyspaceServiceImpl.java:95)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl$1.execute(KeyspaceServiceImpl.java:88)
at me.prettyprint.cassandra.service.Operation.executeAndSetResult(Operation.java:101)
at me.prettyprint.cassandra.connection.HConnectionManager.operateWithFailover(HConnectionManager.java:156)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl.operateWithFailover(KeyspaceServiceImpl.java:129)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl.batchMutate(KeyspaceServiceImpl.java:100)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl.batchMutate(KeyspaceServiceImpl.java:106)
at me.prettyprint.cassandra.model.MutatorImpl$2.doInKeyspace(MutatorImpl.java:172)
at me.prettyprint.cassandra.model.MutatorImpl$2.doInKeyspace(MutatorImpl.java:169)
at me.prettyprint.cassandra.model.KeyspaceOperationCallback.doInKeyspaceAndMeasure(KeyspaceOperationCallback.java:20)
at me.prettyprint.cassandra.model.ExecutingKeyspace.doExecute(ExecutingKeyspace.java:72)
at me.prettyprint.cassandra.model.MutatorImpl.execute(MutatorImpl.java:169)
at org.apache.qpid.server.store.CassandraMessageStore.addMessageContent(CassandraMessageStore.java:267)
at org.apache.qpid.server.store.CassandraMessageStore$StoredCassandraMessage.addContent(CassandraMessageStore.java:620)
at org.apache.qpid.server.queue.IncomingMessage.addContentBodyFrame(IncomingMessage.java:144)
at org.apache.qpid.server.AMQChannel.publishContentBody(AMQChannel.java:391)
at org.apache.qpid.server.protocol.AMQProtocolEngine.contentBodyReceived(AMQProtocolEngine.java:477)
at org.apache.qpid.framing.ContentBody.handle(ContentBody.java:83)
at org.apache.qpid.server.protocol.AMQProtocolEngine.frameReceived(AMQProtocolEngine.java:336)
at org.apache.qpid.server.protocol.AMQProtocolEngine.dataBlockReceived(AMQProtocolEngine.java:285)
at org.apache.qpid.server.protocol.AMQProtocolEngine$1.run(AMQProtocolEngine.java:256)
at org.apache.qpid.pool.Job.processAll(Job.java:110)
at org.apache.qpid.pool.Job.run(Job.java:149)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: InvalidRequestException(why:Expected 8 or 0 byte long (9))
at org.apache.cassandra.thrift.Cassandra$batch_mutate_result.read(Cassandra.java:16477)
at org.apache.cassandra.thrift.Cassandra$Client.recv_batch_mutate(Cassandra.java:916)
at org.apache.cassandra.thrift.Cassandra$Client.batch_mutate(Cassandra.java:890)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl$1.execute(KeyspaceServiceImpl.java:93)
... 25 more

me.prettyprint.hector.api.exceptions.HInvalidRequestException: InvalidRequestException(why:Expected 8 or 0 byte long (9))

We are getting the following kind of exception due to a small mistake that we do in creating column families in cassandra.

me.prettyprint.hector.api.exceptions.HInvalidRequestException: InvalidRequestException(why:Expected 8 or 0 byte long (9))
at me.prettyprint.cassandra.service.ExceptionsTranslatorImpl.translate(ExceptionsTranslatorImpl.java:42)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl$1.execute(KeyspaceServiceImpl.java:95)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl$1.execute(KeyspaceServiceImpl.java:88)
at me.prettyprint.cassandra.service.Operation.executeAndSetResult(Operation.java:101)
at me.prettyprint.cassandra.connection.HConnectionManager.operateWithFailover(HConnectionManager.java:156)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl.operateWithFailover(KeyspaceServiceImpl.java:129)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl.batchMutate(KeyspaceServiceImpl.java:100)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl.batchMutate(KeyspaceServiceImpl.java:106)
at me.prettyprint.cassandra.model.MutatorImpl$2.doInKeyspace(MutatorImpl.java:172)
at me.prettyprint.cassandra.model.MutatorImpl$2.doInKeyspace(MutatorImpl.java:169)
at me.prettyprint.cassandra.model.KeyspaceOperationCallback.doInKeyspaceAndMeasure(KeyspaceOperationCallback.java:20)
at me.prettyprint.cassandra.model.ExecutingKeyspace.doExecute(ExecutingKeyspace.java:72)
at me.prettyprint.cassandra.model.MutatorImpl.execute(MutatorImpl.java:169)
at org.apache.qpid.server.store.CassandraMessageStore.addMessageContent(CassandraMessageStore.java:267)
at org.apache.qpid.server.store.CassandraMessageStore$StoredCassandraMessage.addContent(CassandraMessageStore.java:620)
at org.apache.qpid.server.queue.IncomingMessage.addContentBodyFrame(IncomingMessage.java:144)
at org.apache.qpid.server.AMQChannel.publishContentBody(AMQChannel.java:391)
at org.apache.qpid.server.protocol.AMQProtocolEngine.contentBodyReceived(AMQProtocolEngine.java:477)
at org.apache.qpid.framing.ContentBody.handle(ContentBody.java:83)
at org.apache.qpid.server.protocol.AMQProtocolEngine.frameReceived(AMQProtocolEngine.java:336)
at org.apache.qpid.server.protocol.AMQProtocolEngine.dataBlockReceived(AMQProtocolEngine.java:285)
at org.apache.qpid.server.protocol.AMQProtocolEngine$1.run(AMQProtocolEngine.java:256)
at org.apache.qpid.pool.Job.processAll(Job.java:110)
at org.apache.qpid.pool.Job.run(Job.java:149)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: InvalidRequestException(why:Expected 8 or 0 byte long (9))
at org.apache.cassandra.thrift.Cassandra$batch_mutate_result.read(Cassandra.java:16477)
at org.apache.cassandra.thrift.Cassandra$Client.recv_batch_mutate(Cassandra.java:916)
at org.apache.cassandra.thrift.Cassandra$Client.batch_mutate(Cassandra.java:890)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl$1.execute(KeyspaceServiceImpl.java:93)
... 25 more

Monday, July 18, 2011

How to send filtered events from WSO2 Complex Event Processing Server to your mail box

Most important thing in complex event processing is the EVENT. It will be very useful if we can direct the filtered events to the email box of the user which the most frequently accessible thing in busy schedules even with their mobile phones.

If we take a simple example:

There is a person with very busy schedule , who used to place trades in Stock market with his mobile phone. But he has to keep his eye open on the stock prices in order to place a profitable order. With this WSO2 Complex Event Processing Server , we can make his life easy. What he has to do is, Configure the WSO2 Complex Event Processing Server to receive events stream from stock market and filter the events which will be worth to trade and send an e mail to the inbox of the user. Once the email is received to the inbox, user would get the alert and he will be able to place an order via his mobile phone.

With WSO2 Complex event processing server, it will be very easy for the user to direct filtered events to his/her mail box. There are only two steps.

Step 01 : Add mail transport sender to the axis2_client.xml file.

In order to do this place the following code segment in axis2_client.xml file in the "Transport Outs " section.

<transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender">
<parameter name="mail.smtp.from">synapse.demo.0@gmail.com</parameter>
<parameter name="mail.smtp.user">synapse.demo.0</parameter>
<parameter name="mail.smtp.password">mailpassword</parameter>
<parameter name="mail.smtp.host">smtp.gmail.com</parameter>
<parameter name="mail.smtp.port">587</parameter>
<parameter name="mail.smtp.starttls.enable">true</parameter>
<parameter name="mail.smtp.auth">true</parameter>
</transportSender>

Save the file and start the server.

Step 02:

Create the bucket in WSO2 Complex Event Processing server. You can find more information on
that here.

Create the output topic through the "Topics" menu of WSO2 Complex Event Processing Server and create a subscription by providing event sink URL as : "mailto:test@test.com". User can provide his email address here. Once this is done, user will get an email on any filtered event from his
CEP bucket.