I´m using hibernate 4.3.6 in my vaadin project.
Every time I make changes in the sources code, it is expected that the application builds again and the new source code is deployed automatically to Tomcat. In other words, Tomcat should reload its context.
The problem is that during this operation hibernate throws an error:
GRAVE: Exception loading sessions from persistent storage
org.hibernate.HibernateException: registry does not contain entity manager factory: myproject
at org.hibernate.jpa.internal.EntityManagerFactoryRegistry.getNamedEntityManagerFactory
(...)
After that log, i get:
24/09/2014 13:14:43 org.apache.catalina.core.StandardContext reload
INFO: Reloading Context with name [/myproject] is completed
However, I cannot continue using the website, since I receive a message saying that session is lost.
My question is: what is this hibernate exception and how can I solve it?
EDIT:
This error only happens when I store in session a JPA Entity, for example: the logged user
I don´t know any way to get what you want, in Tomcat, except with JRebel. The staff of Vaadin itself uses and recommends. Link with interesting information about Vaadin+JRebel: http://zeroturnaround.com/blog/jrebel-case-study-vaadin-eliminates-redeploys-and-saves-10-of-development-time/
If in the future you decide to use Jetty instead of Tomcat, you can make settings and get dynamic reloading of the application as suggested here: https://blog.oio.de/2012/08/23/dynamic-reloading-of-vaadin-applications-with-maven-and-eclipse /
Related
I have a Google Cloud Dataflow application that as part of a transform records some information to a MySQL database through JPA 2 and Hibernate. When running this application with the DirectPipelineRunner it locates the persistence.xml and runs fine.
However, when I try to make use of the BlockingDataflowPipelineRunner the persistence context won't initialize because it can't find the persistence.xml. Maybe it can't be loaded from the CLASSPATH? The message being that the only persistence unit named in the persistence.xml isn't found.
Has anyone successfully used JPA 2 and Hibernate with a Dataflow application? If so, what hoops did you have to jump through to get it working when using the BlockingDataflowPipelineRunner?
Hibernate by default looks for the persistence.xml file in potentially many locations. You may want to confirm that the jars that get uploaded contain META-INF/persistence.xml.
If you add the flag
--workerLogLevelOverrides=org.hibernate#TRACE
, that should give you much more detailed output related to Hibernate (you may need to configure JBoss logging to go to SLF4J or JUL to get the Hibernate logging to appear, docs.jboss.org/hibernate/orm/4.3/topical/html/logging/…).
I'm trying to deploy an application to my GlassFish Server environment. I've set it up so that GlassFish creates a connection pool to a postgreSQL database on another server (not localhost) where the database is located. I test the connection and then try to deploy the application. It fails with a java.lang.RuntimeException: EJB Container initialization error, and my error log contains the following: http://ideone.com/UlZXut (put it here due to its size). There were other warnings above these, but they only referred to tables already existing.
As according to this, I thought that the required sun-cmp-mappings.xml file (the one I assume would be necessary for this correct mapping) would be automatically generated upon deployment, but it seems I was wrong. Could anyone shed some light on this situation?
My apologies if this is not the absolute best part of SE to post this, but it is related to development tools and I did see a number of related posts.
Your error log indicates that you are trying to create table(s) with DOUBLE as a datatype. In Postgresql, that datatype is actually called "double precision". What happens if you revise the table definition to use "double precision" instead?
on startup Glassfish tries to create the DB tables for your java code. It fails to do that and it fails to startup.
Check the configuration of your ORM mapper.
I am using IntelliJ 11 to run a spring mvc application in a Tomcat container as I developer. I have IntelliJ configured so that I can "update resources" to make my jsp changes live without needing a full restart of Tomcat. However, whenever I update the resources, my session in Tomcat is lost and I must re-login to my app.
Is there a way to get Tomcat to recognize my application resource changes while keeping my session alive?
While I reference IntelliJ in the question, it is really about Tomcat in general. A way to do this from IntelliJ would be great but any way to do this would be appreciated.
Tomcat is able to persist sessions across restart. The Standard Implementation uses a file called SESSIONS.ser. Obviously the objects stored is the session must be Serializable.
I would like that my Spring-based web application were able to validate its configuration during startup.
This means for example:
check if the required folders exist and are readable/writable
check if the required configuration keys are set and consistent
...
check any other constraint that is required for the correct functioning
How can you perform these checks and notify the system administrator if something is wrong?
The goal is to reduce the risk that some critical error arises when the application is actually going to need those resources that are bound to the wrong configuration.
NOTE: my approach is to use a special EnvironmentValidation bean that checks if the configuration/folder structure is ok and if not it throws an exception
If you want notifications you could set up an email notifier for example using log4j that would send any exceptions on startup to the system administrator.
if a configuration key is not present spring will not start up anyway.
check the keys are consistent with what?
checking folders exist and are readable/writable isn't something I'd really do in my webapp - this belongs in your deployment infrastructure. Saying that you could write your own custom checks as spring beans, load these first and throw an exception if some of your configuration fails validation.
During startup all errors will be logged in to server logs. Logs can be checked and system administrator can be notified.
I have an app using Wicket for the presentation layer with CDI/Weld, JPA 2.0, EJB 3.1 etc. (Java EE 6) deployed on GlassFish v3.0.1.
When I try to inject an EJB into a wicket page using #EJB I get the following error:
java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName
When I try to inject using #Inject, I get the following error:
java.lang.IllegalStateException: Unable to convert ejbRef for ejb UserRepository to a business object of type class
I believe the problem is stemming from JPA. I am using the exact same configuration that I used with a JSF application which worked properly, so I am lost as to what the issue could be. The connection pools are set up properly and pinging correctly through GlassFish, I have included wicket-weld on the classpath and I have even tried using the old Java EE 5 wicketstuff project for wicketstuff-javaeeapi with the same results.
Any help would be appreciated.
If you get the exception:
Unable to retrieve EntityManagerFactory for unitName
It might mean it is not detecting your persistence.xml file. Make sure it's in the WEB-INF\classes\META-INF directory.
You can verify that your app has JPA enabled by going to the Admin Console in GlassFish, go to the Applications section and see if it shows something like [ejb, web, weld, jpa] for your app. If it doesn't show jpa then it's not finding your JPA config file.
Could always try to lookup the EJB via its standard "java:global" name. That should at least let you rule out wicket as a possible source of issues and get you a little closer to a working system.