I am running Kundera 2.8.1 . when i'm configuring ehcache in my persistence.xml its not being picked up. I have a ehcache-test.xml file configured in my classpath. On inspecting i'm finding that Kundera is not picking up the properties from persistence.xml.
In the constructor for EntityManagerFactoryImpl the Map properties is null.
Is this a bug in this release?
Did you define
<property name="kundera.cache.provider.class"
value="com.impetus.kundera.cache.ehcache.EhCacheProvider" />
<property name="kundera.cache.config.resource" value="/ehcache-test.xml" />
Related
I am trying to apply a persistence framework to an eclipse rcp e4 application. For this purpose, I created an example of a feature project, almost following the tutorial https://www.vogella.com/tutorials/JavaPersistenceAPI/article.html, but adapting for rcp. However I got the error "Persistence provider for EntityManager named xxx not found". I have searched for a week but found no solution. Could someone please tell me, what the error really is and how to resolve it?
The persistence.xml is located in project tasks.model folder META-INF. The eclipse.jar and javax.persistence.jar are in another plugin project (Earlier I defined maven dependencies in pom.xml. Although eclipse reports no compilation errors, but running rcp product would result in an error that ClassDefNotFoundException for persistence, so putting javax.persistence.jar in a separate plugin removed this error). Some answers suggested that the persistence.xml should be in the folder src/resources/META-INF. But in a plugin project the folder META-INF is already in its default place. I even created an extra folder resources/META-INF and put the persistence.xml in that, but it did not help. If I created a normal maven project, then things work properly, also when I change the database to mysql in localhost. The errors appear when I convert the project into a plugin project for building rcp applications.
The error "No Persistence provider for EntityManager" occurs when I invoke the command:
factory = Persistence.createEntityManagerFactory("todos");
My persistence.xml file looks like:
<?xml version="1.0" encoding="UTF-8" ?>
<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" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="todos" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>tasks.model.Todo</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
<property name="javax.persistence.jdbc.url" value="jdbc:derby:/tempGeo/simpleDB" />
<property name="javax.persistence.jdbc.user" value="test" />
<property name="javax.persistence.jdbc.password" value="test" />
<!-- EclipseLink should create the database schema automatically -->
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
</properties>
</persistence-unit>
</persistence>
i defined some Entities and want to generate the tables now.
I use Eclipselink 2.5 (JPA 2.1) and Glassfish 4.0 and my Program uses JKD7.
When i build the application there are the following messages:
warning: Supported source version 'RELEASE_6' from annotation processor 'org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor' less than -source '1.7'
Note: Creating static metadata factory ...
Note: Optional file was not found: META-INF/orm.xml continuing with generation.
Note: Optional file was not found: META-INF/eclipselink-orm.xml continuing with generation.
Note: Optional file was not found: META-INF/orm.xml continuing with generation.
Note: Optional file was not found: META-INF/eclipselink-orm.xml continuing with generation.
I don't know what i need to do now...
i have the latest EclipseLink version
latest version of glassfish
jkd 7
just the standard derby database (delivered with glassfish 4.0)
how can i solve this?
EDIT 1:
<properties>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
<property name="eclipselink.ddl-generation.output-mode" value="database"/>
</properties>
just put these lines in persistance.xml:
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
<property name="eclipselink.ddl-generation-mode" value="ddl_database_generation" />
I had the same problem, found the solution here.
Change this setting on netbeans:
[RUN>SET PROJECT CONFIGURATION>Customize>Build>Compiling> Disable Annotation Processing]
I created a project using Netbeans and selected Glassfish 3.1 as a server, it also uses Derby database. Now I want to migrate to Apache Tomcat 7, I just did the following:
Stopped Glassfish
Changed the Netbeans project's properties to use Apache 7 instead of Glassfish
Added Apache to Netbeans and started it
When I try to build the project, several error messages appear like:
error: cannot find symbol
import javax.persistence.Basic;
although I ensured that /bin path of Java is set correctly in Apache server properties in Netbeans and that src.zip path is also set.
I think there are some steps that must be followed to have a successful migration, can any one guide me?
Thanks
Apache Tomcat does not come with the JPA specification. It is a Servlet container only.
You must add JPA specification plus Hibernate (implementation) to your project and make sure it will be deployed on your WEB-INF/lib.
Then, make sure your Persistence Unit is of transaction-type="RESOURCE_LOCAL", and configure all necessary properties to create a connection.
Example:
<persistence-unit name="bookmark-ds" transaction-type="RESOURCE_LOCAL">
<class>com.sample.domain.YourEntity</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver" />
<property name="javax.persistence.jdbc.user" value="sa" />
<property name="javax.persistence.jdbc.password" value="" />
<property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:mem:." />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
</properties>
</persistence-unit>
Obs: this is an HSQLDB example. Adjust for Derby. ;-)
UPDATE: there's a great tutorial for Tomcat+JPA+EclipseLink here.
How can I add an entire folder to Velocity and use the files inside as resource bundles?
Currently in my velocity.xml I have this code:
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="parentMessageSource">
<ref bean="globMessageSource"/>
</property>
<property name="basenames">
<list>
<value>classpath:/WEB-INF/i18n</value>
<value>/WEB-INF/templates/velocity/my_vm_template</value>
</list>
</bean>
I need to add i18n folder to the classpath so that its containing files can be seen by the VelocityTools version 1.4 in the toolbox.xml:
<tool>
<key>test</key>
<scope>request</scope>
<class>org.apache.velocity.tools.generic.ResourceTool</class>
<parameter name="bundles" value="i18n.ss_messages"/>
<parameter name="locale" value="en_US"/>
</tool>
The code is giving me an error message: "java.util.MissingResourceException: Can't find bundle for base name i18n.ss_messages, locale en_US"
This question relates to VelocityTools error - "java.util.MissingResourceException: Can't find bundle for base name WEB-INF.conf.resources.ss_messages, locale en_US"
Sorry if it's a silly question, but I can't find anywhere describing how to add an entire folder to the classpath and be available as a bundle so it can support Velocity template localization.
IMPORTANT NOTE!! If I place my ss_messages_bg_BG.properties and ss_messages_en_US.properties files in /WEB-INF/classes/i18n then it works, but I want to place them in a different folder ideally in /WEB-INF/templates/i18n. How do I do that?
Do you use maven? You could tell maven to use that directory as a resource:
<resource>
<!-- Velocity requires to be in classpath -->
<directory>src/main/webapp/WEB-INF/i8n</directory>
<filtering>true</filtering>
</resource>
I've read in this post that all the ProxyFactory dependency was removed by using an interface in this post.
So you need to specify which implementation to use in the hibernate.cfg.xml file.
I've this configuration:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">Data Source=.\SQLEXPRESS;Initial Catalog=MYDB;Integrated Security=true</property>
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
<property name='proxyfactory.factory_class'>NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
</session-factory>
</hibernate-configuration>
I've added a refernce to the NHibernate.ByteCode.Castle.dll. When I run the test using MBunit, I get the error that my deployment folder should contain either NHibernate.ByteCode.Castle.dll or NHibernate.ByteCode.LinFu.dll. I guess this is right configuration and it should work. But it is not working. I've spent much time behind this.
P.S: When I donwloaded NHibernate, the NHibernate.ByteCode.Castle project was not built. I added the project to the solution and built it. Then I referenced the assembly.
I had this same situation not too long ago.
When you say you added a reference, was it to the actual project or test project? It should be within both. Also, ensure "Copy Local" is set to true in the properties(F4) of the reference.
Another approach I took to check that if dll is within the directory that the application is running from was by calling the following prior to any of the Configuration.
Console.WriteLine(Directory.GetCurrentDirectory());
In my situation, I learned that when using ReSharper to execute tests, it was running in a location different than I had expected and was not containing the dll. Doing a Clean Solution and rebuilding seemed to correct the issue.
Hope this gives you a couple of things to check.