I am using Hibernate-EntityManager 3.2.1 and JBoss 4.0.4 GA
I tried to use EntityManager in SE environment. Here is my code:
properties = new Properties();
properties.put("hibernate.connection.url", "jdbc:oracle:thin:@localhost:1521:db");
properties.put("hibernate.connection.driver_class", "oracle.jdbc.driver.OracleDriver");
properties.put("hibernate.connection.username", "user");
properties.put("hibernate.connection.password", "pass");
properties.put("hibernate.dialect", "org.hibernate.dialect.Oracle9Dialect");
properties.put("hibernate.cache.provider_class", "org.hibernate.cache.HashtableCacheProvider");
properties.put("javax.persistence.provider", "org.hibernate.ejb.HibernatePersistence");
Ejb3Configuration cfg = new Ejb3Configuration();
cfg.addProperties(properties).addAnnotatedClass(User.class);
emf = cfg.buildEntityManagerFactory();
em = emf.createEntityManager();
em.getTransaction().begin();
em.createQuery("from User u").getResultList();
em.getTransaction().commit();
Then I got the following exception:
java.lang.IllegalArgumentException: No PolicyContextHandler for key=javax.security.auth.Subject.container
at javax.security.jacc.PolicyContext.getContext(PolicyContext.java:92)
at org.hibernate.secure.JACCPermissions$3.getContextSubject(JACCPermissions.java:88)
at org.hibernate.secure.JACCPermissions.getContextSubject(JACCPermissions.java:97)
at org.hibernate.secure.JACCPermissions.checkPermission(JACCPermissions.java:36)
at org.hibernate.secure.JACCPreLoadEventListener.onPreLoad(JACCPreLoadEventListener.java:30)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:125)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2211)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2095)
at org.hibernate.loader.Loader.list(Loader.java:2090)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:64)
at com.areteinc.dao.SampleTestDAO.testDAO(SampleTestDAO.java:48)
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 junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Can anyone help? Thanks,
|