Hibernate - createQuery problems

Hi!
I'm getting this exception and can't locate what is wrong:
org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from com.test.model.User where userId = ?]
     org.hibernate.hql.ast.HqlLexer.panic(HqlLexer.java:57)
     antlr.CharScanner.setTokenObjectClass(CharScanner.java:340)
     org.hibernate.hql.ast.HqlLexer.setTokenObjectClass(HqlLexer.java:31)
     antlr.CharScanner.<init>(CharScanner.java:51)
     antlr.CharScanner.<init>(CharScanner.java:60)
     org.hibernate.hql.antlr.HqlBaseLexer.<init>(HqlBaseLexer.java:56)
     org.hibernate.hql.antlr.HqlBaseLexer.<init>(HqlBaseLexer.java:53)
     org.hibernate.hql.antlr.HqlBaseLexer.<init>(HqlBaseLexer.java:50)
     org.hibernate.hql.ast.HqlLexer.<init>(HqlLexer.java:26)
     org.hibernate.hql.ast.HqlParser.getInstance(HqlParser.java:44)
     org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:242)
     org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157)
     org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
     org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
     org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
     org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
     org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
     org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
     org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
     sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     java.lang.reflect.Method.invoke(Method.java:597)
     org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
     $Proxy4.createQuery(Unknown Source)
     com.test.model.UserManager.getUser(UserManager.java:15)
     com.test.test.DefaultController.handleRequest(DefaultController.java:21)
     org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
     org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:858)
     org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:792)
     org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
     org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:431)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)My mapping file looks like this:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.redbet.model">
     <class name="User" table="users">
          <id name="userId" column="userId">
               <generator class="increment" />
          </id>
          <property name="username" column="username" />
     </class>
</hibernate-mapping>And i have put the hibernate and antlr jar files in the lib directory, this is the code that fails, it fails on session.createQuery
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
User result = (User) session.createQuery( "from User where userId = ?" ).setInteger( 0, userId ).uniqueResult();
session.getTransaction().commit();The code for hibernateUtil looks like this:
static {
     try {
          InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream( "hibernate.cfg.xml" );
          Configuration configuration = new Configuration().addInputStream( in ).configure();
          sessionFactory = configuration.buildSessionFactory();
     } catch( Throwable ex ) {
          LOG.fatal( "Could not create session factory: " + ex.getMessage() );
          throw new ExceptionInInitializerError( ex );
public static SessionFactory getSessionFactory() {
     return sessionFactory;
}

Okay it might be that you could have placed few similar files in your
%CATLINA_HOME%\common\libfor quest of sharing the SessionFactory Object at container level is that it ??
If,it is so first remove respective libraries from their and do not try that.Ensure the basic things goes in the right-way.
hibernate-cfg.xml
=================
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
     <property name="connection.driver_class"><!--DRIVER--></property>
     <property name="connection.url"><!--JDBCURL--></property>
     <property name="connection.username"><!--username--></property>
     <property name="connection.password"><!---PASSWORD--></property>
     <property name="connection.pool_size">1</property>
     <property name="dialect"><!--dialect--></property>
     <property name="current_session_context_class">thread</property>
     <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
     <property name="show_sql">false</property>
     <mapping resource="com/test/model/User.hbm.xml" />
  </session-factory>
</hibernate-configuration>HibernateUtils
static {
     try {
                //As the Configuration would automatically check for hibernate-cfg.xml
          Configuration configuration = new Configuration().configure();
                /*please refer http://www.hibernate.org/hib_docs/v3/api/org/hibernate/cfg/Configuration.html#configure()*/
          sessionFactory = configuration.buildSessionFactory();
     } catch( Throwable ex ) {
          LOG.fatal( "Could not create session factory: "+ ex.getMessage() );
          throw new ExceptionInInitializerError( ex );
public static SessionFactory getSessionFactory() {
     return sessionFactory;
}Other than this when i was going through your set of libraries i found that you might using POSTGRESQL-8.2.
And i don't think its been tested over Hibernate platform either.
Please refer. http://www.hibernate.org/80.html
and one more thing i can see that you are using Spring specific libraries as well spring itself provides its own implementation to use hibernate.it could easily be configured and used easily few utility classes(HibernateDAOSupport is one such class which you might of using).
How about trying it instead of re-inventing the wheel by creating your own Utility class ??
if all these don't help i'd advice you go ahead with hibernate/spring forums.
Hope that makes some sense.
REGARDS,
RaHuL

Similar Messages

  • JPA AND HIBERNATE (createquery PB)

    Hi,
    I have an issue in jpa-hibernate program :
    try{
    List dmvs = em.createQuery("select c from Dmv as c order by c.num ASC").getResultList();
    System.err.println("found finsh");
    if (dmvs==null ||dmvs.size() == 0) {
         return -1;
    for (Iterator iter = dmvs.iterator(); iter.hasNext();) {
    Dmv element1 = (Dmv) iter.next();***
    }catch(Exception x){
    x.printStackTrace();
    }the problem is that the em.creatyQueury after 1 or 2 days is blocked and don't return data or exception error !!
    Edited by: user12936212 on 15 juin 2012 03:36
    Edited by: user12936212 on 15 juin 2012 03:45

    Hello,
    You will need to debug your application and obtain a java thread dump when the problem occurs, and possibly check out the locks in the database to see what might be causing the issue. As you are using Hibernate, you might want to post your product specific questions on the particular product forum - or try using TopLink/EclipseLink as the JPA provider and see if you get the same issue.
    Best Regards,
    Chris

  • Hibernate - Spring - problem with mapping (many-to-many)

    Hello,
    I want to map the following situation. I have a table called EDUCATION and a table called SCHOOLS. Between those tables I have an associative table called EDUCATION_SCHOOLS. The (usefull) fields:
    EDUCATION:
    id (long) - PK
    name (varchar)
    versionNr (long)
    SCHOOLS:
    id (long) - PK
    name (varchar)
    versionNr (long)
    EDUCATION_SCHOOLS:
    id (long) - PK
    education_id (long) (FK to EDUCATION.id)
    school_id (long) (FK to SCHOOLS.id)
    name (varchar)
    versionNr (long)
    Their is a Unique Constraint between EDUCATION_SCHOOLS.education_id and EDUCATION_SCHOOLS.school_id.
    What I want to be able to do:
    EDUCATION: select, update, insert
    SCHOOLS: select, update, insert
    EDUCATION_SCHOOLS: select, update (only the non-FK fields), insert
    I never want to delete anything in those tables. (and it's never ever going to be an option either)
    Hibernate version:
    Hibernate-Version: 3.0.5
    Mapping documents:
    Education:
    <hibernate-mapping>
         <class name="##.Education" table="EDUCATION">
              <id name="id" column="ID" type="java.lang.Long">
                   <generator class="sequence">
                        <param name="sequence">EDUCATION_SEQ</param>
                   </generator>
              </id>
              <version name="versionNr" column="VERSIONNR" type="long"/>
              <property name="name" column="NAME" type="string" />
            <set name="SCHOOLS" table="EDUCATION_SCHOOLS">
                <key column="EDUCATION_ID" />
                <many-to-many class="##.Schools" column="SCHOOL_ID" lazy="false" />
            </set>
    </hibernate-mapping>
    Schools:
    <hibernate-mapping>
         <class name="##.Schools" table="SCHOOLS">
              <id name="id" column="ID" type="java.lang.Long">
                   <generator class="sequence">
                        <param name="sequence">SCHOOLS_SEQ</param>
                   </generator>
              </id>
              <version name="versionNr" column="VERSIONNR" type="long"/>
              <property name="name" column="NAAM_NAME" type="string" />
            <set name="educations" table="EDUCATION_SCHOOLS" inverse="true" cascade="none">
                <key column="SCHOOL_ID" />
                <many-to-many class="##.Schools" column="SCHOOL_ID" lazy="proxy"/>
            </set>
    </hibernate-mapping>
    Education_schools:
    <hibernate-mapping>
    <class name="##.EducationSchools" table="EDUCATION_SCHOOLS">
               <id name="id" column="ID" type="java.lang.Long" unsaved-value="0">
                   <generator class="sequence">
                        <param name="sequence">SEQ_EDUCATION_SCHOOLS</param>
                   </generator>
              </id>
              <version name="versionNr" column="VERSIONNR" type="long" />
              <many-to-one name="education" class="##.Education" cascade="none" lazy="proxy"
                           column="EDUCATION_ID" not-null="true"/>
            <many-to-one name="schools" class="##.Schools" cascade="none" lazy="proxy"
                        column="SCHOOL_ID" not-null="true"/>  
    </hibernate-mapping>   
    Name and version of the database you are using:
    Oracle XE 10g
    I am able to:
    EDUCATION: select, insert, update
    SCHOOLS: select, insert, update
    EDUCATION_SCHOOLS: select
    Problems:
    EDUCATION_SCHOOLS: when I try to insert, I sometimes get unique constraint violations. (when I should get them, thus I'm trying to insert something that already exists .. but how do I stop Hibernate from Inserting?)
    EDUCATION_SCHOOLS: when I try to update, sometimes it works, but often I get:
    23:03:55,484 [http-8081-1] ERROR be.vlaanderen.lne.vea.epb.ui.struts.EpbExceptionHandler - org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException: Object of class [##.EducationSchools] with identifier [null]: optimistic locking failed; nested exception is org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [##.EducationSchools#<null>]
    ex.getMessage() Object of class [##.EducationSchools] with identifier [null]: optimistic locking failed; nested exception is org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [##.EducationSchools#<null>]
    org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException: Object of class [##.EducationSchools] with identifier [null]: optimistic locking failed; nested exception is org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [##.EducationSchools#<null>]
    Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect):As you can see from the stacktrace I use Spring for the transactionManager: org.springframework.orm.hibernate3.HibernateTransactionManager in which I use e sessionFactory: org.springframework.orm.hibernate3.LocalSessionFactoryBean
    In my DAO, I try to save with the regular this.getHibernateTemplate().saveOrUpdate that has always worked for me.
    Another problem I have:
    when i update "name" in EDUCATION, the records with that ID are delete from EDUCATION_SCHOOLS ...
    As I am experiencing 3 different problems, I'm pretty sure something is wrong in the mapping files .. however I fail to find out what .. Any input would be greatly appreciated.
    (I translated some class/table-names, that's what the ## cause)
    Edited by: Bart_Blommaerts on Jul 29, 2008 11:53 PM

    Thank you for your input.
    When I try what you suggest, I still get the same error:
    16:39:30,406 [http-8081-1] ERROR ###.EpbExceptionHandler - org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException: Object of class [###.EducationSchools] with identifier [2]: optimistic locking failed; nested exception is org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [###.EducationSchools#2]
    ex.getMessage() Object of class [###.EducationSchools] with identifier [2]: optimistic locking failed; nested exception is org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [###.EducationSchools#2]
    org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException: Object of class [###.EducationSchools] with identifier [2]: optimistic locking failed; nested exception is org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [###.EducationSchools#2]
    Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [###.EducationSchools#2]If you had to map the database tables, I'm trying to map, how would you do it?

  • Struts, hibernate, mysql problem

    I am using eclipse, struts, hibernate, mysql, tomcat to run my web application. When I try to run more than one application that using hibernate, then all the application will hang. I am only able to run one application at a time and keep changing the host in server.xml if I want to run other application that use hibernate.
    This problem occur only when I run more than one application that using hibernate. So is anyone know why does this happen??? help plx..........

    http://docs.jboss.org/jbossas/jboss4guide/r4/html/ch13.html

  • CreateQuery Problem: GROUP BY with SUM()

    Hello,
    I have a problem with the following query:
    query = em.createQuery("select SUM(t.time),t.user,t.task from Time t group by t.task");
    The query works and returns an collection of Time-objects.
    The problem is now, that the value of the time-property of each Time-object does not have the value of the SUM(t.time) function.
    What I'm doing wrong ?
    Thanks for your help,
    Mario

    Hi opie,
    thanks for your reply.
    Im made a mistake in my code line :
    I use createNativeQuery not createQuery, sorry.
    So here is the complete method :
    @Override
    public Collection<Time> getTimeCollection(){
    Query query = em.createNativeQuery(
    "SELECT SUM(t.time),t.task,t.user,t.creationDate FROM Time t " +
    "GROUP BY t.task", Time.class);
    return query.getResultList();
    The query returns the correct collection, but the the value of the SUM-function is not correct.
    The value is allways set to the value of the first entry found in the database. The SUM will not be calculated.
    Regards,
    Mario

  • SUN AppServer PE 8.2 with Hibernate security problems

    All,
    I have an EAR (EJB + WEB) successfully deployed and working on JBoss 4.0.3SP1, IBM WebSphere, BEA Weblogic. I am currently trying to deploy it on SUN AppServer PE 8.2 and am running into lots of security issues.
    So far I had to add the following to my /home/sandeepk/apps/SUNWappserver/domains/domain1/config/server.policy file:
    grant {
    // Permission for allowing Hibernate read/write from it's configuration files.
         permission java.util.PropertyPermission "*", "read,write";
    // Permission for cglib part of Hibernate framework
    permission java.lang.RuntimePermission "getProtectionDomain";
    permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
         // Permissions to get Apache Axis to work
    permission java.lang.RuntimePermission "createClassLoader";
         permission java.lang.RuntimePermission "getClassLoader";
    grant codeBase "file:${com.sun.aas.installRoot}/domains/domain1/applications/j2ee-modules/-" {
    permission java.security.AllPermission;
    The above additions resolved Apache Axis and Hibernate SessionFactory security issues but I still get the following Exception which I am not able to figure out how to resolve.
    javax.ejb.EJBException
    at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:2807)
    at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:2713)
    at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:2521)
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:819)
    at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:160)
    at $Proxy174.findHelpScreenObjectsNoGuid(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(Unknown Source)
    at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(Unknown Source)
    at com.adminserver.dal._HelpScreenFacadeRemote_DynamicStub.findHelpScreenObjectsNoGuid(_HelpScreenFacadeRemote_DynamicStub.java)
    at com.adminserver.utl.HibernateInitUtl.init(HibernateInitUtl.java:43)
    at javax.servlet.GenericServlet.init(GenericServlet.java:261)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
    at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
    at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
    at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:118)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1093)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:931)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4183)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4536)
    at com.sun.enterprise.web.WebModule.start(WebModule.java:241)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1086)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:847)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1086)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:483)
    at org.apache.catalina.startup.Embedded.start(Embedded.java:894)
    at com.sun.enterprise.web.WebContainer.start(WebContainer.java:741)
    at com.sun.enterprise.web.PEWebContainer.startInstance(PEWebContainer.java:515)
    at com.sun.enterprise.web.PEWebContainerLifecycle.onStartup(PEWebContainerLifecycle.java:54)
    at com.sun.enterprise.server.ApplicationServer.onStartup(ApplicationServer.java:300)
    at com.sun.enterprise.server.PEMain.run(PEMain.java:294)
    at com.sun.enterprise.server.PEMain.main(PEMain.java:220)
    Caused by: java.lang.IllegalStateException: Operation not allowed
    at com.sun.ejb.containers.PMTransactionManagerImpl.suspend(PMTransactionManagerImpl.java:91)
    at org.hibernate.cache.TreeCache.suspend(TreeCache.java:101)
    at org.hibernate.cache.TreeCache.put(TreeCache.java:71)
    at org.hibernate.cache.TransactionalCache.put(TransactionalCache.java:50)
    at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:126)
    at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:530)
    at org.hibernate.loader.Loader.doQuery(Loader.java:436)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
    at org.hibernate.loader.Loader.doList(Loader.java:1593)
    at org.hibernate.loader.Loader.list(Loader.java:1577)
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
    at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
    at com.adminserver.dal.HelpScreenFacadeEJB.findHelpScreenObjectsNoGuid(HelpScreenFacadeEJB.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at com.sun.enterprise.security.SecurityUtil$2.run(SecurityUtil.java:153)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.enterprise.security.application.EJBSecurityManager.doAsPrivileged(EJBSecurityManager.java:957)
    at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:158)
    at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:151)
    ... 36 more
    Any ideas?
    --Sandeep Khanna                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    My guess is that the hibernate code is assuming there's a fully-functional transaction manager available at "java:pm/TransactionManager". The J2EE SDK codebase has an internal TM available there but it doesn't support all TM operations, which is why it throws an exception during suspend(). The spec doesn't require that anything be available at java:pm/TransactionManager. There was a requirement for it in an early version of the EJB 2.0 spec but it was removed along with the other container/persistence-manager pluggability contracts in the final release of EJB 2.0.

  • Struts-Hibernate Postgresql problem

    Hi all!,
    i have been developing a web application using struts-hibernate concept with postgresql as database., (Postgres- 7.3.2, Hibernate- 2.0, MyEclipse     - 3.1.2)
    When i insert the value the following error occurs,
    root cause
    java.lang.ArrayIndexOutOfBoundsException: 1
         org.postgresql.core.QueryExecutor.sendQuery(QueryExecutor.java:143)
         org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:65)
         org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:451)
         org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:281)
         org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:48)
         org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:179)
         org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:165)
         org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:80)
         org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
         org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)
         org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
         org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
         org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
         org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
         org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
         org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
         org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
         com.etm.manager.DistrictLoginUserManager.saveDistrictLoginUser(DistrictLoginUserManager.java:162)
         com.etm.struts.action.DistrictLoginEditAction.saveDistrictLogin(DistrictLoginEditAction.java:60)
         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         java.lang.reflect.Method.invoke(Method.java:585)
         org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
         org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)
         org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
         org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    thanks in advance,

    Here is my code:
    public void saveDistrictLoginUser(DistrictLoginUser districtloginuserValue) {
              // a Hibernate session
              Session session = null;
              Transaction tx = null;
              try {
                   // get session of the current thread
                   session=ETMSessionFactory.currentSession();
                   tx = session.beginTransaction();
                   DistrictLoginUser districtloginuser;
                   if (districtloginuserValue.getDistrictloginid() != null && districtloginuserValue.getDistrictloginid().intValue() != 0) {
                        districtloginuser = (DistrictLoginUser)session.get(DistrictLoginUser.class,districtloginuserValue.getDistrictloginid());
                        if (districtloginuser != null) {
                             districtloginuser.setDistrictid(districtloginuserValue.getDistrictid());
                             districtloginuser.setDistrictusername(districtloginuserValue.getDistrictusername());
                             districtloginuser.setDistrictpassword(districtloginuserValue.getDistrictpassword());
                             districtloginuser.setDistrictfirstname(districtloginuserValue.getDistrictfirstname());
                             districtloginuser.setDistrictemail(districtloginuserValue.getDistrictemail());
                             districtloginuser.setDistrictdesignation(districtloginuserValue.getDistrictdesignation());
                             session.update(districtloginuser);
                   else
                        districtloginuser = new DistrictLoginUser();
                        districtloginuser.setDistrictid(districtloginuserValue.getDistrictid());
                        districtloginuser.setDistrictusername(districtloginuserValue.getDistrictusername());
                        districtloginuser.setDistrictpassword(districtloginuserValue.getDistrictpassword());
                        districtloginuser.setDistrictfirstname(districtloginuserValue.getDistrictfirstname());
                        districtloginuser.setDistrictemail(districtloginuserValue.getDistrictemail());
                        districtloginuser.setDistrictdesignation(districtloginuserValue.getDistrictdesignation());
                        session.save(districtloginuser);
                   tx.commit();
              } catch (HibernateException e) {
                   e.printStackTrace();
                   // it is recommended to roll back the transaction after an error occured
                   if (tx != null) try {
                        tx.rollback();
                   } catch (HibernateException e1) {
                        e1.printStackTrace();
              } finally {
                   try {
                        if (session != null) session.close();
                   } catch (HibernateException e1) {
                        e1.printStackTrace();
    here when i commit the tx it gives the error.,

  • Problem parsing configuration/hibernate.cfg.xml

    I am trying to integrate struts with hibernate. I have created a plug-in for that and copied all the necessary jars & xmls to the classpath. I am providing the full stack trace, can any one say what could be the problem
    net.sf.hibernate.HibernateException: problem parsing configuration/hibernate.cfg
    .xml
    at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:963
    at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:902)
    at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:888)
    at com.plugin.HibernatePlugIn.initHibernate(HibernatePlugIn.java:72)
    at com.plugin.HibernatePlugIn.init(HibernatePlugIn.java:54)
    at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServle
    t.java:869)
    at org.apache.struts.action.ActionServlet.init(ActionServlet.java:336)
    at javax.servlet.GenericServlet.init(GenericServlet.java:211)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
    java:1029)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:86
    2)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex
    t.java:4013)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
    357)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
    .java:823)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:80
    7)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
    at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDep
    loyer.java:277)
    at org.apache.catalina.core.StandardHost.install(StandardHost.java:832)
    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:625
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:431
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:983)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
    :349)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
    eSupport.java:119)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478
    at org.apache.catalina.core.StandardService.start(StandardService.java:4
    80)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:231
    3)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:287)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:425)
    Caused by: org.dom4j.DocumentException: hibernate.sourceforge.net Nested excepti
    on: hibernate.sourceforge.net
    at org.dom4j.io.SAXReader.read(SAXReader.java:358)
    at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:958
    )

    Looks like a problem with Hibernate itself parsing the config file?
    Here's a posting from the Hibernate forum that sounds similar:
    http://forums.hibernate.org/viewtopic.php?p=2256871&highlight=&sid=e1090f717891db4535310102c61bec25
    -steve-

  • Problem while trying to load or access OracleTypes.CURSOR value

    Hi all,
    I configured my datasource as follow
    URL:  jdbc:oracle:thin:@192.10.1.230:1521:interp
    Driver Class Name: oracle.jdbc.xa.client.OracleXADataSource
    an my namedquery is
    +@NamedNativeQuery(name = "generaFoliosRenCot",+
    *+               query = "{ ? = call pkg_renovaciones.fn_rencot_auto(:ageid) }",+*
    *+               resultClass = FoliosGenerados.class,+*
    *+               hints = { @javax.persistence.QueryHint(name = "org.hibernate.callable", value = "true") })+*
    I'm using
    <org.springframework.version>3.0.5.RELEASE</org.springframework.version>
    <org.hibernate.version>3.5.4-Final</org.hibernate.version>
    <com.oracle.jdbc.version>10.2.0.4.0</com.oracle.jdbc.version>
    Weblogic 10.3.4
    when i run my app on junit its run fine
    but when i run my app on weblogic server the problem is when i call a function on oracle 9i the error is:
    +*[02/08/2011 10:00:00 ERROR ServiceThrowsAdvice:doRecoveryActionDataAccess:26] - :::: ** ::::Problem while trying to load or access OracleTypes.CURSOR value; nested exception is org.hibernate.HibernateException: Problem while trying to load or access OracleTypes.CURSOR value*+
    +*org.springframework.orm.hibernate3.HibernateSystemException: Problem while trying to load or access OracleTypes.CURSOR value; nested exception is org.hibernate.HibernateException: Problem while trying to load or access OracleTypes.CURSOR value*+
         at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:679)
         at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
         at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
         at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:339)
         at mx.grupocp.inter.model.dao.impl.FoliosGeneradosDaoImpl.generaFoliosRenCot(FoliosGeneradosDaoImpl.java:28)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
         at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:55)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
         at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
         at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
         at $Proxy206.generaFoliosRenCot(Unknown Source)
         at mx.grupocp.inter.controller.scheduler.jobs.impl.ExecuteShellsImpl.generaFoliosRenovCot(ExecuteShellsImpl.java:86)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
         at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
         at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:55)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
         at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:55)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
         at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:55)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
         at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
         at org.springframework.aop.interceptor.AsyncExecutionInterceptor$1.call(AsyncExecutionInterceptor.java:80)
         at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
         at java.util.concurrent.FutureTask.run(FutureTask.java:138)
         at java.lang.Thread.run(Thread.java:619)
    *+Caused by: org.hibernate.HibernateException: Problem while trying to load or access OracleTypes.CURSOR value+*
         at org.hibernate.dialect.Oracle9Dialect.registerResultSetOutParameter(Oracle9Dialect.java:308)
         at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1609)
         at org.hibernate.loader.Loader.doQuery(Loader.java:717)
         at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270)
         at org.hibernate.loader.Loader.doList(Loader.java:2294)
         at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2172)
         at org.hibernate.loader.Loader.list(Loader.java:2167)
         at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:316)
         at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1832)
         at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
         at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:179)
         at mx.grupocp.inter.model.dao.impl.FoliosGeneradosDaoImpl$1.doInHibernate(FoliosGeneradosDaoImpl.java:34)
         at mx.grupocp.inter.model.dao.impl.FoliosGeneradosDaoImpl$1.doInHibernate(FoliosGeneradosDaoImpl.java:29)
         at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
         ... 37 more
    +*Caused by: java.lang.IllegalAccessException: Class org.hibernate.dialect.Oracle9Dialect can not access a member of class oracle.jdbc.driver.OracleTypes with modifiers ""*+
         at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
         at java.lang.Class.newInstance0(Class.java:349)
         at java.lang.Class.newInstance(Class.java:308)
         at org.hibernate.dialect.Oracle9Dialect.registerResultSetOutParameter(Oracle9Dialect.java:306)
         ... 50 more
    please help me

    Hi,
    Have a look at this tread:
    Re: Problems of hibernate calling oracle stored procedure
    Regards peter

  • Megasky 580 standby problem

    After computer wakes up from standby or hibernate I get the blank screen.
    Only after I remove megasky from usb port I see the picture on monitor.
    I have latest version of software and drivers, all windows update files...
    Since I want to use scheduled recordings can you give me some tip or link
    to the new version of drivers (if existss).
    thanks

    I didn't mention it in my previous mail but same problem with wakeup from standby/hibernate
    happens on my MSI L720 notebook.
    Other applications wake up PC from standby or hibernate without problem on both systems.
    My PC Configuration:
    AMD barton 2500+ mobile, SocketaA, ABIT nForce2 NF7-s: ATI 9100 AGP: 512+256+256 400Mhz RAM: 300+160GB Seagate SATA + PATA HDDs : : MSI MegaSky 580 : onboard LAN : Coolermaster Centurion case : CoolerMaster 380W PSU : Windows XP Pro :

  • Convert HashMap to HashSet for @OneToMany for JPA Hibernate Implementation

    Hi,
    I have a HashMap with @OneToMany relationship as shown below:-
    @Entity
    Class CustomerDetails {
      @OneToMany(fetch = FetchType.EAGER)
      @JoinTable(name="Cust_Order")
      @MapKeyColumn(name="orders_number")
       public Map<String,Order> getOrders() { return orders; }
       public void setOrders(Map<String,Order> orders) { this.orders = orders; }
       private Map<String,Order> orders;
       // getters & setters for orders
    This class does have "N" number of @OneToMany relationships which is represented as "HashMap" and I want all of them to be eagerly loaded.Where it throws HibernateException "Cannot simultaneously fetch Multiple Bags" this is due to multiple collections in CustomerDetails
    with fetchType as "EAGER". Now I want to convert my collection type from HashMap to HashSet so that I can resolve this problem? Please let me know how I can convert HashMap to HashSet as HashMap takes key,value pairs unlike HashSet?
    private Map<String,Order> orders;
    to
    private Set<Order> orders;
    Please clarify the above & is there any better way to do it?
    Thanks.

    Hello,
    I'm not sure exactly what you mean, but there is no problem using eager or lazy access types with either HashMap or HashSets in EclipseLink/TopLink.  As a HashSet is a Set implementation, it is nothing like a Map and cannot be used as a HashMap replacement that I'm aware of.   The code you posted will work with EclipseLink without exceptions being thrown.
    If you have a Hibernate specific problem, you might try posting on that Hibernate's forum for an answer.

  • RED5 + JPA Problem

    Hi,
    First, sry for the english. I am newbie in java and i am stucked in a problem that i think is easy. I have an application that is running perfectly in red5. I am copying the files from this application (laboratory) to other folder in red5's directory WEBAPPS called laboratory2. I restart my Tomcat and red5 services but the following error is shown when i try to access my app from browser
    root cause
    java.lang.ExceptionInInitializerError
         br.inf.mmc.msys.servico.persistencia.jpa.JPAUtil.<clinit>(JPAUtil.java:32)
         br.inf.mmc.msys.web.filter.SegurancaFilter.doFilter(SegurancaFilter.java:48)
    root cause
    javax.persistence.PersistenceException: [PersistenceUnit: laboratorioPU] Unable to build EntityManagerFactory
         org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)
         org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)
    root cause
    org.hibernate.HibernateException: Could not instantiate dialect class
         org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:84)
         org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:42)
         org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:426)
    java.lang.ClassCastException: org.hibernate.dialect.MySQLDialect cannot be cast to org.hibernate.dialect.Dialect
         org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:78)
         org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:42)
         org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:426)
         org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:128)
         org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
    Persistence.xml
    <persistence version="1.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_1_0.xsd">
    <persistence-unit name="laboratory2PU" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <properties>
    <property name="hibernate.connection.username" value="laboratorio"/>
    <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
    <property name="hibernate.connection.password" value="laboratorio"/>
    <property name="hibernate.connection.url" value="jdbc:mysql://127.0.0.1/msysdb?autoReconnect=true"/>
    <property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
    <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
    <property name="hibernate.show_sql" value="false"/>
    <property name="hibernate.hbm2ddl.auto" value="update"/>
    <property name="hibernate.connection.autocommit" value="false"/>
    <property name="current_session_context_class" value="thread"/>
    </properties>
    </persistence-unit>
    </persistence>
    I tried modify the persistence-unit name but the same error was shown. I was thinking that can be linked with jars.
    ty

    Hello,
    I am not overly familar with the products involved so you might want to try forums more specific to the products you are using - though this forum does get general JPA questoins, it is more for TopLink which is a JPA provider.
    From the Exception though it seems like a classloader issue where you might have two different versions of the Hibernate classes being loaded - did you also copy the hibernate jars? You might want to set up shared libraries rather than put tool jars in the application directly.
    Or Try TopLink/EclipseLink as the JPA provider to verifty that it is not a Hibernate specific problem.

  • Plz help with deploying applet that uses SSL

    Hi, maybe this is not the adecuate forum but ive already tried in others and i got no answer.
    Im trying to use a certificate with my applet ( tha sends a lot of info to the server and also connects to another hibernate db) but im getting this error:
    Server side:
    username is: Panda
    Registered the SSLServerSocket on port 6969
    Listening ....
    ---- Got a connection from a client
         this is an unknown client
    !!!!!!Error in reading or writing from/to the client:
    javax.net.ssl.SSLException: Connection has been shutdown: javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.checkEOF(Unknown Source)
         at com.sun.net.ssl.internal.ssl.AppInputStream.read(Unknown Source)
         at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source)
         at sun.nio.cs.StreamDecoder$CharsetSD.implRead(Unknown Source)
         at sun.nio.cs.StreamDecoder.read(Unknown Source)
         at java.io.InputStreamReader.read(Unknown Source)
         at java.io.BufferedReader.fill(Unknown Source)
         at java.io.BufferedReader.readLine(Unknown Source)
         at java.io.BufferedReader.readLine(Unknown Source)
         at PaqueteServidor.Server$handleRequest.run(Server.java:130)
    Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
         at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source)
         at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.recvAlert(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.getSession(Unknown Source)
         at PaqueteServidor.Server.printClientCerts(Server.java:47)
         at PaqueteServidor.Server.run(Server.java:100)
    javax.net.ssl.SSLException: Connection has been shutdown: javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.checkEOF(Unknown Source)
         at com.sun.net.ssl.internal.ssl.AppInputStream.read(Unknown Source)
         at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source)
         at sun.nio.cs.StreamDecoder$CharsetSD.implRead(Unknown Source)
         at sun.nio.cs.StreamDecoder.read(Unknown Source)
         at java.io.InputStreamReader.read(Unknown Source)
         at java.io.BufferedReader.fill(Unknown Source)
         at java.io.BufferedReader.readLine(Unknown Source)
         at java.io.BufferedReader.readLine(Unknown Source)
         at PaqueteServidor.Server$handleRequest.run(Server.java:130)
    Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
         at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source)
         at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.recvAlert(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.getSession(Unknown Source)
         at PaqueteServidor.Server.printClientCerts(Server.java:47)
         at PaqueteServidor.Server.run(Server.java:100)
    Client side:
    javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
         at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(Unknown Source)
         at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source)
         at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source)
         at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(Unknown Source)
         at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(Unknown Source)
         at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Unknown Source)
         at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
         at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
         at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
         at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
         at Interfaz.InterfazMovil.init(InterfazMovil.java:89)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
         at sun.security.validator.PKIXValidator.doBuild(Unknown Source)
         at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
         at sun.security.validator.Validator.validate(Unknown Source)
         at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
         at com.sun.net.ssl.internal.ssl.JsseX509TrustManager.checkServerTrusted(Unknown Source)
         ... 14 more
    Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
         at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
         at java.security.cert.CertPathBuilder.build(Unknown Source)
         ... 19 more
    19:40:34,444 INFO Environment:464 - Hibernate 3.0.5
    19:40:34,444 INFO Environment:477 - hibernate.properties not found
    19:40:34,444 INFO Environment:510 - using CGLIB reflection optimizer
    19:40:34,454 INFO Environment:540 - using JDK 1.4 java.sql.Timestamp handling
    19:40:34,645 INFO Configuration:1110 - configuring from resource: /bd/hibernate/hibernate.cfg.xml
    19:40:34,645 INFO Configuration:1081 - Configuration resource: /bd/hibernate/hibernate.cfg.xml
    19:40:35,045 ERROR XMLHelper:59 - Error parsing XML: /bd/hibernate/hibernate.cfg.xml(21) The content of elements must consist of well-formed character data or markup.
    19:40:35,045 ERROR Configuration:1172 - problem parsing configuration/bd/hibernate/hibernate.cfg.xml
    org.dom4j.DocumentException: Error on line 21 of document : The content of elements must consist of well-formed character data or markup. Nested exception: The content of elements must consist of well-formed character data or markup.
         at org.dom4j.io.SAXReader.read(SAXReader.java:482)
         at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1168)
         at org.hibernate.cfg.Configuration.configure(Configuration.java:1112)
         at bd.hibernate.HibernateUtil.currentSession(HibernateUtil.java:51)
         at bd.controlador.CLetrero.ListarLetreros(CLetrero.java:45)
         at Interfaz.InterfazMovil.init(InterfazMovil.java:126)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Nested exception:
    org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
         at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
         at org.dom4j.io.SAXReader.read(SAXReader.java:465)
         at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1168)
         at org.hibernate.cfg.Configuration.configure(Configuration.java:1112)
         at bd.hibernate.HibernateUtil.currentSession(HibernateUtil.java:51)
         at bd.controlador.CLetrero.ListarLetreros(CLetrero.java:45)
         at Interfaz.InterfazMovil.init(InterfazMovil.java:126)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    %%%% Error Creating SessionFactory %%%%
    org.hibernate.HibernateException: problem parsing configuration/bd/hibernate/hibernate.cfg.xml
         at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1173)
         at org.hibernate.cfg.Configuration.configure(Configuration.java:1112)
         at bd.hibernate.HibernateUtil.currentSession(HibernateUtil.java:51)
         at bd.controlador.CLetrero.ListarLetreros(CLetrero.java:45)
         at Interfaz.InterfazMovil.init(InterfazMovil.java:126)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by: org.dom4j.DocumentException: Error on line 21 of document : The content of elements must consist of well-formed character data or markup. Nested exception: The content of elements must consist of well-formed character data or markup.
         at org.dom4j.io.SAXReader.read(SAXReader.java:482)
         at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1168)
         ... 6 more
    java.lang.NullPointerException
         at bd.hibernate.HibernateUtil.currentSession(HibernateUtil.java:59)
         at bd.controlador.CLetrero.ListarLetreros(CLetrero.java:45)
         at Interfaz.InterfazMovil.init(InterfazMovil.java:126)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Plz help and thx in advance.

    I know I didn't get round to replying but no need to post it so many times.
    http://forum.java.sun.com/thread.jspa?threadID=666870
    http://forum.java.sun.com/profile.jspa?userID=543817
    http://forum.java.sun.com/thread.jspa?threadID=669965
    http://forum.java.sun.com/profile.jspa?userID=543817
    http://forum.java.sun.com/thread.jspa?threadID=669975
    http://forum.java.sun.com/thread.jspa?threadID=669973
    Could it be that the server and client need to open different keystores?
    http://forums.java.sun.com/thread.jspa?threadID=573918&messageID=3272683
    reply 7
    My example given before should work on different machines, try to export the server key and import it into the
    client keystore. Export the client key and import in the server keystore if you want the server to authenticate
    the client.
    http://forum.java.sun.com/thread.jspa?threadID=666870
    reply 4
    Check the method getSSLSocketFactory in the applet, that will open a keystore for you.

  • Virus Updates and PC Mode

    Security Note...
    If you use MSE (Microsoft Security Essentials)  the virus definition files will not update if you put your system into SLEEP, HIBERNATE or STANDBY mode.  MSE virus definition files update every day and even sometimes several times a day to keep your system safe from attack.
    Microsoft is aware of this problem and have been working on it since November 11, 2009. No fix as yet.
    If you are using MSE, make sure you either MANUALLY update the virus definitions every day or SHUTDOWN your system after use.  After a shutdown/reboot or restart the definition files update.
    I will post to this location once I find out more. More details at:   social.answers.microsoft.com/forums
    T23: 2647-8RU, Ubuntu 12.04 LTS
    A61E: 6418-12U, W7/Pro 64
    X200: 7454-CTO, W7/Pro 32
    Solved!
    Go to Solution.

    As promised...an update:      Applies to WIndow 7, Vista and XP
    New release 1.0.1961.0  ( 2/3/2010), laptops & desktops using hibernate/sleep:  problem still not addressed.
    N.B.: You can not upgrade to the latest release of MSE by selecting   'UPGRADE'  from the dropdown menu beside 'help'.  If you want the new version, you have to reinstall MSE all over again, or wait for the upgrade to come down via windows updates.
    Temporary Workaround for sleep/hibernate:  Reset  your power settings to keep your PC awake.   
    There is a MSE  catchup utility that checks your system every 24 hours to see if your virus definitions have updated.  Apparently this is the problem.  Some users are also experiencing problems with scheduled scans. These are either not running on schedule or not at all.
    Temporary Workaround for Updates and Scans:.
    Download splinterware scheduler (freeware).  Follow these setup instructions:
    1. Open a new event. 
    2. In Application, enter:        c:\program files\microsoft security essentials\MpCmdRun.exe
    3. In Parameters, enter:     SignatureUpdate
    4. Go to Schedule, enter:   Daily     enter a time that suits you.. Save/exit
    for scans:
    1. Open another event
    2. In Application, enter:      same as above
    3. In Paramters, enter        Scan 1  (quick scan)   or   Scan 2  (full scan)
    4. Set your schedule, save/exit
    NB: you obviously have to be online for MSE to update.
    T23: 2647-8RU, Ubuntu 12.04 LTS
    A61E: 6418-12U, W7/Pro 64
    X200: 7454-CTO, W7/Pro 32

  • Problem with Hibernate Connection and MySQL

    I have the following setup:
    J2EE web-application, Java Servlets, Jsp, Hibernate for DB persistence, MySQL 4 (InnoDB tables)
    I have not specified any connection pool parameters (c3p0) in my hibernate.cfg.xml, as the default settings should suffice for my purposes.
    I use the SessionFactory object as follows.
    In my database access class, I have a static declaration that initialises the new SessionFactory.
    Then, I use Session session = sessionFactory.getSession(); and session.close(); to do my DB access.
    Likewise, when storing data into the DB, I use a Transaction object, and use transaction.commit(); at the end of database access.
    The problem is:
    When I store data into the database, the changes do not occur on the website. In other words, the data gets stored into the tables (I check that via phpMyAdmin) but when accessing it, it only gets the old data. This is a serious problem as I am developing a website with attached CMS that will be used to update the pages.
    The OTHER problem is:
    Instead of having a static initialisation of the SessionFactory object, I created a new one every time I needed to access the database. Although I had a sessionFactory.close(); statement at the end of the database acccess, I got an exception:
    "java.sql.SQLException: User db_user already has more than 'max_user_connections' active connections"
    At the very moment I don't have access to my code.
    If somebody has a suggestion or a solution to the problem, please reply.
    Also, I will supply any code that is necessary to identify the problem.
    Anders

    Thanks for the tip, but how do you mean to update the object?
    Here is the code that stores the data into the database:
    'sessionFactory' is a static SessionFactory object.
         public static int saveOrUpdate ( Object object ) {
              int flag = 0; // 0 is true
              LOG.info("CMSLogic >>> saveOrUpdate() - object: " + object );
              Session session = null;
              Transaction transaction = null;
              try {
                   session = sessionFactory.openSession();
                   transaction = session.beginTransaction();
                   LOG.info("CMSLogic >>> saveOrUpdate() - object to save or update: " + object );
                   session.saveOrUpdate(object);
                   // Flush the session
                   if ( session!= null )
                        session.flush();
                   transaction.commit();
              } catch ( Exception e ) {
                   e.printStackTrace ();
                   transaction.rollback();
                   flag = 1;
              } finally {
                   try{
                        if (session != null) {
                             session.close();
                   } catch (Exception e) {
                        LOG.error("CMSLogic >>> saveOrUpdate() - threw exception: " + e);
              return flag;
         }Further, here is the code that fetches the data from the DB:
         public static Item getItemByURL ( String url ) {
              // Verify the URL
              if ( url.charAt(0) == '/' ) url = url.substring (1);
              String [] urlArr = url.split( "/" );
              LOG.info("BusinessLogic >>> getItemByURL() - split url: urlArr.length: " + urlArr.length );
              for ( int i = 0; i < urlArr.length; i++ )
                   System.out.println ( urlArr[i] + ", " );
              if ( urlArr == null ) return null;
              if ( urlArr.length == 0 ) return null;
              if ( urlArr.length > 4 ) return null; // If the path depth is more than 3 levels, abort
              // Fetch data from DB
              List<Item> items = null;
              Session session = null;
              Query query = null;
              try {
                   session = sessionFactory.openSession();
                   if ( urlArr.length == 1 ) {
                        query = session.createQuery(
                             "FROM Item WHERE section.sectionKey LIKE 'root' " +
                             "AND filename LIKE '" + urlArr[0] + "'" );
                   else if ( urlArr.length == 2 ) {
                        query = session.createQuery(
                             "FROM Item WHERE section.sectionKey LIKE '" + urlArr[0] + "' " +
                             "AND filename LIKE '" + urlArr[1] + "'" );
                   else if ( urlArr.length == 3 ) {
                        query = session.createQuery(
                             "FROM Item WHERE section.sectionKey LIKE '" + urlArr[1] + "' " +
                             "AND section.parentSection.sectionKey LIKE '" + urlArr[0] + "' " +
                             "AND filename LIKE '" + urlArr[2] + "'" );
                   else { // if ( urlArr.length == 4 ) {
                        query = session.createQuery(
                             "FROM Item WHERE section.sectionKey LIKE '" + urlArr[2] + "' " +
                             "AND section.parentSection.sectionKey LIKE '" + urlArr[1] + "' " +
                             "AND section.parentSection.parentSection.sectionKey LIKE '" + urlArr[0] + "' " +
                             "AND filename LIKE '" + urlArr[3] + "'" );
                   items = query.list();
                   LOG.info("BusinessLogic >>> getItemByURL() - items = query.list(): " + items );
                   // Load the related revisions, too
                   if ( !items.isEmpty() ) {
                        Hibernate.initialize ( items.get(0).getRevisions() );
                        LOG.info("BusinessLogic >>> getItemByURL() - initialised revisions for item." );
                        Hibernate.initialize ( items.get(0).getRevisions().get(0).getTemplate() );
                        LOG.info("BusinessLogic >>> getItemByURL() - initialised template for first revision." );
                   // Flush the session
                   if ( session!= null )
                        session.flush();
              } catch ( Exception e ) {
                   e.printStackTrace ();
                   LOG.error("BusinessLogic >>> getItemByURL() - threw exception: " + e );
              } finally {
                   session.close();
                   //sessionFactory.close(); // !!!???
              // Return query results
              if ( items == null ) return null;
              else if ( items.isEmpty() == true ) return null;
              else {
                   LOG.info("BusinessLogic >>> getItemByURL() - items.get(0).getRevisions().size(): " + items.get(0).getRevisions().size() );
                   LOG.info("BusinessLogic >>> getItemByURL() - items.get(0).getRevisions().get(0): " + items.get(0).getRevisions().get(0) );
                   return items.get(0);
         }Any constructive suggestions and helpful comments are more than welcome.
    I have been struggling with this problem for a while now.
    Anders

Maybe you are looking for

  • Is there a way to restore an iPod to its factory condition?

    Since the last updater, I havnt been able to connect my iPod to any computer. Im sure the updater corrupted the iPod, so what I would like to do is wipe the iPod clean and start fresh with the factory settings. I know you can restore it using the upd

  • HT1923 Cannot uninstall Apple Mobile Device Support

    It begins to uninstall, then seems to reverse itself?  I can uninstall all other pieces of iTunes?

  • IMovie won't update because of an old card.

    Hello! Besides buying a new iMAC, what can I do to get an updated card for my iMAC (purch. 03/2008) so that I can update the newest version of OSX Maverick iMovie App??  I upgraded to OSX Maverick yesterday.  I'm not sure what my options are on this.

  • Vendor invoice number

    where should i enter the vendor invoice number during invoice verification i am not able to see any where the vendor invoice number which i entered in invoice verification Pls guide me

  • How to use fp file in my project

    I have used ini and toolbar functions in my project, these functions are included in inifile.fp and toolbar.fp. Recently I found my released .exe routine userly got run-time error. And I changed CVI compiling environment as below: 1. add these two fp