Running examples inside Eclipse
saltnlight5 Jan 23, 2010 7:44 PMHi,
I finds it helpful to be able to run the examples inside Eclipse, but the current source only setup to be runnable with ant on a shell. I have modified the HornetQExample base class that allows me to do so. Would you have better suggestion?
1. Import 2.0.0.GA source into Eclipse
2. Modify this file as displayed here:
$ svn diff examples/common/src/org/hornetq/common/example/HornetQExample.java
Index: examples/common/src/org/hornetq/common/example/HornetQExample.java
===================================================================
--- examples/common/src/org/hornetq/common/example/HornetQExample.java (revision 8843)
+++ examples/common/src/org/hornetq/common/example/HornetQExample.java (working copy)
@@ -53,14 +53,21 @@
serverClasspath = System.getProperty("hornetq.example.server.classpath");
boolean runServer = runServerProp == null ? true : Boolean.valueOf(runServerProp);
logServerOutput = logServerOutputProp == null ? false : Boolean.valueOf(logServerOutputProp);
- serverProps = System.getProperty("hornetq.example.server.args");
+ serverProps = System.getProperty("hornetq.example.server.args", "");
if (System.getProperty("hornetq.example.server.override.args") != null)
{
serverProps = System.getProperty("hornetq.example.server.override.args");
}
System.out.println("serverProps = " + serverProps);
HornetQExample.log.info("hornetq.example.runServer is " + runServer);
-
+
+ String inheritProp = System.getProperty("hornetq.example.server.inherit.classpath", "false");
+ if (Boolean.valueOf(inheritProp))
+ {
+ String sep = System.getProperty("path.separator");
+ serverClasspath = serverClasspath + sep + System.getProperty("java.class.path");
+ }
+
this.configs = configs;
try
@@ -130,7 +137,7 @@
protected InitialContext getContext(final int serverId) throws Exception
{
- String jndiFilename = "server" + serverId + "/client-jndi.properties";
+ String jndiFilename = configs[serverId] + "/client-jndi.properties";
File jndiFile = new File(jndiFilename);
HornetQExample.log.info("using " + jndiFile + " for jndi");
Properties props = new Properties();
3. In Eclipse right click /trunk/examples/jms/queue/src/org/hornetq/jms/example/QueueExample.java and go menu Run As > Run Configuraton ...
3a. Create New or select QueueExample Configuraton
3b. In Arguments Tab, enter:
Program arguments:
${project_loc}/examples/jms/queue/server0
VM arguments:
-Dhornetq.example.server.inherit.classpath=true
3c. Click Run button
I get these console output:
Jan 23, 2010 7:28:51 PM org.hornetq.common.example.HornetQExample run
INFO: hornetq.example.runServer is true
Jan 23, 2010 7:28:51 PM org.hornetq.common.example.HornetQExample startServer
INFO: starting server with config 'C:\source\hornetq\HornetQ_2_0_0_GA/examples/jms/queue/server0' logServerOutput false
serverProps =
HornetQServer_0 err:Jan 23, 2010 7:28:53 PM org.hornetq.core.logging.impl.JULLogDelegate info
HornetQServer_0 err:INFO: live server is starting..
HornetQServer_0 err:Jan 23, 2010 7:28:53 PM org.hornetq.core.logging.impl.JULLogDelegate warn
HornetQServer_0 err:WARNING: AIO wasn't located on this platform, it will fall back to using pure Java NIO. If your platform is Linux, install LibAIO to enable the AIO journal
HornetQServer_0 err:Jan 23, 2010 7:28:53 PM org.hornetq.core.logging.impl.JULLogDelegate info
HornetQServer_0 err:INFO: Using NIO Journal
HornetQServer_0 err:Jan 23, 2010 7:28:53 PM org.hornetq.core.logging.impl.JULLogDelegate warn
HornetQServer_0 err:WARNING: Security risk! It has been detected that the cluster admin user and password have not been changed from the installation default. Please see the HornetQ user guide, cluster chapter, for instructions on how to do this.
HornetQServer_0 err:Jan 23, 2010 7:28:53 PM org.hornetq.core.logging.impl.JULLogDelegate warn
HornetQServer_0 err:WARNING: Binding for /ConnectionFactory already exists
HornetQServer_0 err:Jan 23, 2010 7:28:53 PM org.hornetq.core.logging.impl.JULLogDelegate warn
HornetQServer_0 err:WARNING: Binding for java:/ConnectionFactory already exists
HornetQServer_0 err:Jan 23, 2010 7:28:53 PM org.hornetq.core.logging.impl.JULLogDelegate warn
HornetQServer_0 err:WARNING: Binding for java:/XAConnectionFactory already exists
HornetQServer_0 err:Jan 23, 2010 7:28:53 PM org.hornetq.core.logging.impl.JULLogDelegate warn
HornetQServer_0 err:WARNING: There is no connector with name 'netty-connector' deployed.
HornetQServer_0 err:Jan 23, 2010 7:28:53 PM org.hornetq.core.logging.impl.JULLogDelegate warn
HornetQServer_0 err:WARNING: Unexpected Netty Version was expecting @NETTY.VERSION@ using 3.1.5.GA-r1772
HornetQServer_0 err:Jan 23, 2010 7:28:53 PM org.hornetq.core.logging.impl.JULLogDelegate info
HornetQServer_0 err:INFO: Started Netty Acceptor version 3.1.5.GA-r1772
HornetQServer_0 err:Jan 23, 2010 7:28:53 PM org.hornetq.core.logging.impl.JULLogDelegate info
HornetQServer_0 err:INFO: HornetQ Server version 2.0.0.GA (Hornet Queen, 113) started
Jan 23, 2010 7:28:53 PM org.hornetq.common.example.HornetQExample getContext
INFO: using C:\source\hornetq\HornetQ_2_0_0_GA\examples\jms\queue\server0\client-jndi.properties for jndi
Jan 23, 2010 7:28:54 PM org.hornetq.core.logging.impl.JULLogDelegate warn
WARNING: Unexpected Netty Version was expecting @NETTY.VERSION@ using 3.1.5.GA-r1772
Sent message: This is a text message
Received message: This is a text message
example complete
#####################
### SUCCESS! ###
#####################