Hello,
Thanks in advance for taking the time and effort to answer my question.
I'm trying to embed the
JBoss naming server in my own
Java application. I'm using the code from version 4.2.1.GA. I've thoroughly read the Java code, and found it a little confusing. Among other classes, I've read the code from org.jboss.naming.NamingService and org.jnp.server.Main. I've been trying for days with no luck. Here's a class from my simplest attempt:
// Server.java
package miaJs.server;
import org.apache.log4j.Logger;
import org.jboss.naming.NamingService;
import org.jnp.server.Main;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.impl.StdSchedulerFactory;
public class Server
{
/**
* Logger for this class.
*/
private static final Logger logger =
Logger.getLogger("miaJs.server.Server");
/**
* Start the server.
*/
public void start()
{
logger.debug("Server ClassLoader: " +
this.getClass().getClassLoader().getClass().getName());
try
{
logger.debug("Starting JBoss naming server...");
Main namingServer = new Main();
namingServer.start();
}
catch (Throwable t)
{
logger.error("Error starting Java Job Scheduler: " +
t.getMessage(),
t);
System.exit(1);
}
try
{
// Register a shutdown hook
ServerShutdownHook shutdownHook = new ServerShutdownHook();
Runtime.getRuntime().addShutdownHook(shutdownHook);
}
catch (Throwable t)
{
logger.error("Error adding server shutdown hook: " +
t.getMessage(),
t);
System.exit(1);
}
}
}
The above example gives me the following NullPointerException:
lljava.lang.NullPointerException
jvm 1 | at org.jnp.server.Main.getNamingInstance(Main.java:301)
wrapper | Pause reading child output to share cycles.
wrapperp | socket read failed. (An established connection was aborted by the software in your host machine. (0x2745
))
jvm 1 | at org.jnp.server.Main.initJnpInvoker(Main.java:354)
jvm 1 | at org.jnp.server.Main.start(Main.java:316)
jvm 1 | at miaJs.server.Server.start(Server.java:45)
jvm 1 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
jvm 1 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
jvm 1 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
jvm 1 | at java.lang.reflect.Method.invoke(Method.java:585)
wrapper | Pause reading child output to share cycles.
wrapperp | server listening on port 32000.
jvm 1 | at miaJs.server.Bootstrap.start(Bootstrap.java:135)
jvm 1 | at miaJs.server.Bootstrap.main(Bootstrap.java:76)
jvm 1 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
jvm 1 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
jvm 1 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
jvm 1 | at java.lang.reflect.Method.invoke(Method.java:585)
jvm 1 | at org.tanukisoftware.wrapper.WrapperStartStopApp.run(WrapperStartStopApp.java:238)
jvm 1 | at java.lang.Thread.run(Thread.java:595)
What I really want is an in-memory JNDI server that doesn't have external dependencies. I really hope the JBoss naming service can achieve this.
Thanks again,
Bob Pepersack