UPDATE 2: Tested this on a Ubuntu 12.04 Virtual Machine on VMWare player so issue might be with my Ubuntu workstation.
UPDATE 1: I tested this on windows 7 and an installed version works there so I submitted this as a bug report to netbeans. http://netbeans.org/bugzilla/show_bug.cgi?id=217699
ORIGINAL QUESTION
My NetBeans Platform application which uses JPA with embedded Derby will work when I launch it out of the NetBeans 7.2 IDE but when I create the linux installer for Ubuntu 12.04 and install, the installed app will not create my database in the derby home directory which I set to System.getProperty("user.home")
.
Basically, it works great in the IDE but I have issues getting the entity manager when launching the nb platform deployed version. I've tried installing with sudo which defaults into /usr/local/myapp and also changed the permissions for the database temporarily to 777 for the install dir but this did not help. There doesn't not seem to be any logging directory to see what might have failed. I fear that the exceptions or error messages are being eaten by the Netbeans Platform.
Hoping a NetBeans Platform or embedded derby person can share some advise on troubleshooting this.
Here is my persistance.xml which is a wrapped jar in my netbeans platform app
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="VmCfgLibPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>mycompany.jpa.Vmcfg</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:derby:myDB;create=true"/>
<property name="javax.persistence.jdbc.password" value="app"/>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
<property name="javax.persistence.jdbc.user" value="app"/>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
Here is my Utils class that i used to get the entity manager. The lines after em = emf.createEntityManager();
do not execute and no exception is thrown.
public class Util {
static public EntityManager getEm() {
return getEntityManager();
}
static public EntityManager em;
static public EntityManager getEntityManager() {
if (em == null || em.isOpen() == false) {
try {
File homeDir = new File(System.getProperty("user.home")+"/.simdriver");
homeDir.mkdirs();
Msg.info("home dir is: "+homeDir.getAbsolutePath());
System.setProperty("derby.system.home", homeDir.getAbsolutePath());
EntityManagerFactory emf
= Persistence.createEntityManagerFactory("VmCfgLibPU");
Msg.info("Check B2");
System.out.println("Check B2");
// .createEntityManager() does not execute when formally installed
// works when running in IDE
em = emf.createEntityManager();
Msg.info("Check C2");
System.out.println("Check C2");
} catch (Exception e) {
Exceptions.printStackTrace(e);
Msg.err("Error while getting entity manager");
}
}
return em;
}
}