Tuesday, November 20, 2012

Library not found: tibrvj

if you come across the below exception while connecting to Tibco RV then you could try follow below steps if that helps.

Caused by: TibrvException[error=901,message=Library not found: tibrvj]
at com.tibco.tibrv.Tibrv.loadLib(Tibrv.java:449)


This  happens because of Tibrv.open(Tibrv.IMPL_NATIVE); line in tibrvj java API code

 1. This means it could not find tibrvj.dll (and its dependent dlls from classpath setting)
 2. Not sure why such dependency when a standalone Java code wanted to establish a connection with Tibco RV for sending & receiving messages.
 3. If you have the Tibco RV installed on the same m/c, well then you can point to the bin directory of the installation and give that location in PATH variable
 4. if you don't have that installed and you wanted to connect to remote Tibco RV (running on different m/c) then you could copy the whole bin folder from the installation package & keep it on the local m/c where you are running the Java client code and configure the PATH setting.
 5.  Finally, if you want to connect to remote Tibco RV, you could try configuring the TibrvRvdTransport object with below parameter and mention the remote host where the daemon is running.

String service ="7500";
String network="";
String daemon="hostname:7500";
transport = new TibrvRvdTransport(service,network,daemon);






Tuesday, December 20, 2011

Understanding scoped-proxy in spring framework

Let say there are two classes, namely SingletonBean and PrototypeBean class, where prototype bean reference is kept inside the singleton bean. And as the name suggests, SingletonBean is specified with "singleton" scope and "prototype" scope for PrototypeBean. Now if we access the singleton bean using the application context, it will create single instance all times. However if we access the prototype bean reference using the singleton bean reference it will also show single instance all times because it has been wrapped inside the singleton bean, which is an expected behaviour under singleton pattern scenario. But we specified the prototype scope in PrototypeBean and if we wanted to return a new PrototypeBean object every time when we access using the singleton reference(getPrototypeBean()) then we need to specify the prototype bean additionally using

or @Scope(value="prototype", proxyMode=ScopedProxyMode.TARGET_CLASS) as annotation.

Following example -

@Component

@Scope(value="singleton")

public class SingletonBean {


@Autowired

private PrototypeBean prototypeBean;
/**

*

*/

public SingletonBean() {



}

public PrototypeBean getPrototypeBean()
{

return prototypeBean;

}

public void
setPrototypeBean(PrototypeBean prototypeBean) {


this.prototypeBean = prototypeBean;
}

}


@Component

@Scope(value="prototype",
proxyMode=ScopedProxyMode.TARGET_CLASS)


public class PrototypeBean {


/**

*

*/

public PrototypeBean() {



}


}


When we test these beans after wiring them in xml file (using component-scan), we
find below results -

SingletonBean singletonBean = (SingletonBean)container.getBean("singletonBean");
System.out.println("singleton instance :"+singletonBean); //container.bean.SingletonBean@2200d5
System.out.println("prototype instance :"+singletonBean.getPrototypeBean()); //container.bean.PrototypeBean@df1832

singletonBean = (SingletonBean)container.getBean("singletonBean");
System.out.println("singleton instance :"+singletonBean); //container.bean.SingletonBean@2200d5
System.out.println("prototype instance :"+singletonBean.getPrototypeBean());//container.bean.PrototypeBean@ad8659

Wednesday, March 3, 2010

JGroups

To implement fail-over operation in java application, you can easily use jgroups (www.jgroups.org) library. If your application is not a J2EE based architecture (basically EJB containers involved) and its a POJOs based then JGroups will be the best fit for detecting node addition and deletion scenarios (may be one of the best available options).