This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | JSF sample project ScrumToys doesn't work | ||
---|---|---|---|
Product: | javaee | Reporter: | devm1214 |
Component: | Samples | Assignee: | Martin Janicek <mjanicek> |
Status: | NEW --- | ||
Severity: | normal | ||
Priority: | P3 | ||
Version: | 8.1 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Issue Type: | DEFECT | Exception Reporter: |
Description
devm1214
2016-03-01 15:33:38 UTC
"The biggest problem is that we cannot add a project. After displaying the form with the "Create New Project" button in the View Projects list we can enter the project name and the dates click the "Create Project" button. Then we return to the list of projects and it remains empty.." When a persistence context is created by calling EntityManagerFactory.createEntityManager () method where JTA is enabled , You must run EntityManager.joinTransaction() method to do the synchronization with the database the changes have no effect. Here is the Fixed AbstractManager class: (...) public abstract class AbstractManager { @PersistenceUnit private EntityManagerFactory emf; @Resource private UserTransaction userTransaction; protected final <T> T doInTransaction(PersistenceAction<T> action) throws ManagerException { EntityManager em = emf.createEntityManager(); try { userTransaction.begin(); em.joinTransaction(); T result = action.execute(em); userTransaction.commit(); return result; } catch (Exception e) { try { userTransaction.rollback(); } catch (Exception ex) { Logger.getLogger(AbstractManager.class.getName()).log(Level.SEVERE, null, ex); } throw new ManagerException(e); } finally { em.close(); } } protected final void doInTransaction(PersistenceActionWithoutResult action) throws ManagerException { EntityManager em = emf.createEntityManager(); try { userTransaction.begin(); em.joinTransaction(); action.execute(em); userTransaction.commit(); } catch (Exception e) { try { userTransaction.rollback(); } catch (Exception ex) { Logger.getLogger(AbstractManager.class.getName()).log(Level.SEVERE, null, ex); } throw new ManagerException(e); } finally { em.close(); } } protected static interface PersistenceAction<T> { T execute(EntityManager em); } (...) } the exception is displayed on the console is not a fatal exception. But it can be solved by modifying the "eclipselink.target-database" property in the "persistence.xml" file so that it correctly references the database used. Ex: <property name = "eclipselink.target-database" value = "Derby" /> Play the free online bejeweled 3 games http://bejeweled3.co this is full unlimited fun and entertainment game. |