-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Annotated classes in seperate Jar file
PostPosted: Tue Feb 20, 2007 9:54 am 
Newbie

Joined: Fri Dec 22, 2006 2:32 pm
Posts: 16
Hello,

I have placed my annotated hibernate classes inside a seperate "commons" jar file. Inside this file I have placed the hibernate.cfg.xml file which looks like this:

Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
        <property name="hibernate.connection.password">xxx</property>
        <property name="hibernate.connection.url">jdbc:mysql:///DevsidenNy</property>
        <property name="hibernate.connection.username">xxx</property>
        <property name="hibernate.current_session_context_class">thread</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.show_sql">true</property>


      <mapping class="info.devsiden.dsj.persistancetier.data.BildeData" />
      <mapping class="info.devsiden.dsj.persistancetier.data.BildeAlbumData" />
      
   </session-factory>
</hibernate-configuration>



Now, when I deploy the application this file is read, which outputs the following:

Code:
14:37:43,671 INFO  [Configuration] configuring from resource: /hibernate.cfg.xml
14:37:43,671 INFO  [Configuration] Configuration resource: /hibernate.cfg.xml
14:37:43,679 INFO  [Configuration] Configured SessionFactory: null
14:37:43,691 INFO  [DriverManagerConnectionProvider] Using Hibernate built-in connection pool (not for production use!)
14:37:43,691 INFO  [DriverManagerConnectionProvider] Hibernate connection pool size: 20
14:37:43,692 INFO  [DriverManagerConnectionProvider] autocommit mode: false
14:37:43,692 INFO  [DriverManagerConnectionProvider] using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql:///DevsidenNy
14:37:43,692 INFO  [DriverManagerConnectionProvider] connection properties: {user=xxx, password=xxx}
14:37:43,722 INFO  [SettingsFactory] RDBMS: MySQL, version: 5.0.20-standard
14:37:43,722 INFO  [SettingsFactory] JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.12 ( $Date: 2005-11-17 15:53:48 +0100 (Thu, 17 Nov 2005) $, $Revision$ )
14:37:43,723 INFO  [Dialect] Using dialect: org.hibernate.dialect.MySQLDialect
14:37:43,723 INFO  [TransactionFactoryFactory] Using default transaction strategy (direct JDBC transactions)
14:37:43,724 INFO  [TransactionManagerLookupFactory] No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
14:37:43,724 INFO  [SettingsFactory] Automatic flush during beforeCompletion(): disabled
14:37:43,724 INFO  [SettingsFactory] Automatic session close at end of transaction: disabled
14:37:43,724 INFO  [SettingsFactory] JDBC batch size: 15
14:37:43,724 INFO  [SettingsFactory] JDBC batch updates for versioned data: disabled
14:37:43,724 INFO  [SettingsFactory] Scrollable result sets: enabled
14:37:43,724 INFO  [SettingsFactory] JDBC3 getGeneratedKeys(): enabled
14:37:43,724 INFO  [SettingsFactory] Connection release mode: auto
14:37:43,724 INFO  [SettingsFactory] Maximum outer join fetch depth: 2
14:37:43,724 INFO  [SettingsFactory] Default batch fetch size: 1
14:37:43,725 INFO  [SettingsFactory] Generate SQL with comments: disabled
14:37:43,725 INFO  [SettingsFactory] Order SQL updates by primary key: disabled
14:37:43,725 INFO  [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
14:37:43,725 INFO  [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
14:37:43,725 INFO  [SettingsFactory] Query language substitutions: {}
14:37:43,726 INFO  [SettingsFactory] JPA-QL strict compliance: disabled
14:37:43,726 INFO  [SettingsFactory] Second-level cache: enabled
14:37:43,726 INFO  [SettingsFactory] Query cache: disabled
14:37:43,726 INFO  [SettingsFactory] Cache provider: org.hibernate.cache.NoCacheProvider
14:37:43,727 INFO  [SettingsFactory] Optimize cache for minimal puts: disabled
14:37:43,727 INFO  [SettingsFactory] Structured second-level cache entries: disabled
14:37:43,727 INFO  [SettingsFactory] Echoing all SQL to stdout
14:37:43,727 INFO  [SettingsFactory] Statistics: disabled
14:37:43,727 INFO  [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
14:37:43,727 INFO  [SettingsFactory] Default entity-mode: pojo
14:37:43,732 INFO  [SessionFactoryImpl] building session factory
14:37:43,733 INFO  [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured


Note that there is no reading of these annotated classes (which are correct BTW, with @Entity, and such).

Now, when I try to use any of the annotated classes, I get the following exception:

org.hibernate.MappingException: Unknown entity: info.devsiden.dsj.persistancetier.data.BildeAlbumData
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:548)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:68)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:795)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:788)
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.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
at $Proxy73.load(Unknown Source)
at info.devsiden.dsj.persistancetier.dao.data.BildeDao.getBildeAlbum(BildeDao.java:58)
at org.apache.jsp.testHibernate_jsp._jspService(org.apache.jsp.testHibernate_jsp:85)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:613)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 20, 2007 12:25 pm 
Senior
Senior

Joined: Tue Jul 25, 2006 9:05 am
Posts: 163
Location: Stuttgart/Karlsruhe, Germany
Have you tried adding the following line to your hibernate.cfg.xml file:

If you want the schema creating and droppping on SessionFactory creation/destroy (or whatever the equivalent is to restarting the appserver)
Code:
<property name="hibernate.hbm2ddl.auto">create-drop</property>


If you want the schema to be created once and not dropped only updated
Code:
<property name="hibernate.hbm2ddl.auto">update</property>


Cheers,

Andy

_________________
Rules are only there to be broken


Top
 Profile  
 
 Post subject: Fixed...
PostPosted: Tue Feb 20, 2007 2:55 pm 
Newbie

Joined: Fri Dec 22, 2006 2:32 pm
Posts: 16
Problem fixed... I had <scope>provided</scope> in my POM for hibernate-annotations...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.