Jboss Clustering and Load Balancing

October 23, 2012 Comments off
Categories: General

OpenNMS Installation inUbuntu 10.04

October 23, 2012 Comments off

The below link worked well for me.

http://www.hatimonline.com/2012/07/opennms-on-ubuntu-1004-installation.html

For adding opennms repositories follow the below link

http://www.opennms.org/wiki/Installation:Debian

 

The only issue i faced while installation is below :

While performing the install ipLike step make sure the you have disabled the password for all user or posgres use for Posegre sql db.

 

Check this step in Allowing User Access to the Database section in the opennms forum.

Other than the lines mention in the site comment out every thing.

 

 

 

 

 

 

 

Categories: General

org.apache.cxf.binding.soap.SoapFault: The signature or decryption was invalid

October 12, 2012 Comments off

org.apache.cxf.binding.soap.SoapFault: The signature or decryption was
invalid; nested exception is:
org.apache.ws.security.WSSecurityException: The signature or
decryption was invalid
at
org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.createSoapFault(WSS4JInInterceptor.java:643)
at
org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.handleMessage(WSS4JInInterceptor.java:307)
at
org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.handleMessage(WSS4JInInterceptor.java:84)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:118)
at
org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:208)
at
org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223)
at
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:205)
at
org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:113)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:184)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:163)
at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at
org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)
at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
at
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:880)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:834)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
Caused by: org.apache.ws.security.WSSecurityException: The signature or
decryption was invalid; nested exception is:
org.apache.ws.security.WSSecurityException: The signature or
decryption was invalid
at
org.apache.ws.security.processor.SignatureProcessor.verifyXMLSignature(SignatureProcessor.java:378)
at
org.apache.ws.security.processor.SignatureProcessor.handleToken(SignatureProcessor.java:174)
at
org.apache.ws.security.WSSecurityEngine.processSecurityHeader(WSSecurityEngine.java:396)
at
org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.handleMessage(WSS4JInInterceptor.java:248)
… 28 more
Caused by: org.apache.ws.security.WSSecurityException: The signature or
decryption was invalid
at
org.apache.ws.security.processor.SignatureProcessor.verifyXMLSignature(SignatureProcessor.java:375)
… 31 more

SOLUTION::
*************
Thsi is a problem with inbuilt CXF v2.4.0. It contains
wss4j-1.6.0.jar:1.6.0. This needs to be replace with wss4j-1.6.3.jar.
This worked for me.

How to run multiple Jetty instances on a host with different ports

September 18, 2012 Comments off

My Goal is to run multiple instance of jetty on the different ports in the same machine.

Pre-Requsites :
Java Installation and JAVA_HOME Environment variable.
Now download the jetty server distributable and unzip(untar) to a directory.

First of all we need to know how jetty is getting started and the various inputs/arguments it needs while starting.

for this i have gone through jetty.sh provided with the distributable.

open the jetty.sh and goto line 474(in my distributable).

give echo RUN_CMD variable.This will show you the command formed before jetty start.

mine is like this

“/home/user/installables/jdk1.6.0_22/bin/java -Xmx1024m -Xms1024m -Djetty.home=/opt/jetty-6.1.14 -Djava.io.tmpdir=/tmp -jar /opt/jetty-6.1.14/start.jar /opt/jetty-6.1.14/etc/jetty-logging.xml /opt/jetty-6.1.14/etc/jetty.xml /opt/jetty-6.1.14/etc/jetty-ssl.xml”

now goto the etc folder

create a copy of jetty.xml and jetty-ssl.xml
create a copy of jetty-A.xml and jetty-ssl-A.xml

change the port number in jetty-A.xml to some other port
<Set name=”port”><SystemProperty name=”jetty.port” default=”7010″/></Set>

change the port number in jetty-ssl-A.xml to some other port
<New>
<Set name=”Port”>7444</Set>

Now create a sh file setup.sh

copy the exe command twice with the different arguments.
“$JAVA_HOME/bin/java -Xmx1024m -Xms1024m -Djetty.home=/opt/jetty-6.1.14 -Djava.io.tmpdir=/tmp -jar /opt/jetty-6.1.14/start.jar /opt/jetty-6.1.14/etc/jetty-logging.xml /opt/jetty-6.1.14/etc/jetty.xml /opt/jetty-6.1.14/etc/jetty-ssl.xml”
“$JAVA_HOME/bin/java -Xmx1024m -Xms1024m -Djetty.home=/opt/jetty-6.1.14 -Djava.io.tmpdir=/tmp -jar /opt/jetty-6.1.14/start.jar /opt/jetty-6.1.14/etc/jetty-logging.xml /opt/jetty-6.1.14/etc/jetty-A.xml /opt/jetty-6.1.14/etc/jetty-ssl-A.xml”

and now run the ./sh file.

two jetty instances will launched with corresponding ports.

Enjoy.

Categories: General Tags:

Free Website Infrastructure monitoring service

July 10, 2012 Comments off

Dear friends,

Let me take the privilege of introducing my Cloud based Website Monitoring Service MyMonitor.in.

With a simple sign-up u will be able to monitor your URL’s,Machine Ping and the Port

you can keep monitor your URLs,machines and device with ping and services like ssh,tomcat,jetty,apache,e.t.c with port monitoring.

This tool will send u mails when ever there is a problem with your infrastructure.

You can check the reports and in graph format by login to the website.

here you can access any number of URL’s any number of machines ping for free..

give a try and let me know your feed back.

URL : http://www.mymonitor.in

Categories: General

How to create SOAP web service client in java with cxf, Spring, Maven

July 9, 2012 Comments off

In continuation with my previous post i am showing a way how to invoke a SOAP service from java.

There are different ways to create a SOAP Clinet in java with cxf.Here im giving the most fastest and easiest way to create.

Get the wsdl URL form the server.

open up the pom.xml file.

Add the below wsdl-to-java plugin.This plugin will generate the java code by parsin the wsdl which is given as input to it.

<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>http://localhost:7009/cxf-spring-test/calculatorService?wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>

now open the commanprompt or terminal,navigate to the project

type mvn clean generate-sources

this will generate the wsdl correspondin code in the <Project Folder>/generated/cxf location.

Add this to the project build path.

now i am writing a simple class and wired to the bean in the application context

Application Context File:

<?xml  version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util" xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

<!-- Start up bean which will invoke server webservice -->
<bean id="calculatorService" init-method="invoke">
<constructor-arg index="0" value="http://localhost:7009/cxf-spring-test/calculatorService?wsdl"/>
</bean>

</beans>

Java Client Class(As per the above example this will get invoked automatically during start up)

package com.test;

import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;

public class CalculatorServiceClient
{
private String targetURL;

public CalculatorServiceClient(String targetURL)
{
this.targetURL = targetURL;
}

public void invoke()
{
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(CalculatorIntf.class);

factory.setAddress(this.targetURL);
CalculatorIntf calculatorIntf = (CalculatorIntf) factory.create();

//invoking add web servcie
System.out.println("10 + 15 = "+calculatorIntf.add(10, 15));

//invoking subtract web service
System.out.println("15 - 5 = "+calculatorIntf.subtract(15, 5));

//invoking multiply web service
System.out.println("10 * 5 = "+calculatorIntf.multiply(10,5));
}
}

In the next post i will show how to add SSL Support to the above client code.

Source Code Download : cxf_spring_maven.zip

Categories: Web Services

How to create SOAP WebService with spring, cxf, Maven, Java

July 7, 2012 2 comments

Steps to create MAVEN SOAP Based Web Service with Eclipse.

Pre-Requsites :

  1. Java >= 1.5 version
  2. Maven installation
  3. Eclipse Maven Plugin

Steps to create :

Create a new Maven Project with packaging type as war

open the pom file and maven and spring dependencies

pom.xml file


4.0.0
com.test
cxf-spring-test
0.1
war

UTF-8
3.0.5.RELEASE
1.6.4
2.4.1

maven2-repository.java.net
Java.net Repository for Maven
http://download.java.net/maven/2/
default

${project.artifactId}

maven-compiler-plugin
2.3.2

1.6
1.6

org.mortbay.jetty
jetty-maven-plugin
7.4.2.v20110526

10

7009

/${project.artifactId}

<!-- CXF Dependencies -->

jta
jta
1.0.1b

org.apache.cxf
cxf-rt-core
${cxf.version}

org.apache.cxf
cxf-rt-frontend-simple
${cxf.version}

org.apache.cxf
cxf-rt-frontend-jaxws
${cxf.version}

org.apache.cxf
cxf-rt-databinding-aegis
${cxf.version}

org.apache.cxf
cxf-rt-transports-local
${cxf.version}

org.apache.cxf
cxf-rt-transports-http
${cxf.version}

org.apache.cxf
cxf-rt-transports-http-jetty
${cxf.version}

org.apache.cxf
cxf-rt-transports-jms
${cxf.version}

org.apache.cxf
cxf-rt-management
${cxf.version}

org.apache.cxf
cxf-common-utilities
${cxf.version}

<!-- End of CXF Dependencies -->

org.eclipse.jetty
jetty-servlets
7.4.0.v20110414
provided

org.eclipse.jetty
jetty-client

<!-- Spring Dependencies ${spring.version} -->

org.springframework
spring-beans
${spring.version}

org.springframework
spring-jdbc
${spring.version}

org.springframework
spring-web
${spring.version}

org.springframework
spring-webmvc
${spring.version}

org.springframework
spring-orm
${spring.version}

org.springframework
spring-expression
${spring.version}

org.apache.geronimo.specs
geronimo-annotation_1.0_spec
1.1.1

org.slf4j
slf4j-log4j12
${slf4j.version}
jar
compile

Create a web.xml file in src/main/webapp/WEB-INF folder

In the web.xml mention the servlet mapping for cxf servlet and add spring listner to load the application context during the webapp startup time.

Web.Xml file

<!--?xml version="1.0" encoding="UTF-8"?-->

<!-- Servlet Mapping for CXFServlet -->

CXFServlet
org.apache.cxf.transport.servlet.CXFServlet

CXFServlet
/*

<!-- Context parameters -->

log4jConfigLocation
classpath:sitemonitor_log4j.properties

log4jExposeWebAppRoot
false

		org.springframework.web.util.Log4jConfigListener

contextConfigLocation
classpath:sitemonitor_appContext.xml

		org.springframework.web.context.ContextLoaderListener

Now create a package in the src/main/java folder as mentioned in the pom file

create a interface with the service you want to expose

package com.test;

import javax.jws.WebService;

@WebService
public interface CalculatorIntf
{
public long add(long num1,long num2);

public long subtract(long num1,long num2);

public long multiply(long num1,long num2);
}

Create a inplementation for this service and implement all the methods of the interface

package com.test;

public class CalculatorImpl implements CalculatorIntf
{
public long add(long num1, long num2)
{
return (num1 + num2);
}

public long subtract(long num1, long num2)
{
return (num1 - num2);
}

public long multiply(long num1, long num2)
{
return (num1 * num2);
}

}

create a spring application context file and add the file to the application class path.

Application Context file

<!--?xml   version="1.0" encoding="UTF-8"?-->

<!-- Initiliaing Client Webservices -->

<!-- JAX-WS Service Endpoint -->

now open the command prompt and navigate to the porject folder in the command prompt

run the maven command : mvn clean package jetty:run -DskipTests (for running the inbuild jetty we need to add this in the pom file.In the above pom has that jetty plugin)

now open the browser and hit http://localhost:7009/cxf-spring-test

now you should see the wsdl link.click on the wsdl link will show you the wsdl file.

you can test the service with soap-ui.

In the comming post i will post how to invoke this wsdl from the java program.

Categories: Web Services
%d bloggers like this: