Access to sdk throws hibernate.cfg.xml not found error
Status: Beta
Brought to you by:
akutz
Ubuntu Jaunty (9.04), Tomcat 6.0 web server, MySql 5.1.31
1. Create database
2. Change hibernate.cfg.xml to point it to local database, provide auth info
3. Run db.sh & check if db was populated (encountered jvm heap related error, fixed it by reducing size to 1024 in the shell script)
4. Deploy simdk-ws-0.0.1-SNAPSHOT.war using Tomcat manager
5. Start tomcat server
6. Copy hibernate.cfg.xml to /etc/simdk (also copied it at conf folder in tomcat top dir)
7. Try to access system with vCenter power shell (also tried accessing http://localhost:8080/simdk-ws-0.0.1-SNAPSHOT/sdk url)
1. Connection using power shell failed.
2. Access to above mentioned url resulted into a result page (see attachment)
Error
I also experienced this, and debugged it by starting Tomcat with the following JVM arguments:
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7777
creating an IntelliJ IDEA project with the correct source and library dependencies, and then attaching to port 7777 via IDEA's debugger. It seems that http://simdk.sourceforge.net/installing.html is missing some instructions which are detailed here:
http://akutz.wordpress.com/2010/03/11/a-simdk-virtual-appliance/
but strangely there is no link from the main site to this blog post. I think it's necessary to ensure that /etc/simdk contains not only hibernate.cfg.xml but also the 4 files from the conf/ subdirectory of the release. These are also in svn under:
https://simdk.svn.sourceforge.net/svnroot/simdk/trunk/ws/src/main/webapp/conf
This is because the code first tries to locate a config directory. If /etc/simdk is readable, it will use that. Then it looks for security.config in the located directory, and if it cannot find it, this code in ws/src/main/java/com/hyper9/simdk/ws/InitApplicationServlet.java:
private void initJaas()
{
String path =
ConfigFileUtil.getFile("security.config").getAbsolutePath();
System.getProperties().put("java.security.auth.login.config", path);
}
will cause the following:
java.lang.NullPointerException
at com.hyper9.simdk.ws.InitApplicationServlet.initJaas(InitApplicationServlet.java:151)
at com.hyper9.simdk.ws.InitApplicationServlet.init(InitApplicationServlet.java:77)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1172)
[...]
This then aborts servlet initialization, which means the database layer never gets initialized properly. So you should look in your tomcat logs for strings like the following
error getting config dir=
using configuration directory=
error getting file=
error initializing