java - How registry JNDI datasource for JUnit for Jboss environment -


project use hibernate , deployed on jboss 5.1. hibernate uses jndi datasource.

i want create junit tests dao layer , need create jndi data source , transaction manager test without running jboss.

for wrote code:

system.out.println(locateregistry.getregistry()); registry reg = locateregistry.createregistry(1099);   properties properties = new properties(); properties.put(context.initial_context_factory, "org.jnp.interfaces.namingcontextfactory"); properties.put(context.url_pkg_prefixes, "org.jboss.naming"); properties.put(context.provider_url, "localhost:1099");  initialcontext initialcontextcontext = new initialcontext(properties); 

when try lookup or bind named object application frizz. , after time throw timeout exception. bind subcontext throws same exception

in maven include dependency:

  <groupid>org.jboss.client</groupid>   <artifactid>jbossall-client</artifactid>   <version>4.2.3.ga</version> 

after research have faced article http://something-about-tech.blogspot.com/2008/12/injecting-jndi-datasource-for-junit.html . there line registry reg = locateregistry.createregistry(1099); missed.. in confusion...

in related post (registering mysql datasource jndi hibernate) have interested registry datasource there

context.initial_context_factory="com.sun.jndi.rmi.registry.registrycontextfactory" 

please help.

org.jnp.interfaces.namingcontextfactory jboss specific protocol, cannot use connect rmi registry. try test

public class test1 implements serializable, remote {      public static void main(string[] args) throws exception {         registry reg = locateregistry.createregistry(1099);         context ctx = new initialcontext();         ctx.bind("rmi://localhost/xxx", new test1());         test1 t1 = (test1) ctx.lookup("rmi://localhost/xxx");         system.out.println(t1);     } } 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -