0

I recently changed my JPA design for that :

persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<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="flightfaq" transaction-type="JTA">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <properties>
            <property name="hibernate.archive.autodetection" value="class, hbm" />
            <property name="hibernate.connection.username" value="root" />
            <property name="hibernate.connection.password" value="password" />
            <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/flightfaq" />
            <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
            <property name="hibernate.hbm2ddl.auto" value="update" />
            <property name="hibernate.c3p0.min_size" value="5" />
            <property name="hibernate.c3p0.max_size" value="20" />
            <property name="hibernate.c3p0.timeout" value="300" />
            <property name="hibernate.c3p0.max_statements" value="50" />
            <property name="hibernate.c3p0.idle_test_period" value="3000" />
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.format_sql" value="true" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
            <property name="use_sql_comments" value="true" />
            <property name="jadira.usertype.autoRegisterUserTypes"
                value="true" />
        </properties>
    </persistence-unit>
</persistence>

Dao's

@Singleton
@LocalBean
@Startup
public class AircraftTypeDaoImpl implements AircraftTypeDao {

    @PersistenceContext
    private EntityManager em;

    /** JPQL query to find a {@link AircraftType} given its OACI name */
    private static final String JPQL_FIND_BY_TYPE = "SELECT a FROM AircraftType a WHERE a.typeOACI=:typeOACI";

    /** JPQL query to find all {@link AircraftType} */
    private static final String JPQL_FIND_ALL = "SELECT a FROM AircraftType a";

    public AircraftType find(String typeOACI) throws DAOException {
        AircraftType aircraftType = null;
        Query findQuery = em.createQuery(JPQL_FIND_BY_TYPE).setParameter(
                "typeOACI", typeOACI);
        aircraftType = (AircraftType) findQuery.getSingleResult();
        return aircraftType;
    }

    @SuppressWarnings("unchecked")
    public List<AircraftType> findAll() throws DAOException {
        return em.createQuery("SELECT a FROM AircraftType a").getResultList();
    }

}

managed bean simplified

@ManagedBean
@ViewScoped
public class MissionHandler implements Serializable {

    private static final long serialVersionUID = 2462652101518266609L;

    private Mission mission;

    private List<FlightFeasibilityException> exceptions;

    @EJB
    private AircraftTypeDaoImpl aircraftTypeDao;

    public MissionHandler() {
    }

    @PostConstruct
    public void init() {
        /** Create an empty mission */
        mission = new Mission();
        /** Create an empty list of exceptions */
        exceptions = new ArrayList<FlightFeasibilityException>();
        /** get aircraft types from the database */
        aircraftTypes = aircraftTypeDao.findAll();
        System.out.println("dump types");
        for (AircraftType type : aircraftTypes) {
            System.out.println(type.getTypeOACI());
        }
        System.out.println("init done");
    }

}

Contrary to my other post, the web server loads perfectly. (I´m closing the other one, I don't know what happend) But in the @PostConstruct method of my managed bean (which is called direclty when loading the first xhtml page of the app) the aircraftTypes list is empty ! I know the JPQL query is OK because it´s fairly simple and it works before this design change. My guess is that the created entitymanager is not querying on my "flightfaq" database. I really don't understand, since I have one persistence-unit only.

Below is the log displayed by TomEE on launch You will see the hibernate log when querying aircraft Types, but nothing just after, when printing the list's content

27 févr. 2013 08:22:11 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
27 févr. 2013 08:22:12 org.apache.tomcat.util.digester.SetPropertiesRule begin
ATTENTION: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:FlightFAQ' did not find a matching property.
27 févr. 2013 08:22:12 org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
27 févr. 2013 08:22:12 org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
27 févr. 2013 08:22:13 org.apache.openejb.util.OptionsLog info
INFO: Using 'openejb.jdbc.datasource-creator=org.apache.tomee.jdbc.TomEEDataSourceCreator'
27 févr. 2013 08:22:13 org.apache.tomee.catalina.TomcatLoader optionalService
INFO: Optional service not installed: org.apache.tomee.webservices.TomeeJaxRsService
27 févr. 2013 08:22:13 org.apache.tomee.catalina.TomcatLoader optionalService
INFO: Optional service not installed: org.apache.tomee.webservices.TomeeJaxWsService
27 févr. 2013 08:22:13 org.apache.openejb.OpenEJB$Instance <init>
INFO: ********************************************************************************
27 févr. 2013 08:22:13 org.apache.openejb.OpenEJB$Instance <init>
INFO: OpenEJB http://openejb.apache.org/
27 févr. 2013 08:22:13 org.apache.openejb.OpenEJB$Instance <init>
INFO: Startup: Wed Feb 27 08:22:13 CET 2013
27 févr. 2013 08:22:13 org.apache.openejb.OpenEJB$Instance <init>
INFO: Copyright 1999-2012 (C) Apache OpenEJB Project, All Rights Reserved.
27 févr. 2013 08:22:13 org.apache.openejb.OpenEJB$Instance <init>
INFO: Version: 4.5.1
27 févr. 2013 08:22:13 org.apache.openejb.OpenEJB$Instance <init>
INFO: Build date: 20121209
27 févr. 2013 08:22:13 org.apache.openejb.OpenEJB$Instance <init>
INFO: Build time: 08:47
27 févr. 2013 08:22:13 org.apache.openejb.OpenEJB$Instance <init>
INFO: ********************************************************************************
27 févr. 2013 08:22:13 org.apache.openejb.OpenEJB$Instance <init>
INFO: openejb.home = /Users/valentine/apache-tomee-webprofile-1.5.1
27 févr. 2013 08:22:13 org.apache.openejb.OpenEJB$Instance <init>
INFO: openejb.base = /Users/valentine/jbossworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
27 févr. 2013 08:22:13 org.apache.openejb.cdi.CdiBuilder initializeOWB
INFO: Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@65450f1f
27 févr. 2013 08:22:13 org.apache.openejb.cdi.CdiBuilder initializeOWB
INFO: Succeeded in installing singleton service
27 févr. 2013 08:22:13 org.apache.openejb.config.ConfigurationFactory init
INFO: openejb configuration file is '/Users/valentine/jbossworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/conf/openejb.xml'
27 févr. 2013 08:22:13 org.apache.openejb.util.OptionsLog info
INFO: Using 'openejb.provider.default=org.apache.tomee'
27 févr. 2013 08:22:13 org.apache.openejb.config.ConfigurationFactory configureService
INFO: Configuring Service(id=Tomcat Security Service, type=SecurityService, provider-id=Tomcat Security Service)
27 févr. 2013 08:22:13 org.apache.openejb.config.ConfigurationFactory configureService
INFO: Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
27 févr. 2013 08:22:13 org.apache.openejb.config.ConfigurationFactory configureService
INFO: Configuring Service(id=My DataSource, type=Resource, provider-id=Default JDBC Database)
27 févr. 2013 08:22:13 org.apache.openejb.config.ConfigurationFactory configureService
INFO: Configuring Service(id=My Unmanaged DataSource, type=Resource, provider-id=Default JDBC Database)
27 févr. 2013 08:22:13 org.apache.openejb.config.ConfigurationFactory configureService
INFO: Configuring Service(id=My Singleton Container, type=Container, provider-id=Default Singleton Container)
27 févr. 2013 08:22:13 org.apache.openejb.config.ConfigurationFactory configureService
INFO: Configuring Service(id=My Stateful Container, type=Container, provider-id=Default Stateful Container)
27 févr. 2013 08:22:13 org.apache.openejb.config.ConfigurationFactory configureService
INFO: Configuring Service(id=My Stateless Container, type=Container, provider-id=Default Stateless Container)
27 févr. 2013 08:22:13 org.apache.openejb.config.DeploymentsResolver loadFrom
ATTENTION: <Deployments dir="null"> - Does not exist: /Users/valentine/jbossworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/apps
27 févr. 2013 08:22:13 org.apache.openejb.util.OptionsLog info
INFO: Using 'openejb.system.apps=true'
27 févr. 2013 08:22:14 org.apache.openejb.config.ConfigurationFactory configureApplication
INFO: Configuring enterprise application: null
27 févr. 2013 08:22:14 org.apache.openejb.config.InitEjbDeployments deploy
INFO: Using openejb.deploymentId.format '{ejbName}'
27 févr. 2013 08:22:14 org.apache.openejb.config.InitEjbDeployments deploy
INFO: Auto-deploying ejb openejb/User: EjbDeployment(deployment-id=openejb/User)
27 févr. 2013 08:22:14 org.apache.openejb.config.InitEjbDeployments deploy
INFO: Auto-deploying ejb openejb/Deployer: EjbDeployment(deployment-id=openejb/Deployer)
27 févr. 2013 08:22:14 org.apache.openejb.config.InitEjbDeployments deploy
INFO: Auto-deploying ejb openejb/ConfigurationInfo: EjbDeployment(deployment-id=openejb/ConfigurationInfo)
27 févr. 2013 08:22:14 org.apache.openejb.config.InitEjbDeployments deploy
INFO: Auto-deploying ejb MEJB: EjbDeployment(deployment-id=MEJB)
27 févr. 2013 08:22:14 org.apache.openejb.config.AppInfoBuilder build
INFO: Enterprise application "openejb" loaded.
27 févr. 2013 08:22:14 org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating TransactionManager(id=Default Transaction Manager)
27 févr. 2013 08:22:14 org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating SecurityService(id=Tomcat Security Service)
27 févr. 2013 08:22:14 org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating Resource(id=My DataSource)
27 févr. 2013 08:22:14 org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating Resource(id=My Unmanaged DataSource)
27 févr. 2013 08:22:14 org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating Container(id=My Singleton Container)
27 févr. 2013 08:22:14 org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating Container(id=My Stateful Container)
27 févr. 2013 08:22:14 org.apache.openejb.core.stateful.SimplePassivater init
INFO: Using directory /var/folders/UO/UOQ3IO17G+0yGL13ChYWzU+++TI/-Tmp- for stateful session passivation
27 févr. 2013 08:22:14 org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating Container(id=My Stateless Container)
27 févr. 2013 08:22:14 org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Assembling app: openejb
27 févr. 2013 08:22:14 org.apache.openejb.util.OptionsLog info
INFO: Using 'openejb.jndiname.format={deploymentId}{interfaceType.openejbLegacyName}'
27 févr. 2013 08:22:14 org.apache.openejb.assembler.classic.JndiBuilder bind
INFO: Jndi(name=openejb/UserBusinessRemote) --> Ejb(deployment-id=openejb/User)
27 févr. 2013 08:22:14 org.apache.openejb.assembler.classic.JndiBuilder bind
INFO: Jndi(name=global/openejb/openejb/User!org.apache.openejb.assembler.util.User) --> Ejb(deployment-id=openejb/User)
27 févr. 2013 08:22:14 org.apache.openejb.assembler.classic.JndiBuilder bind
INFO: Jndi(name=global/openejb/openejb/User) --> Ejb(deployment-id=openejb/User)
27 févr. 2013 08:22:14 org.apache.openejb.assembler.classic.JndiBuilder bind
INFO: Jndi(name=openejb/DeployerBusinessRemote) --> Ejb(deployment-id=openejb/Deployer)
27 févr. 2013 08:22:14 org.apache.openejb.assembler.classic.JndiBuilder bind
INFO: Jndi(name=global/openejb/openejb/Deployer!org.apache.openejb.assembler.Deployer) --> Ejb(deployment-id=openejb/Deployer)
27 févr. 2013 08:22:14 org.apache.openejb.assembler.classic.JndiBuilder bind
INFO: Jndi(name=global/openejb/openejb/Deployer) --> Ejb(deployment-id=openejb/Deployer)
27 févr. 2013 08:22:14 org.apache.openejb.assembler.classic.JndiBuilder bind
INFO: Jndi(name=openejb/ConfigurationInfoBusinessRemote) --> Ejb(deployment-id=openejb/ConfigurationInfo)
27 févr. 2013 08:22:14 org.apache.openejb.assembler.classic.JndiBuilder bind
INFO: Jndi(name=global/openejb/openejb/ConfigurationInfo!org.apache.openejb.assembler.classic.cmd.ConfigurationInfo) --> Ejb(deployment-id=openejb/ConfigurationInfo)
27 févr. 2013 08:22:14 org.apache.openejb.assembler.classic.JndiBuilder bind
INFO: Jndi(name=global/openejb/openejb/ConfigurationInfo) --> Ejb(deployment-id=openejb/ConfigurationInfo)
27 févr. 2013 08:22:14 org.apache.openejb.assembler.classic.JndiBuilder bind
INFO: Jndi(name=MEJB) --> Ejb(deployment-id=MEJB)
27 févr. 2013 08:22:14 org.apache.openejb.assembler.classic.JndiBuilder bind
INFO: Jndi(name=global/openejb/MEJB!javax.management.j2ee.ManagementHome) --> Ejb(deployment-id=MEJB)
27 févr. 2013 08:22:14 org.apache.openejb.assembler.classic.JndiBuilder bind
INFO: Jndi(name=global/openejb/MEJB) --> Ejb(deployment-id=MEJB)
27 févr. 2013 08:22:14 org.apache.openejb.cdi.CdiBuilder initSingleton
INFO: Existing thread singleton service in SystemInstance() org.apache.openejb.cdi.ThreadSingletonServiceImpl@65450f1f
27 févr. 2013 08:22:14 org.apache.openejb.cdi.OpenEJBLifecycle startApplication
INFO: OpenWebBeans Container is starting...
27 févr. 2013 08:22:14 org.apache.webbeans.plugins.PluginLoader startUp
INFO: Adding OpenWebBeansPlugin : [CdiPlugin]
27 févr. 2013 08:22:14 org.apache.webbeans.plugins.PluginLoader startUp
INFO: Adding OpenWebBeansPlugin : [OpenWebBeansJsfPlugin]
27 févr. 2013 08:22:14 org.apache.openejb.cdi.BeansDeployer validateInjectionPoints
INFO: All injection points are validated successfully.
27 févr. 2013 08:22:14 org.apache.openejb.cdi.OpenEJBLifecycle startApplication
INFO: OpenWebBeans Container has started, it took 109 ms.
27 févr. 2013 08:22:15 org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Created Ejb(deployment-id=openejb/Deployer, ejb-name=openejb/Deployer, container=My Stateless Container)
27 févr. 2013 08:22:15 org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Created Ejb(deployment-id=MEJB, ejb-name=MEJB, container=My Stateless Container)
27 févr. 2013 08:22:15 org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Created Ejb(deployment-id=openejb/ConfigurationInfo, ejb-name=openejb/ConfigurationInfo, container=My Stateless Container)
27 févr. 2013 08:22:15 org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Created Ejb(deployment-id=openejb/User, ejb-name=openejb/User, container=My Stateless Container)
27 févr. 2013 08:22:15 org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Started Ejb(deployment-id=openejb/Deployer, ejb-name=openejb/Deployer, container=My Stateless Container)
27 févr. 2013 08:22:15 org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Started Ejb(deployment-id=MEJB, ejb-name=MEJB, container=My Stateless Container)
27 févr. 2013 08:22:15 org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Started Ejb(deployment-id=openejb/ConfigurationInfo, ejb-name=openejb/ConfigurationInfo, container=My Stateless Container)
27 févr. 2013 08:22:15 org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Started Ejb(deployment-id=openejb/User, ejb-name=openejb/User, container=My Stateless Container)
27 févr. 2013 08:22:15 org.apache.openejb.assembler.classic.Assembler deployMBean
INFO: Deployed MBean(openejb.user.mbeans:application=openejb,group=org.apache.openejb.assembler.monitoring,name=JMXDeployer)
27 févr. 2013 08:22:15 org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Deployed Application(path=openejb)
27 févr. 2013 08:22:15 org.apache.openejb.server.SimpleServiceManager start
INFO:   ** Bound Services **
27 févr. 2013 08:22:15 org.apache.openejb.server.SimpleServiceManager printRow
INFO:   NAME                 IP              PORT  
27 févr. 2013 08:22:15 org.apache.openejb.server.SimpleServiceManager start
INFO: -------
27 févr. 2013 08:22:15 org.apache.openejb.server.SimpleServiceManager start
INFO: Ready!
27 févr. 2013 08:22:15 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 4212 ms
27 févr. 2013 08:22:15 org.apache.tomee.catalina.OpenEJBNamingContextListener bindResource
INFO: Importing a Tomcat Resource with id 'UserDatabase' of type 'org.apache.catalina.UserDatabase'.
27 févr. 2013 08:22:15 org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating Resource(id=UserDatabase)
27 févr. 2013 08:22:15 org.apache.catalina.core.StandardService startInternal
INFO: Démarrage du service Catalina
27 févr. 2013 08:22:15 org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat (TomEE)/7.0.34
27 févr. 2013 08:22:15 org.apache.tomee.catalina.TomcatWebAppBuilder init
INFO: -------------------------
TomcatWebAppBuilder.init 
27 févr. 2013 08:22:15 org.apache.openejb.config.ConfigurationFactory configureApplication
INFO: Configuring enterprise application: /Users/valentine/jbossworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/ROOT
27 févr. 2013 08:22:15 org.apache.openejb.config.AppInfoBuilder build
INFO: Enterprise application "/Users/valentine/jbossworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/ROOT" loaded.
27 févr. 2013 08:22:15 org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Assembling app: /Users/valentine/jbossworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/ROOT
27 févr. 2013 08:22:15 org.apache.openejb.cdi.CdiBuilder initSingleton
INFO: Existing thread singleton service in SystemInstance() org.apache.openejb.cdi.ThreadSingletonServiceImpl@65450f1f
27 févr. 2013 08:22:15 org.apache.openejb.cdi.OpenEJBLifecycle startApplication
INFO: OpenWebBeans Container is starting...
27 févr. 2013 08:22:15 org.apache.webbeans.plugins.PluginLoader startUp
INFO: Adding OpenWebBeansPlugin : [CdiPlugin]
27 févr. 2013 08:22:15 org.apache.webbeans.plugins.PluginLoader startUp
INFO: Adding OpenWebBeansPlugin : [OpenWebBeansJsfPlugin]
27 févr. 2013 08:22:15 org.apache.openejb.cdi.BeansDeployer validateInjectionPoints
INFO: All injection points are validated successfully.
27 févr. 2013 08:22:15 org.apache.openejb.cdi.OpenEJBLifecycle startApplication
INFO: OpenWebBeans Container has started, it took 3 ms.
27 févr. 2013 08:22:15 org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Deployed Application(path=/Users/valentine/jbossworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/ROOT)
27 févr. 2013 08:22:16 org.apache.myfaces.ee6.MyFacesContainerInitializer onStartup
INFO: Added FacesServlet with mappings=[/faces/*, *.jsf, *.faces]
27 févr. 2013 08:22:16 org.apache.myfaces.config.DefaultFacesConfigurationProvider getStandardFacesConfig
INFO: Reading standard config META-INF/standard-faces-config.xml
27 févr. 2013 08:22:17 org.apache.myfaces.config.DefaultFacesConfigurationProvider getClassloaderFacesConfig
INFO: Reading config : jar:file:/Users/valentine/apache-tomee-webprofile-1.5.1/lib/omnifaces-1.3.jar!/META-INF/faces-config.xml
27 févr. 2013 08:22:17 org.apache.myfaces.config.DefaultFacesConfigurationProvider getClassloaderFacesConfig
INFO: Reading config : jar:file:/Users/valentine/apache-tomee-webprofile-1.5.1/lib/openwebbeans-jsf-1.1.7.jar!/META-INF/faces-config.xml
27 févr. 2013 08:22:17 org.apache.myfaces.config.LogMetaInfUtils logArtifact
INFO: Artifact 'myfaces-api' was found in version '2.1.10' from path 'file:/Users/valentine/apache-tomee-webprofile-1.5.1/lib/myfaces-api-2.1.10.jar'
27 févr. 2013 08:22:17 org.apache.myfaces.config.LogMetaInfUtils logArtifact
INFO: Artifact 'myfaces-impl' was found in version '2.1.10' from path 'file:/Users/valentine/apache-tomee-webprofile-1.5.1/lib/myfaces-impl-2.1.10.jar'
27 févr. 2013 08:22:17 org.hibernate.validator.internal.util.Version <clinit>
INFO: HV000001: Hibernate Validator 4.3.1.Final
27 févr. 2013 08:22:17 org.apache.myfaces.util.ExternalSpecifications isBeanValidationAvailable
INFO: MyFaces Bean Validation support enabled
27 févr. 2013 08:22:17 org.apache.myfaces.application.ApplicationImpl getProjectStage
INFO: Couldn't discover the current project stage, using Production
27 févr. 2013 08:22:17 org.apache.myfaces.config.FacesConfigurator handleSerialFactory
INFO: Serialization provider : class org.apache.myfaces.shared_impl.util.serial.DefaultSerialFactory
27 févr. 2013 08:22:17 org.apache.myfaces.config.annotation.DefaultLifecycleProviderFactory getLifecycleProvider
INFO: Using LifecycleProvider org.apache.myfaces.config.annotation.Tomcat7AnnotationLifecycleProvider
27 févr. 2013 08:22:17 org.apache.myfaces.webapp.AbstractFacesInitializer initFaces
INFO: ServletContext initialized.
27 févr. 2013 08:22:17 org.apache.myfaces.util.ExternalSpecifications isUnifiedELAvailable
INFO: MyFaces Unified EL support enabled
27 févr. 2013 08:22:17 org.apache.tomee.catalina.TomcatWebAppBuilder init
INFO: -------------------------
TomcatWebAppBuilder.init /FlightFAQ
27 févr. 2013 08:22:19 org.apache.openejb.config.ConfigurationFactory configureApplication
INFO: Configuring enterprise application: /Users/valentine/jbossworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/FlightFAQ
27 févr. 2013 08:22:22 org.apache.openejb.config.InitEjbDeployments deploy
INFO: Auto-deploying ejb AircraftTypeDaoImpl: EjbDeployment(deployment-id=AircraftTypeDaoImpl)
27 févr. 2013 08:22:22 org.apache.openejb.config.InitEjbDeployments deploy
INFO: Auto-deploying ejb MissionDaoImpl: EjbDeployment(deployment-id=MissionDaoImpl)
27 févr. 2013 08:22:22 org.apache.openejb.config.InitEjbDeployments deploy
INFO: Auto-deploying ejb AirportDaoImpl: EjbDeployment(deployment-id=AirportDaoImpl)
27 févr. 2013 08:22:22 org.apache.openejb.config.InitEjbDeployments deploy
INFO: Auto-deploying ejb LegDaoImpl: EjbDeployment(deployment-id=LegDaoImpl)
27 févr. 2013 08:22:22 org.apache.openejb.config.InitEjbDeployments deploy
INFO: Auto-deploying ejb VariantDaoImpl: EjbDeployment(deployment-id=VariantDaoImpl)
27 févr. 2013 08:22:22 org.apache.openejb.config.InitEjbDeployments deploy
INFO: Auto-deploying ejb CustomerDaoImpl: EjbDeployment(deployment-id=CustomerDaoImpl)
27 févr. 2013 08:22:22 org.apache.openejb.config.InitEjbDeployments deploy
INFO: Auto-deploying ejb FlightFaqUserDaoImpl: EjbDeployment(deployment-id=FlightFaqUserDaoImpl)
27 févr. 2013 08:22:22 org.apache.openejb.config.AutoConfig deploy
INFO: Configuring PersistenceUnit(name=flightfaq, provider=org.hibernate.ejb.HibernatePersistence)
27 févr. 2013 08:22:22 org.apache.openejb.config.AutoConfig setJtaDataSource
INFO: Adjusting PersistenceUnit flightfaq <jta-data-source> to Resource ID 'My DataSource' from 'null'
27 févr. 2013 08:22:22 org.apache.openejb.config.AutoConfig setNonJtaDataSource
INFO: Adjusting PersistenceUnit flightfaq <non-jta-data-source> to Resource ID 'My Unmanaged DataSource' from 'null'
27 févr. 2013 08:22:22 org.apache.openejb.config.AppInfoBuilder build
INFO: Enterprise application "/Users/valentine/jbossworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/FlightFAQ" loaded.
27 févr. 2013 08:22:22 org.apache.openejb.assembler.classic.Assembler createApplication
INFO: Assembling app: /Users/valentine/jbossworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/FlightFAQ
27 févr. 2013 08:22:22 org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
27 févr. 2013 08:22:22 org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.9.Final}
27 févr. 2013 08:22:22 org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
27 févr. 2013 08:22:22 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
27 févr. 2013 08:22:22 org.hibernate.ejb.Ejb3Configuration configure
INFO: HHH000204: Processing PersistenceUnitInfo [
    name: flightfaq
    ...]
27 févr. 2013 08:22:23 org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator instantiateExplicitConnectionProvider
INFO: HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
27 févr. 2013 08:22:46 com.sun.faces.mgbean.BeanManager addBean
ATTENTION: JSF1074 : Le bean géré nommé «startup» a déjà été enregistré.  Remplacement du type de classe du bean géré existant java.util.Date par java.util.Date.
27 févr. 2013 08:22:46 com.sun.faces.mgbean.BeanManager addBean
ATTENTION: JSF1074 : Le bean géré nommé «now» a déjà été enregistré.  Remplacement du type de classe du bean géré existant java.util.Date par java.util.Date.
Wed Feb 27 08:22:48 MacBook-Pro-de-Valentine-Calloud.local java[323] <Error>: kCGErrorIllegalArgument: CGSOrderWindowList
Wed Feb 27 08:22:48 MacBook-Pro-de-Valentine-Calloud.local java[323] <Error>: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.
27 févr. 2013 08:22:48 org.richfaces.application.InitializationListener logWarningWhenConnectionFactoryPresent
ATTENTION: JMS API was found on the classpath; if you want to enable RichFaces Push JMS integration, set context-param 'org.richfaces.push.jms.enabled' in web.xml
Hibernate: 
    select
        aircraftty0_.id as id12_,
        aircraftty0_.massChild as massChild12_,
        aircraftty0_.massFemale as massFemale12_,
        aircraftty0_.massMale as massMale12_,
        aircraftty0_.postFlightShowUp as postFlig5_12_,
        aircraftty0_.preFlightShowUp as preFligh6_12_,
        aircraftty0_.typeOACI as typeOACI12_ 
    from
        AircraftType aircraftty0_
dump types
init done
Community
  • 1
  • 1
facewindu
  • 705
  • 3
  • 11
  • 31

2 Answers2

1

Have you tried providing the explicit name for persistence unit? I was told once that it is always best to provide the name even if you only have one by David Blevins, one of the devs of TomEE ;-)

Though I actually doubt that it will solve your problem.

By the way, if you change the creating of the queries to adding the class of the result type, you can leave out the cast

em.createQuery("SELECT a FROM AircraftType a", AircraftType.class).getResultList();

These methods always return TypedQuery<AircraftType>

Then you can the avoid warning message.

omilke
  • 827
  • 9
  • 20
  • hello. Yes i tried @PersistenceContext(unitname= "flightfaq") (not sure about the exacte writing) ... and it doesn't work. Thanks for your remark on TypedQuery. This is what I used but I changed my code quickly to explain the problem and left the cast, but that not the main concern :) – facewindu Feb 27 '13 at 10:04
  • Have you by chance changed anything in the entity resulting in an update of the db strcuture? – omilke Feb 27 '13 at 10:09
  • unfortunately, no. After looking with the Eclipse debugger at the resultList from the query (and seeing it is empty) I connect via phpmyAdmin to ma databse. I run a SQL command "SELECT * FROM AircraftType" and I get all my expected results ... Is there a chance that the problem comes from the query itself, which is not well-written ? – facewindu Feb 27 '13 at 10:13
  • i truely doubt that, since it would haven been reported from hibernate. Moreover, logical errors in the JPQL can be checked with executing the statement from hibernate log yourself. – omilke Feb 27 '13 at 10:18
  • Can it be related to my definition of the DAO ? (@ singleton, @ startup, @ local bean). I tried before to use @Stateless beans as DAOs but I ran into nullPointer, because the call to the dao in the managed bean @ PostConstruct method was probably done too soon ? – facewindu Feb 27 '13 at 10:49
  • The problem you encountered with the `@Stateless` bean most likely resolves to the scope you used in the `@ManagedBean`. This is from the JSF bean scopes, whereas the `@Stateless` works with the EJBs scopes. I'd recommend changing to `@Named @RequestScoped` to make sure you use the same set of scopes as in the EJBs, which re-enables you to use `@Stateless`. Maybe give it a try – omilke Feb 27 '13 at 11:27
  • alright, i'll give it a try and keep you posted (even if I don't really understand your explanation :) ) – facewindu Feb 27 '13 at 11:35
  • Too bad. JSF has its own lifecycle for beans, EJB / CDI use another. Mixing them up leads to the NPE you encountered. HAve a look at http://www.andygibson.net/blog/article/comparing-jsf-beans-cdi-beans-and-ejbs/ – omilke Feb 27 '13 at 11:53
  • ok. I can't try it right now (but will definitely do that in a few hours). Let's say a perfrom the changes : @ ManagedBean => @ Named @ RequestScoped, andthe other conversion @ Singleton => @ Stateless ... How can I be sure that the @ Stateless DAO bean will be already instantiated when needed in the @Named JSF bean (to populate the list of aircraftType) ? Other question : I will loose the benefit of @ ViewScoped annotation (even if i'm not sure it really has an effect on my application, even if it seems the right scope to use in my case) – facewindu Feb 27 '13 at 12:57
  • You're right in loosing the one option, since @ViewScope is not part of the EJB scopes. However, there are workarounds on the internet if you absolutely need them. As to your first question, this is what dependency injection is made for. Default scope of `@Stateless` is `@Dependant`, which means your DAO will be made available for your ('JSF' backing) bean even before its `@PostConstruct` method is called. – omilke Feb 27 '13 at 13:03
  • Well, I tried whqt we discussed about ... without any success. The Injection is OK, but as before, the query returns an empty list. I'm kind of desperate right now. What can you suggest ? – facewindu Feb 27 '13 at 17:37
  • The more I think about it, the more I think it HAS to do with my persistence.xml and/or other xml config file that i am missing, and/or dependencies not deployed on TomEE or sth like that. Could you list from scratch what is needed and what I should check about my environment ?I can't believe that I can get what I want in phpMyAdmin with SQL syntax queries and that the conversion in JPQL doesn't work ! – facewindu Feb 27 '13 at 18:19
0

I found the problem. It was related to my TomEE Web server configuration. I needed to describe my dataSource in tomee.xml file (which I did) AND copy these definitions in the openejb.xml file that is deployed in the hard disk directory where TomEE deploys the webapps and other stuffs. I thought this copy was done automatically (from tomee.xml to openejb.xml)

Everything is well detailed in this thread

Note that the behaviour is now as expected using :

  • @ ManagedBean / @ ViewScoped
  • @ Singleton / @ Startup / @ LocalBean
facewindu
  • 705
  • 3
  • 11
  • 31