I have inherited a maven based project that was created with Netbeans 7.4. I have configured a local Glassfish 3.1.2.2 in the servers tab, set up JDBC connection pools and resources and can debug the project correctly.
However, I created 2 more tables in one of the connected databases, and let Netbeans generate 2 new entities from the Database schema. The entities are generated correctly, but when I start using them and start a debug session on the glassfish server I can see error messages being logged saying that the entities are not declared in the persistence unit.
I am trying to find what persistence.xml is being used, but although I find a lot of old ones inside the project structure (that I didn't create myself and I don't have contact with the authors) I cannot find any that seems to be the one being used. Hibernate only refers to the Persistence Unit name, not to the path of the file being used.
I am new to Java Persistence, so I am a bit confused. Can anybody suggest how I find, or recreate, the persistence.xml file?
EDIT: Here is the stack trace:
INFO: HHH000412: Hibernate Core {4.2.6.Final}
INFO: HHH000206: hibernate.properties not found
INFO: HHH000021: Bytecode provider name : javassist
INFO: HHH000204: Processing PersistenceUnitInfo [
name: core_rw_pu_hibernate
...]
INFO: HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
SEVERE: Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method
SEVERE: Exception while preparing the app
SEVERE: [PersistenceUnit: core_rw_pu_hibernate] Unable to build EntityManagerFactory
javax.persistence.PersistenceException: [PersistenceUnit: core_rw_pu_hibernate] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:924)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:76)
at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:206)
at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:120)
at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:224)
at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:495)
at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:233)
at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:168)
at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:871)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:410)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.hibernate.AnnotationException: Use of #OneToMany or #ManyToMany targeting an unmapped class: com.acme.ee.domain.entity.DeviceEntity.deviceInOuts[com.acme.ee.domain.entity.DeviceInOuts]
at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1059)
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:733)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:668)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:69)
at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1632)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1390)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1777)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:96)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
... 38 more
In a normal maven-based web application project the persistence.xml has to be placed in the folder:
src/main/resources/META-INF
In the NetBeans Projects tab this folder can be seen by opening "Other Sources" (should be right under "Source Packages").
If this isn't the right file, you have the option to search for the name of the PersistenceUnit in the whole project. The name has to be declared in the persistence.xml. If it finds multiple files you can find the one which is actually used by making the files unparsable one by one. To do this, just remove a closing tag (like </provider>) in the first file, save it and deploy it. If it throws an error which tells you the file is unparsable (probably something containing the class SAXParser), this is the file which is used. If it doesn't throw an error, try again with the next file.
To fix the initial problem (new entities not in persistence unit) make sure you add the new entity classes in the persistence.xml like this:
<class>com.company.SomeClass</class>
Another option is to add the following to your persistence.xml:
<exclude-unlisted-classes>false</exclude-unlisted-classes>
This should automatically discover all entities, but sometimes this doesn't work because the project structure doesn't fit, then you have to explicitly list every entity.
your persistence.xml should have information about your connection to the database like bellow:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="YOUR_PERSISTENCE_UNIT_NAME" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/YOUR_JNDI_NAME</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<!--<property name="javax.persistence.schema-generation.database.action" value="none"/> -->
<property name="hibernate.archive.autodetection" value="class"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.SunOneJtaPlatform"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/YOUR_SCHEMA_NAME?zeroDateTimeBehavior=convertToNull"/>
<property name="hibernate.connection.username" value="YOUR_USERNAME"/>
<property name="hibernate.connection.password" value="YOUR_PASSWORD"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>
</persistence-unit>
</persistence>
Related
I have a web application which is written in JEE. I am using hibernate as a JPA provider and I would like to use Infinispan as a second level cache. As I went through internet I noticed that only adding several lines is needed. I added in my persistence.xml these lines
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.infinispan.InfinispanRegionFactory"/>
<property name="javax.persistence.sharedCache.mode" value="ENABLE_SELECTIVE"/>
<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.infinispan.InfinispanRegionFactory"/>
<property name="hibernate.cache.use_query_cache" value="true"/>
but during deploying ear and war file on JBoss I receive an error message
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.spi.CacheImplementor]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:244)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:208)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:242)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879)
... 83 more
Caused by: org.hibernate.cache.CacheException: Unable to start region factory
at org.hibernate.cache.infinispan.InfinispanRegionFactory.start(InfinispanRegionFactory.java:415)
at org.hibernate.internal.CacheImpl.<init>(CacheImpl.java:49)
at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:28)
at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:20)
at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.initiateService(SessionFactoryServiceRegistryImpl.java:46)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:234)
... 88 more
Caused by: org.infinispan.jmx.JmxDomainConflictException: ISPN000034: There's already a JMX MBean instance type=CacheManager,name="SampleCacheManager" already registered under 'org.infinispan' JMX domain. If you want to allow multiple instances configured with same JMX domain enable 'allowDuplicateDomains' attribute in 'globalJmxStatistics' config element
at org.infinispan.jmx.JmxUtil.buildJmxDomain(JmxUtil.java:52)
at org.infinispan.jmx.CacheManagerJmxRegistration.updateDomain(CacheManagerJmxRegistration.java:79)
at org.infinispan.jmx.CacheManagerJmxRegistration.buildRegistrar(CacheManagerJmxRegistration.java:73)
at org.infinispan.jmx.AbstractJmxRegistration.registerMBeans(AbstractJmxRegistration.java:37)
at org.infinispan.jmx.CacheManagerJmxRegistration.start(CacheManagerJmxRegistration.java:41)
at org.infinispan.manager.DefaultCacheManager.start(DefaultCacheManager.java:639)
at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:300)
at org.hibernate.cache.infinispan.InfinispanRegionFactory.createCacheManager(InfinispanRegionFactory.java:532)
at org.hibernate.cache.infinispan.InfinispanRegionFactory$1.doWork(InfinispanRegionFactory.java:500)
at org.hibernate.cache.infinispan.InfinispanRegionFactory$1.doWork(InfinispanRegionFactory.java:473)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.workWithClassLoader(ClassLoaderServiceImpl.java:342)
at org.hibernate.cache.infinispan.InfinispanRegionFactory.createCacheManager(InfinispanRegionFactory.java:472)
at org.hibernate.cache.infinispan.InfinispanRegionFactory.start(InfinispanRegionFactory.java:380)
... 93 more
UPDATE
When my persistence unit looks like this
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="myPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>java:jboss/datasources/myDatasource</non-jta-data-source>
<mapping-file>META-INF/orm_mapping.xml</mapping-file>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
...
<properties>
...
<property name="hibernate.cache.use_second_level_cache" value="true" />
...
</properties>
</persistence-unit>
</persistence>
I am getting an exception
Caused by: org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given; please either disable second level cache or set correct region factory using the hibernate.cache.region.factory_class setting and make sure the second level cache provider (hibernate-infinispan, e.g.) is available on the classpath.
at org.hibernate.cache.internal.NoCachingRegionFactory.buildEntityRegion(NoCachingRegionFactory.java:66)
at org.hibernate.internal.SessionFactoryImpl.determineEntityRegionAccessStrategy(SessionFactoryImpl.java:619)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:332)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879)
... 83 more
After adding below line to persistence.xml
<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.infinispan.InfinispanRegionFactory" />
I am still getting exception with JMX MBean
Caused by: org.infinispan.jmx.JmxDomainConflictException: ISPN000034: There's already a JMX MBean instance type=CacheManager,name="SampleCacheManager" already registered under 'org.infinispan' JMX domain. If you want to allow multiple instances configured with same JMX domain enable 'allowDuplicateDomains' attribute in 'globalJmxStatistics' config element
at org.infinispan.jmx.JmxUtil.buildJmxDomain(JmxUtil.java:52)
at org.infinispan.jmx.CacheManagerJmxRegistration.updateDomain(CacheManagerJmxRegistration.java:79)
at org.infinispan.jmx.CacheManagerJmxRegistration.buildRegistrar(CacheManagerJmxRegistration.java:73)
at org.infinispan.jmx.AbstractJmxRegistration.registerMBeans(AbstractJmxRegistration.java:37)
at org.infinispan.jmx.CacheManagerJmxRegistration.start(CacheManagerJmxRegistration.java:41)
at org.infinispan.manager.DefaultCacheManager.start(DefaultCacheManager.java:639)
at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:300)
at org.hibernate.cache.infinispan.InfinispanRegionFactory.createCacheManager(InfinispanRegionFactory.java:532)
at org.hibernate.cache.infinispan.InfinispanRegionFactory$1.doWork(InfinispanRegionFactory.java:500)
at org.hibernate.cache.infinispan.InfinispanRegionFactory$1.doWork(InfinispanRegionFactory.java:473)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.workWithClassLoader(ClassLoaderServiceImpl.java:342)
at org.hibernate.cache.infinispan.InfinispanRegionFactory.createCacheManager(InfinispanRegionFactory.java:472)
at org.hibernate.cache.infinispan.InfinispanRegionFactory.start(InfinispanRegionFactory.java:380)
... 93 more
Maybe I need some kind of infinispan config file where I will be able to place
<jmx duplicate-domains="true" />
like it is mentioned here Infinispan as second level cache hibernate
You should check the EAP 7 documentation since all the configuration required to get second level cache (powered by Infinispan behind the scenes) is this:
<persistence-unit name="...">
(...) <!-- other configuration -->
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
<properties>
<property name="hibernate.cache.use_second_level_cache" value="true" />
<property name="hibernate.cache.use_query_cache" value="true" />
</properties>
</persistence-unit>
https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.1/html/development_guide/java_persistence_api_jpa#second_level_caches
The hibernate version should be 5.0.x.
persistence.xml :
<persistence ...>
<persistence-unit ...>
...
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode> <!-- ADD THIS -->
<properties>
...
<property name="hibernate.cache.use_second_level_cache" value="true" /> <!-- KEEP THIS -->
</properties>
</persistence-unit>
</persistence>
Remove all other hibernate.cache.* properties----leaving only the above
Note that using the above setting you must explicitly mark entities as #Cacheable. It can be used the ALL setting for shared-cache-mode if not wish to explicitly mark each entity as #cacheable---- and then all entities would be cached.
Additional documentation on configuration and implementation may be found in
EAP 7: Hibernate 5 User Guide(http://docs.jboss.org/hibernate/orm/5.0/userguide/html_single/Hibernate_User_Guide.html#caching) and Hibernate 5 Developer Guide(http://docs.jboss.org/hibernate/orm/5.0/devguide/en-US/html_single/#d5e1433) and Infinispan 8 User Guide(http://infinispan.org/docs/8.1.x/user_guide/user_guide.html)
I have a JavaFX Maven project in IntelliJ, which uses Hibernate. When the app is starting, I am getting the following error message:
No persistence provider for entitymanager named xyz
Why? My META-INF/persistence.xml is located in myproject/src/main/resources (the directory is checked as resource folder in project settings).
I am sure I've downloaded all Hibernate JARs via Maven.
My persistence.xml is correct:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="xyz">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>entity.User</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLiteDialect"/>
<property name="javax.persistence.jdbc.url" value="jdbc:sqlite:java.sqlite"/>
<property name="javax.persistence.jdbc.driver_class" value="oracle.jdbc.driver"/>
<property name="hibernate.hbm2ddl.auto" value="none"/>
<property name="hibernate.show_sql" value="false"/>
<property name="javax.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>
</persistence>
Java code:
factory = Persistence.createEntityManagerFactory("xyz");
In my an old non-Maven project the code above worked fine.
your persistence.xml must be located in the META-INF folder
There was a different context and solution in my case:
Context:
see the log below:
org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001005: using driver [org.h2.Driver] at URL [jdbc:h2:tcp://localhost/~/test]
org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001001: Connection properties: {user=sa}
org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001003: Autocommit mode: false
org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections <init>
INFO: HHH000115: Hibernate connection pool size: 20 (min=1)
org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
...
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named NewPersistenceUnit`
Solution:
As its clear from logs above, persistenceUnit has been found and some data like dialect, username and password is extracted.
There was problem in mapping of entities. By commenting out #Entity one by one on entities, I was able to find the problem and solve it, without any change in persistence.xml file.
I have no idea why error like No Persistence provider for EntityManager named X should be shown when there is a problem in entity mapping!
I am trying to play around with Kundera 2.5.1 on JBoss EAP 6.1 (essentially the same as JBoss AS 7.1). However, when I deploy my application, I see the following Exception:
[0m[31m12:44:24,119 ERROR org.jboss.msc.service.fail MSC000001: Failed to start service jboss.persistenceunit."KunderaTests-ear.ear/KunderaTests-ejb.jar#KunderaTests": org.jboss.msc.service.StartException in service jboss.persistenceunit."KunderaTests-ear.ear/KunderaTests-ejb.jar#KunderaTests": com.impetus.kundera.loader.PersistenceLoaderException: com.impetus.kundera.utils.InvalidConfigurationException: Could not find any META-INF/persistence.xml file in the classpath
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:103) [jboss-as-jpa-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_07]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_07]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_07]
at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.0.Final-redhat-1.jar:2.1.0.Final-redhat-1]
Caused by: com.impetus.kundera.loader.PersistenceLoaderException: com.impetus.kundera.utils.InvalidConfigurationException: Could not find any META-INF/persistence.xml file in the classpath
at com.impetus.kundera.configure.PersistenceUnitConfiguration.configure(PersistenceUnitConfiguration.java:103)
at com.impetus.kundera.configure.Configurator.configure(Configurator.java:65)
at com.impetus.kundera.KunderaPersistence.initializeKundera(KunderaPersistence.java:104)
at com.impetus.kundera.KunderaPersistence.createEntityManagerFactory(KunderaPersistence.java:77)
at com.impetus.kundera.KunderaPersistence.createContainerEntityManagerFactory(KunderaPersistence.java:65)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:200) [jboss-as-jpa-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$600(PersistenceUnitServiceImpl.java:57) [jboss-as-jpa-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:99) [jboss-as-jpa-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]
... 4 more
Caused by: com.impetus.kundera.utils.InvalidConfigurationException: Could not find any META-INF/persistence.xml file in the classpath
at com.impetus.kundera.configure.PersistenceUnitConfiguration.findPersistenceMetadatas(PersistenceUnitConfiguration.java:131)
at com.impetus.kundera.configure.PersistenceUnitConfiguration.configure(PersistenceUnitConfiguration.java:86)
... 11 more
The Kundera JARs (core & cassandra) are deployed within my EAR. There is a Web application project, and a separate EJB project that houses the entities. The persistence.xml file is in the EJB project under the src/META-INF path, but I still get this exception. I do not have any problems with other JPA providers, such as Hibernate.
My persistence.xml file looks like this:
<persistence 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"
version="2.0">
<persistence-unit name="KunderaTests">
<provider>com.impetus.kundera.KunderaPersistence</provider>
<properties>
<property name="kundera.nodes" value="localhost" />
<property name="kundera.port" value="9160" />
<property name="kundera.keyspace" value="dev" />
<property name="kundera.dialect" value="cassandra" />
<property name="kundera.client.lookup.class"
value="com.impetus.client.cassandra.pelops.PelopsClientFactory" />
</properties>
</persistence-unit>
</persistence>
Am I missing something? Does my configuration look okay? Or, is this an issue with deploying Kundera on JBoss EAP 6.1?
Have a look at
https://groups.google.com/forum/#!topic/kundera-discuss/x0AqH_Te6eQ.
See if it helps.
-Vivek
Solved by upgrading to the latest trunk.
I'm having trouble using the new multi tenant feature of hibernate 4.1.3
I'm using Glassfish 3.1 with JPA2 and Hibernate 4.1.3 as provider.
This is my persistence.xml
<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="AuroraServicePU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/sqlserver/Aurora</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.default_batch_fetch_size" value="100"/>
<property name="hibernate.cache.use_second_level_cache" value="false"/>
<property name="hibernate.cache.use_query_cache" value="false"/>
<property name="hibernate.tenant_identifier_resolver" value="org.dna.aurora.web.TenantResolver" />
<property name="hibernate.multiTenancy" value="DISCRIMINATOR" />
</properties>
</persistence-unit>
</persistence>
This is the exception I get when try to deploy the application.
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final} INFO:
HHH000412: Hibernate Core {4.1.3.Final} INFO: HHH000206:
hibernate.properties not found INFO: HHH000021: Bytecode provider name
: javassist INFO: HHH000204: Processing PersistenceUnitInfo [ name:
AuroraServicePU ...] SEVERE: Exception while invoking class
org.glassfish.persistence.jpa.JPADeployer prepare method SEVERE:
Exception while preparing the app SEVERE: The log message is null.
java.lang.NullPointerException at
org.hibernate.engine.jdbc.internal.JdbcServicesImpl$MultiTenantConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcServicesImpl.java:260)
at
org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:117)
at
org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
at
org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
at
org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
at
org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71)
at
org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2277)
at
org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2273)
at
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1742)
at
org.hibernate.ejb.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:76)
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
at
org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
at
org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:205)
at
org.glassfish.persistence.jpa.PersistenceUnitLoader.(PersistenceUnitLoader.java:119)
at
org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:213)
at
org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:486)
at
org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:220)
at
org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:166)
at
com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:870)
at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:410)
at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at
org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:370)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1067)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1247)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
at
com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:465)
at
com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:222)
at
com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
at
com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:234)
at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:619)
SEVERE: Exception while preparing the app
UPDATE:
I've read the docs again and notice this important peace of information:
DISCRIMINATOR Correlates to the partitioned (discriminator) approach.
It is an error to attempt to open a session without a tenant
identifier using this strategy. This strategy is not yet implemented
in Hibernate as of 4.0 and 4.1. Its support is planned for 5.0.
Is that really means the discriminator strategy is not available right now?
Maybe this is the whole problem?
Any help will be great.
Thank you,
Ido.
You have not specified how Hibernate should obtain connections. Did you read the docs related to this? http://docs.jboss.org/hibernate/orm/4.1/devguide/en-US/html_single/#d5e4583
And specifically:
http://docs.jboss.org/hibernate/orm/4.1/devguide/en-US/html_single/#d5e4658
http://docs.jboss.org/hibernate/orm/4.1/devguide/en-US/html_single/#d5e4702
I have been recently running into an issue in which my web application will not start properly and the stack trace doesn't indicate exactly what happened. I have been able to isolate it to an event listener that I wrote. Whenever I attempt to activate it, I get a very generic exception:
org.jboss.seam.InstantiationException: Could not instantiate Seam component: entityManagerFactory
at org.jboss.seam.Component.newInstance(Component.java:2144)
at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:116)
at org.jboss.seam.init.Initialization.init(Initialization.java:740)
at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:36)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:645)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:189)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:978)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:586)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:349)
at org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:102)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:165)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:162)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:165)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:92)
at org.eclipse.jetty.server.Server.doStart(Server.java:228)
at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:69)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:433)
at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:377)
at org.mortbay.jetty.plugin.JettyRunWarMojo.execute(JettyRunWarMojo.java:68)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Now, I had this problem in the past, and that was caused by me trying to over optimize each entity class by making the setters and getters final. Hibernate needs to setup proxying for the entity classes so it can lazy load stuff, so if I make a setter/getter final, it can't do that.
The event listener I want to use essentially listens for persist and update events. When one happens, it is supposed to set the current date on a field annotated with the corresponding annotation to mark the field as requiring a current date to be set.
I am thinking that this is because I am running a newer version of javassist:
javassist:javassist:jar:3.11.0.GA:runtime
Has anyone run into this issue before?
I am running JBoss Seam 2.2.0.GA on Jetty 7.
persistence.xml (abbreviated version)
<?xml version="1.0" encoding="UTF-8"?>
<persistence 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_1_0.xsd"
version="1.0">
<persistence-unit name="${jdbc.database}" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>${jdbc.datasource.name}</non-jta-data-source>
<class> ... classes go here </class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect" value="${hibernate.dialect}"/>
<property name="hibernate.hbm2ddl.auto" value="${ddl.mode}"/>
<property name="hibernate.show_sql" value="${hibernate.showSql}"/>
<property name="format_sql" value="${hibernate.formatSql}"/>
<property name="use_sql_comments" value="${hibernate.useSqlComments}"/>
<property name="hibernate.jdbc.batch_versioned_data" value="true"/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.EHCacheProvider"/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider"/>
<property name="hibernate.cache.use_query_cache" value="true"/>
<property name="hibernate.cache.provider_configuration_file_resource_path" value="/ehcache.xml"/>
<property name="hibernate.connection.release_mode" value="after_transaction"/>
<property name="hibernate.connection.autocommit" value="true"/>
<!-- Current Date listeners -->
<!--
<property name="hibernate.ejb.event.pre-insert" value="org.hibernate.ejb.event.EJB3PersistEventListener,com.walterjwhite.listener.persistence.listener.SetCurrentDateListener"/>
<property name="hibernate.ejb.event.pre-update" value="org.hibernate.ejb.event.EJB3MergeEventListener,com.walterjwhite.listener.persistence.listener.SetCurrentDateListener"/>
-->
<!-- Envers listeners -->
<property name="hibernate.ejb.event.post-insert" value="org.hibernate.ejb.event.EJB3PostInsertEventListener,org.hibernate.envers.event.AuditEventListener"/>
<property name="hibernate.ejb.event.post-update" value="org.hibernate.ejb.event.EJB3PostUpdateEventListener,org.hibernate.envers.event.AuditEventListener"/>
<property name="hibernate.ejb.event.post-delete" value="org.hibernate.ejb.event.EJB3PostDeleteEventListener,org.hibernate.envers.event.AuditEventListener"/>
<property name="hibernate.ejb.event.pre-collection-update" value="org.hibernate.envers.event.AuditEventListener"/>
<property name="hibernate.ejb.event.pre-collection-remove" value="org.hibernate.envers.event.AuditEventListener"/>
<property name="hibernate.ejb.event.post-collection-recreate" value="org.hibernate.envers.event.AuditEventListener"/>
<!-- Hibernate Search -->
<property name="hibernate.search.default.directory_provider" value="org.hibernate.search.store.FSDirectoryProvider"/>
<property name="hibernate.search.default.indexBase" value="${application.directory}/lucene/indexes"/>
</properties>
</persistence-unit>
</persistence>
When I use Javassist 3.4.GA instead of 3.11.GA, I get this error.
java.lang.IllegalAccessError: tried to access class javassist.bytecode.StackMapTable$Writer from class org.jboss.seam.util.ProxyFactory
at org.jboss.seam.util.ProxyFactory.makeConstructor(ProxyFactory.java:803)
at org.jboss.seam.util.ProxyFactory.makeConstructors(ProxyFactory.java:685)
at org.jboss.seam.util.ProxyFactory.make(ProxyFactory.java:565)
at org.jboss.seam.util.ProxyFactory.createClass3(ProxyFactory.java:346)
at org.jboss.seam.util.ProxyFactory.createClass2(ProxyFactory.java:325)
at org.jboss.seam.util.ProxyFactory.createClass(ProxyFactory.java:284)
at org.jboss.seam.Component.createProxyFactory(Component.java:2426)
at org.jboss.seam.Component.getProxyFactory(Component.java:1513)
at org.jboss.seam.Component.wrap(Component.java:1504)
at org.jboss.seam.Component.instantiateJavaBean(Component.java:1442)
at org.jboss.seam.Component.instantiate(Component.java:1359)
at org.jboss.seam.Component.newInstance(Component.java:2122)
at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:116)
at org.jboss.seam.init.Initialization.init(Initialization.java:740)
at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:36)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:645)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:189)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:978)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:586)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:349)
at org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:102)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:165)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:162)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:165)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:92)
at org.eclipse.jetty.server.Server.doStart(Server.java:228)
at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:69)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:433)
at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:377)
at org.mortbay.jetty.plugin.JettyRunWarMojo.execute(JettyRunWarMojo.java:68)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Walter
My advice is:
Always generate your project by using Seam-gen
This way, you do not have to worry about libraries that your project needs.
Message is:
org.jboss.seam.InstantiationException: Could not instantiate Seam component: entityManagerFactory
Have you set up your EntityManagerFactory ?
If not, do as follows (I suppose you are not using JTA environment. So i will show you a RESOURCE_LOCAL EntityManagerFactory)
/WEB-INF/components.xml
<!--I AM USING 2.1 version-->
<!--SO I SUPPOSE YOU HAVE TO REPLACE 2.1 by 2.2-->
<components xmlns="http://jboss.com/products/seam/components"
xmlns:core="http://jboss.com/products/seam/core"
xmlns:persistence="http://jboss.com/products/seam/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.xsd
http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.1.xsd
http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd">
<!--SET UP A MANAGED EntityManagerFactory-->
<!--DEFAULT TO ScopeType.APPLICATION-->
<persistence:entity-manager-factory name="entityManagerFactory" persistence-unit-name="<PERSISTENCE_UNIT_NAME_MUST_MATCH_NAME_ATTRIBUTE_IN_PERSISTENCE.XML>"/>
<!--SET UP A MANAGED EntityManager-->
<!--DEFAULT TO ScopeType.CONVERSATION-->
<persistence:managed-persistence-context name="entityManager" entity-manager-factory="#{entityManagerFactory}" auto-create="true"/>
<!--SET UP SEAM TRANSACTION MANAGER-->
<!--IT TAKES CARE OF CALLING BEGIN AND COMMIT-->
<tx:entity-transaction entity-manager="#{entityManager}"/>
</components>
Notice when using auto-create attribute equal true, you do not have to set up create attribute in #In annotation
// You do not need to set up create attribute
// because of auto-create atrribute in persistence:managed-persistence-context component
#In(create=true)
private EntityManager entityManager;
Takes care by using naming convention, EntityManager reference must match name attribute in persistence:managed-persistence-context component.
Now you have to define your /META-INF/persistence.xml
/META-INF/persistence.xml
<persistence-unit name="<PERSISTENCE_UNIT_NAME_GOES_HERE>" transaction-type="RESOURCE_LOCAL">
// Set up properties here
</persistence-unit>
If you are using a data source that can be obtained by JNDI - you need to set up according your target application server (TOMCAT, JETTY etc), do as follows
/META-INF/persistence.xml
<persistence-unit name="<PERSISTENCE_UNIT_NAME_GOES_HERE>">
<non-jta-data-source>jdbc/myAppDS</non-jta-data-source>
</persistence-unit>
And if you want to set up a current date, do as follows instead of using Hibernate event
<!--currentDate IS A BUILT-IN Seam component-->
<!--DEFAULT TO ScopeType.STATELESS-->
<!--ScopeType.STATELESS IS SIMILAR TO Spring prototype scope-->
<h:inputHidden value="#{currentDate}" rendered="false" binding="#{myBackingBean.currentDate}"/>
About final keyword, maybe you want to see I get a log message: reflection optimizer disabled
regards,
Well, I didn't really get any good answers. In this particular instance that I had the problem, the problem was having an incorrect version of my dependencies configured. That is one of the negatives with having my projects split up as much as they are. I have to pay close attention to which version I'm using in each project.
In other cases, it seemed to me that I had issues with a Lucene configuration. In either case, I would prefer to see the stack trace so I can look at it and then, oops, I have a bad jar or something like that.
Walter