persistencecontext使查询为空

时间:2013-02-27 07:43:19

标签: jpa hibernate-mapping apache-tomee

我最近改变了我的JPA设计:

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

道的

@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();
    }

}

托管bean简化

@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");
    }

}

与我的other post相反,Web服务器加载完美。 (我关闭另一个,我不知道发生了什么) 但是在我的托管bean的@PostConstruct方法中(在加载应用程序的第一个xhtml页面时称为direclty),aircraftTypes列表为空! 我知道JPQL查询是可以的,因为它非常简单,并且在此设计更改之前可以正常工作。我的猜测是创建的实体管理器不在我的“flightfaq”数据库上查询。我真的不明白,因为我只有一个持久单元。

以下是TomEE在启动时显示的日志 在查询飞机类型时,您将看到休眠日志,但在打印列表内容时不会发生任何事情

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

2 个答案:

答案 0 :(得分:1)

您是否尝试过为持久性单元提供显式名称?有人告诉我,即使你只有一个由TomEE的开发人员David Blevins提供的名字,最好提供这个名字; - )

虽然我确实怀疑它会解决你的问题。

顺便说一句,如果您将查询的创建更改为添加结果类型的类,则可以省略强制转换

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

这些方法始终返回TypedQuery<AircraftType>

然后你可以避免警告信息。

答案 1 :(得分:0)

我发现了问题。 它与我的TomEE Web服务器配置有关。 我需要在tomee.xml文件中描述我的dataSource(我做了)并将这些定义复制到部署在TomEE部署webapps和其他东西的硬盘目录中的openejb.xml文件中。 我认为这个副本是自动完成的(从tomee.xml到openejb.xml)

this thread

中的所有内容都非常详细

请注意,现在可以使用以下方式执行此操作:

  • @ ManagedBean / @ ViewScoped
  • @ Singleton / @ Startup / @ LocalBean