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.

Bug 258204 - JSF sample project ScrumToys doesn't work
Summary: JSF sample project ScrumToys doesn't work
Status: NEW
Alias: None
Product: javaee
Classification: Unclassified
Component: Samples (show other bugs)
Version: 8.1
Hardware: PC Windows XP
: P3 normal (vote)
Assignee: Martin Janicek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-01 15:33 UTC by devm1214
Modified: 2019-07-14 08:03 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description devm1214 2016-03-01 15:33:38 UTC
After a clean install of NetBeans 8.1, I created a new project choosen in the category Samples/Java EE -> project Scrum Toys (Java EE 6)

then run it on the glassfish server

first the application is not displayed properly because of some minor bugs :

in file : \web\.dashboard.todoTasks.xhtml
line 46 :
      xmlns:c="http://java.sun.com/jstl/core"
should be :
      xmlns:c="http://java.sun.com/jsp/jstl/core"
-> no impact because not used

file : \web\template.xhtml
line 49 and 50 :
        <h:outputStylesheet library="css/1_1" name="#{skinManager.selectedSkin}"/>
        <h:outputStylesheet library="css/1_1" name="common.css"/>
should be :
        <h:outputStylesheet library="css" name="#{skinManager.selectedSkin}"/>
        <h:outputStylesheet library="css" name="common.css"/>
-> allows css files to be found

line 64 :
                <scrum:menu image="#{resource['images/menu:barraSuperior-04.png']}" />
should be :
                <scrum:menu image="#{resource['images/menu/barraSuperior-04.png']}" />
-> allows header image to be displayed


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...

No exception is found on the server log when creating a project, but one exception is displayed on the console when the application starts : 

Avertissement:   java.lang.NullPointerException
	at org.eclipse.persistence.platform.server.ServerPlatformUtils.createServerPlatform(ServerPlatformUtils.java:99)
	at org.eclipse.persistence.sessions.factories.SessionManager.init(SessionManager.java:77)
	at org.eclipse.persistence.sessions.factories.SessionManager.<clinit>(SessionManager.java:71)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.removeSessionFromGlobalSessionManager(EntityManagerSetupImpl.java:558)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.undeploy(EntityManagerSetupImpl.java:2982)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.close(EntityManagerFactoryDelegate.java:268)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.close(EntityManagerFactoryImpl.java:288)
	at org.glassfish.persistence.jpa.JPADeployer.closeEMFs(JPADeployer.java:414)
	at org.glassfish.persistence.jpa.JPADeployer.event(JPADeployer.java:405)
	at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
	at com.sun.enterprise.v3.server.ApplicationLifecycle.unload(ApplicationLifecycle.java:1067)
	at com.sun.enterprise.v3.server.ApplicationLifecycle.undeploy(ApplicationLifecycle.java:1099)
	at org.glassfish.deployment.admin.UndeployCommand.execute(UndeployCommand.java:412)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.security.auth.Subject.doAs(Subject.java:356)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)


I tried to add a project record directly in the derby database. 
The record is displayed and then it is possible to add sprints, stories and tasks, but nothing is written in the database. 
And we still cannot add another project. 

I have found a way to be able to add a project but it's weird :
after launching the application in firefox I go to the glassfish admin console
then I remove the password property from the jdbc properties (or rename it, is the same), then I am able to create project. 
but it's very slow because a lot of exceptions are thrown
however the list of projects shows the new project added...


when clean and build the project the following alert is displayed in the console (although the persistence file is in the META-INF folder) : 

Note: Creating static metadata factory ...
Note: The persistence xml file [META-INF/persistence.xml] was not found. NO GENERATION will occur!! Please ensure a persistence xml file is available either from the CLASS_OUTPUT directory [META-INF/persistence.xml] or using the eclipselink.persistencexml property to specify its location. 
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Comment 1 lisy 2017-07-18 03:12:53 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" />
Comment 2 KGF123 2019-07-14 08:03:52 UTC
Play the free online bejeweled 3 games http://bejeweled3.co this is full unlimited fun and entertainment game.