Beginner |
|
Joined: Tue Sep 21, 2004 1:03 pm Posts: 21
|
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.x
Mapping documents: <?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="session_factory_name"> java:/hibernate/TrackingSessionFactory </property> <property name="transaction.manager_lookup_class"> org.hibernate.transaction.JBossTransactionManagerLookup </property> <property name="connection.datasource">java:/trackingDS</property> <property name="transaction.manager_lookup_class"> org.hibernate.transaction.JBossTransactionManagerLookup </property> <property name="transaction.factory_class"> org.hibernate.transaction.JTATransactionFactory </property> <property name="show_sql">true</property> <mapping resource="com/eon/tracking/instance/DefaultTracking.hbm.xml" /> </session-factory> </hibernate-configuration>
and DefaultTracking.hbm.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="com.eon.tracking.instance.DefaultTracking" table="events"> <meta attribute="class-description"> Represents a events track in the event_tracking database. </meta> <id name="id" type="int" column="id"> <meta attribute="scope-set">protected</meta> <generator class="increment" /> </id> <property name="sessionId" column="sessionId"/> <property name="channelName" column="channelName" /> <property name="vehicleId" column="vehicleId" /> <property name="timeDateStamp" column="timeDateStamp" /> <property name="inspectionId" column="inspectionId" /> <property name="regMark" column="regMark" /> </class>
</hibernate-mapping>
and Datasource mapping is as below.
<local-tx-datasource> <jndi-name>trackingDS</jndi-name> <connection-url>jdbc:mysql://localhost:3306/event_tracking</connection-url> <!-- The driver class --> <driver-class>com.mysql.jdbc.Driver</driver-class> <!-- The login and password --> <user-name>root</user-name> <password>password</password> <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name> <!-- The minimum connections in a pool/sub-pool. Pools are lazily constructed on first use --> <min-pool-size>2</min-pool-size> <!-- The maximum connections in a pool/sub-pool --> <max-pool-size>50</max-pool-size> <idle-timeout-minutes>10</idle-timeout-minutes> <prepared-statement-cache-size>32</prepared-statement-cache-size>
Code to get the session factory
public class HibernateUtil { private static Logger LOGGER = Logger.getLogger(HibernateUtil.class); private static Context jndiContext;
static { try { LOGGER.debug(" Loading configuration ....."); Configuration config = new Configuration().configure( "com/eon/tracking/persistence/hibernate/config/tracking-hibernate.cfg.xml"); LOGGER.debug(" Configuration loaded .. " + config); jndiContext = new InitialContext(); } catch (Throwable ex) { ex.printStackTrace(); throw new ExceptionInInitializerError(ex); } }
/** * Returns the SessionFactory using. * * @return SessionFactory */ public static SessionFactory getSessionFactory(String sfName) throws PersistenceException { SessionFactory sessions = null;
try { if (LOGGER.isDebugEnabled()) { LOGGER.debug(" Looking up for session factory name : " + sfName); }
sessions = (SessionFactory) jndiContext.lookup(sfName); } catch (NamingException ex) { ex.printStackTrace(); throw new PersistenceException(ex); }
return sessions; } }
:
Full stack trace of any exception that occurs:
13:06:52,093 DEBUG [HibernateUtil] Loading configuration ..... 13:06:52,296 INFO [Environment] Hibernate 3.2.3 13:06:52,312 INFO [Environment] hibernate.properties not found 13:06:52,312 INFO [Environment] Bytecode provider name : javassist 13:06:52,312 INFO [Environment] using JDK 1.4 java.sql.Timestamp handling 13:06:52,359 INFO [Configuration] configuring from resource: com/eon/tracking/persistence/hibernate/config/tracking-hibernate.cfg.xml 13:06:52,359 INFO [Configuration] Configuration resource: com/eon/tracking/persistence/hibernate/config/tracking-hibernate.cfg.xml 13:06:52,421 INFO [Configuration] Reading mappings from resource : com/eon/tracking/instance/DefaultTracking.hbm.xml 13:06:52,500 INFO [HbmBinder] Mapping class: com.eon.tracking.instance.DefaultTracking -> events 13:06:52,531 INFO [Configuration] Configured SessionFactory: null 13:06:52,531 DEBUG [HibernateUtil] Configuration loaded .. org.hibernate.cfg.Configuration@a6343d 13:06:52,531 DEBUG [HibernateUtil] Looking up for session factory name : java:/hibernate/TrackingSessionFactory 13:06:52,531 ERROR [STDERR] javax.naming.NameNotFoundException: hibernate not bound 13:06:52,546 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:529) 13:06:52,546 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:537) 13:06:52,562 ERROR [STDERR] at org.jnp.server.NamingServer.getObject(NamingServer.java:543) 13:06:52,562 ERROR [STDERR] at org.jnp.server.NamingServer.lookup(NamingServer.java:267) 13:06:52,562 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625) 13:06:52,562 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587) 13:06:52,578 ERROR [STDERR] at javax.naming.InitialContext.lookup(InitialContext.java:392) 13:06:52,578 ERROR [STDERR] at com.eon.tracking.persistence.hibernate.HibernateUtil.getSessionFactory(HibernateUtil.java:59) 13:06:52,593 ERROR [STDERR] at com.eon.tracking.service.instance.DefaultTrackingDataRetrievalService.getTrackingDataForAVehicle(DefaultTrackingDataRetrievalService.java:44) 13:06:52,593 ERROR [STDERR] at com.eon.pricing.spring.service.instance.PriceDecisionService.getPageVisits(PriceDecisionService.java:993) 13:06:52,593 ERROR [STDERR] at com.eon.pricing.spring.controller.PricingDecisionController.showPricingDetail(PricingDecisionController.java:105) 13:06:52,593 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Name and version of the database you are using:MySQL
The generated SQL (show_sql=true): yes, but no query generated
Debug level Hibernate log excerpt:DEBUG
Could you any one plase shade some lights what I might be doing wrong here?
Thanks & REgards,
Irfan
|
|