I managed to get the basic example to run in both Eclipse and Intellij IDEA
after some effort troubleshooting.
Here are observations on the docs/tutorial info that were confusing or
incorrect.
I pulled down the distro and expanded into /appdev, cd
/appdev/apache-empire-db-2.1.0-incubating/src, and then ran mvn idea:idea. The
project opened in Intellij IDEA, ran SampleApp.java... gives an error saying it
cannot get the config value for empireDBDriverClass which suggests config.xml
file was found, but can't load that node.
I switched to Eclipse since the docs mention it specifically....
The website Getting started and Tutorial instructions incorrectly say to import
empire-db-2.0.0/examples/DBSample which does not exist in the 2.1 distro. The
Tutorial PDF inside the distro is more accurate for the path, but says to use
mvn eclipse:eclipse, but the README.txt says "mvn clean install" to build and
"mvn clean eclipse:eclipse -DdownloadSources=true" - so I did both steps.
I imported the projects Eclipse, but it complained of a missing "M2_REPO"
variable. I googled and fixed and the sample ran!
I went back to Intellij IDEA, and on a hunch checked the working directory. It
was set to the root of the src folder, so I set it to empire-db-example-basic.
The sample ran fine! :-)
I guessed that the config.xml wasn't actually loading, but the error is
misleading. I reviewed XMLConfiguration.java, line 114, FileNotFoundException,
but since log4j reported a problem initializing, I added a System.out.println()
and re-ran - it printed that config.xml was not found.
Suggestions:
* update the Tutorial and Getting Started docs to align with the current release
* maybe add a footnote for Intellij users to make sure to set the working
directory so the config.xml is loaded.
* Review logging setup - since until config is loaded, the log system isn't
init'd so the log message about not being able to load the file fails.
Cheers!
-Tim
Intellij IDEA -- error....
log4j:WARN No appenders could be found for logger
(org.apache.empire.commons.ErrorType).
log4j:WARN Please initialize the log4j system properly.
Running DB Sample...
*** Step 1: getJDBCConnection() ***
*** Step 2: getDatabaseProvider() ***
java.lang.RuntimeException: Configuration error: Element 'empireDBDriverClass'
not found in node 'properties-hsqldb'
at
org.apache.empire.samples.db.SampleApp.getDatabaseDriver(SampleApp.java:201)
at org.apache.empire.samples.db.SampleApp.main(SampleApp.java:85)
java.lang.RuntimeException: java.lang.RuntimeException: Configuration error:
Element 'empireDBDriverClass' not found in node 'properties-hsqldb'
java.lang.RuntimeException: java.lang.RuntimeException: Configuration error:
Element 'empireDBDriverClass' not found in node 'properties-hsqldb'
at
org.apache.empire.samples.db.SampleApp.getDatabaseDriver(SampleApp.java:221)
at org.apache.empire.samples.db.SampleApp.main(SampleApp.java:85)
Caused by: java.lang.RuntimeException: Configuration error: Element
'empireDBDriverClass' not found in node 'properties-hsqldb'
at
org.apache.empire.samples.db.SampleApp.getDatabaseDriver(SampleApp.java:201)
... 1 more