tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Keulkeul <>
Subject Starting OpenEJB server from a java code.
Date Fri, 24 Jul 2009 12:24:50 GMT


I'm starting an OPENEJB Server from a Java application thanks to
RemoteServer class (located into the org.apache.openejb.config package). In
fact, RemoteServer is a kind of wrapper which made a
Runtime.getRuntime().exec(args) with openejb-core.jar file to execute

Below, the code to start server

System.setProperty("openejb.home", "D:/OSGi/openejb-3.1.1");
String[] param = new String[1];
param[0] = "start";

I can list the EJB sessions available from the current Context like this:

Properties props = new Properties();
props.put(Context.PROVIDER_URL, "httpejbd://");
Context ctx = new InitialContext(props);
NamingEnumeration<NameClassPair> list = ctx.list("");
while (list.hasMore()) {
	System.out.println("name: " +;

Also, i can stop the current OPENEJB Server like this

param = new String[1];
param[0] = "stop";

So, i can restart a new OPENEJB Server according to the same configuration.

param = new String[1];
param[0] = "start";

But, now when i would like to list the EJB sessions (see previous code) from
the new instance of OPENEJB Server, i have a RuntimeException exception
which is throwned (java.lang.RuntimeException: Invalid response from server

In fact, when a restart an OPENEJB Server in a same instance of JVM it
does'nt working.

I have checked this new OPENEJB Server with a new Java program (so a new
instance of JVM) and it is working.

It is important to note that i need to start an OpenEJB Server like this
because i need to deploy and undeploy EJBs. These EJBs are not located into
the same applications.

Any idea about this issue ?

Best regards

View this message in context:
Sent from the OpenEJB User mailing list archive at

View raw message