-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: Java Web Start NullPointerException
PostPosted: Tue Aug 01, 2006 5:45 pm 
Newbie

Joined: Tue Aug 01, 2006 5:35 pm
Posts: 4
I am getting the following error in the console when launching my app using Java Web Start (runs fine from the desktop). My JNLP file has

<security>
<all-permissions/>
</security>

I am using EntityManager 3.2.0 CR1 , Hibernate Core 3.2 CR2, Annotations 3.2.0.CR1.

Is there a help page for using Web Start with Hibernate EJB3 Persistence? Why is it unable to read my jar from the cache -- is Hibernate doing some file access that is outside of the security allowed by web start? Thanks,

Mark

log4j:WARN No appenders could be found for logger (org.hibernate.ejb.Version).
log4j:WARN Please initialize the log4j system properly.
javax.persistence.PersistenceException: java.security.AccessControlException: access denied (java.io.FilePermission C:\Documents%20and%20Settings\merickson\Application%20Data\Sun\Java\Deployment\cache\javaws\http\Dtestserver\P80\DMjavalib\java-XMnb-ejb-whitepine.jar29246tmp read)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:217)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
at com.nbbs.application.ApplicationEntityManager.connect(ApplicationEntityManager.java:48)
at com.nbbs.application.ApplicationManager.connect(ApplicationManager.java:63)
at com.nbbs.application.machines.receiving.swing.Main.main(Main.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.continueLaunch(Unknown Source)
at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)
at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied (java.io.FilePermission C:\Documents%20and%20Settings\merickson\Application%20Data\Sun\Java\Deployment\cache\javaws\http\Dtestserver\P80\DMjavalib\java-XMnb-ejb-whitepine.jar29246tmp read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkRead(Unknown Source)
at java.io.File.isDirectory(Unknown Source)
at org.hibernate.ejb.packaging.JarVisitor.getVisitor(JarVisitor.java:83)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:189)
... 16 more


Last edited by merickson on Wed Aug 02, 2006 4:27 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 02, 2006 2:19 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
I think that almost in all cases you need a certificate. And <all-permission> is not replacing that. I think it just says when you are certified, that you can do whatever you want.
If you look at the cause - it is thrown when looking at the File - permission to browse your file system. That definitely needs authorized permission.

I did a couple of JWS and I always had certificate - mostly made my own with keytool.

Rgds, Ales


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 02, 2006 10:18 am 
Newbie

Joined: Tue Aug 01, 2006 5:35 pm
Posts: 4
Hello Ales,

Do you mean that you sign the jars before deploying them? I am doing that. I've used web start successfully before, but after migrating over to Hibernate persistance I am getting this error.

After clearing out my web start cache and trying again, I'm actually getting a different error now. Has anyone been able to successfully deploy an app using EntityManager 3.2.0 CR1 and JWS? It would be nice to know if it has been done. Thanks,

Mark


javax.persistence.PersistenceException: java.lang.NullPointerException
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:217)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
...
Caused by: java.lang.NullPointerException
at java.io.File.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at org.hibernate.ejb.packaging.FileZippedJarVisitor.doProcessElements(FileZippedJarVisitor.java:34)
at org.hibernate.ejb.packaging.JarVisitor.getMatchingEntries(JarVisitor.java:208)
at org.hibernate.ejb.Ejb3Configuration.addMetadataFromVisitor(Ejb3Configuration.java:223)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:200)
... 16 more


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 02, 2006 4:52 pm 
Newbie

Joined: Tue Aug 01, 2006 5:35 pm
Posts: 4
I'm trying to isolate the problem. I am using the following seemingly simple code snippet. Is there a problem referencing the META-INF/persistence.xml file through ClassLoader.getResource() in JWS? I've spent a good day on this now, if anyone can at least give me a "yes, I've done it, it should work", at least I'll know that it's possible. Otherwise, should it be submitted as a JIRA issue with Hibernate EntityManager? Thanks,

Mark

EntityManager em;

try {
// get a new entity manager factory
Map<String, String> properties = new HashMap<String, String>();
properties.put("hibernate.connection.driver_class", "net.sourceforge.jtds.jdbc.Driver");
properties.put("hibernate.connection.url", "jdbc:jtds:sqlserver://dbserver/testdb;tds=8.0;lastupdatecount=true");
properties.put("hibernate.connection.username", "xxxxxxx");
properties.put("hibernate.connection.password", "xxxxxxx");
properties.put("hibernate.show_sql", "false");
EntityManagerFactory emf = Persistence.createEntityManagerFactory("ejb-test", properties);

// test properties
em = emf.createEntityManager();
Query q = em.createQuery("select a from Account a where a.id = 10");
List<Account> list = q.getResultList();
Account a = list.get(0);
em.close();
System.err.println("list size = " + list.size());
System.err.println("accountType = " + a.getAccountType());
System.err.println("name = " + a.getName());

// close the factory
emf.close();
}
catch (Exception e) {
throw new RuntimeException(e);
}

which produces the following exception in Java Web Start (works fine from desktop):

java.lang.RuntimeException: javax.persistence.PersistenceException: java.lang.NullPointerException
at hibernatetest.Main.<init>(Main.java:61)
at hibernatetest.Main.main(Main.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.continueLaunch(Unknown Source)
at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)
at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.persistence.PersistenceException: java.lang.NullPointerException
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:217)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
at hibernatetest.Main.<init>(Main.java:45)
... 12 more
Caused by: java.lang.NullPointerException
at java.io.File.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at org.hibernate.ejb.packaging.FileZippedJarVisitor.doProcessElements(FileZippedJarVisitor.java:34)
at org.hibernate.ejb.packaging.JarVisitor.getMatchingEntries(JarVisitor.java:208)
at org.hibernate.ejb.Ejb3Configuration.addMetadataFromVisitor(Ejb3Configuration.java:223)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:200)
... 15 more


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 02, 2006 6:53 pm 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Debug?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 03, 2006 3:08 pm 
Newbie

Joined: Tue Aug 01, 2006 5:35 pm
Posts: 4
I turned on Debugging and here is what I get:

INFO - Hibernate EntityManager 3.2.0.CR1
INFO - Hibernate Annotations 3.2.0.CR1
INFO - Hibernate 3.2 cr2
INFO - hibernate.properties not found
INFO - Bytecode provider name : cglib
INFO - using JDK 1.4 java.sql.Timestamp handling
DEBUG - Trying to find persistence unit: ejb-test
DEBUG - Analyse of persistence.xml: jar:file:C:/Documents%20and%20Settings/merickson/application%20data/Sun/Java/Deployment/cache/javaws/http/Dtestserver/P80/DMjws/DMHibernateTest/DMlib/RMejb-test.jar!/META-INF/persistence.xml
DEBUG - Persistent Unit name from persistence.xml: ejb-test
DEBUG - Detect class: true; detect hbm: true
DEBUG - Archive to be processed by hibernate Entity Manager implementation found
DEBUG - Searching mapped entities in jar/par: file:C:/Documents%20and%20Settings/merickson/application%20data/Sun/Java/Deployment/cache/javaws/http/Dtestserver/P80/DMjws/DMHibernateTest/DMlib/RMejb-test.jar
DEBUG - Persistence unit name: ejb-test
DEBUG - emname:ejb-test metadata: ejb-test
#### Java Web Start Error:
#### javax.persistence.PersistenceException: java.lang.NullPointerException


The exception's stack trace is:



java.lang.RuntimeException: javax.persistence.PersistenceException: java.lang.NullPointerException
at hibernatetest.Main.<init>(Main.java:61)
at hibernatetest.Main.main(Main.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.continueLaunch(Unknown Source)
at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)
at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.persistence.PersistenceException: java.lang.NullPointerException
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:217)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
at hibernatetest.Main.<init>(Main.java:45)
... 12 more
Caused by: java.lang.NullPointerException
at java.io.File.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at org.hibernate.ejb.packaging.FileZippedJarVisitor.doProcessElements(FileZippedJarVisitor.java:34)
at org.hibernate.ejb.packaging.JarVisitor.getMatchingEntries(JarVisitor.java:208)
at org.hibernate.ejb.Ejb3Configuration.addMetadataFromVisitor(Ejb3Configuration.java:223)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:200)
... 15 more


Top
 Profile  
 
 Post subject: Re: Java Web Start NullPointerException
PostPosted: Fri May 22, 2009 8:59 pm 
Newbie

Joined: Wed Feb 07, 2007 3:43 pm
Posts: 2
Any solution or suggestions to this issue? The application eventually executes after minutes, but I'm getting errors.

I'm Running:

INFO: Hibernate Annotations 3.4.0.GA
INFO: Hibernate 3.3.0.SP1
INFO: hibernate.properties not found
INFO: Bytecode provider name : javassist
INFO: Hibernate Commons Annotations 3.1.0.GA
INFO: Hibernate EntityManager 3.4.0.GA

I signed my jars and added the security tags to my jnlp file:
<security>
<all-permissions/>
</security>

I'm having a similar problem. My app functions properly if I run it locally with javaws, but if I post it to a site and launch it from the site I get the error:

at org.hibernate.ejb.packaging.JarVisitorFactory.getBytesFromInputStream(JarVisitorFactory.java:146)
at org.hibernate.ejb.packaging.InputStreamZippedJarVisitor.doProcessElements(InputStreamZippedJarVisitor.java:81)
at org.hibernate.ejb.packaging.AbstractJarVisitor.getMatchingEntries(AbstractJarVisitor.java:139)
at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:287)
at org.hibernate.ejb.Ejb3Configuration.addMetadataFromVisitor(Ejb3Configuration.java:282)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:247)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:125)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)

at edu.fullcoll.timekeeper.tkstation.dataaccess.ClassJpaController.<init>(ClassJpaController.java:26)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:83)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:911)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:873)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)
- locked <0x24bac700> (a java.util.concurrent.ConcurrentHashMap)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:413)
- locked <0x24bac950> (a java.util.concurrent.ConcurrentHashMap)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:735)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:369)
- locked <0x24b90b00> (a java.lang.Object)
at edu.fullcoll.timekeeper.tkstation.display.TimeKeeperApplication$3.run(TimeKeeperApplication.java:622)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Any help would be greatly appreciated! Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.