Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    SmartGWT EE Eval with hibernate annotations

    I'm trying to recreate the masterDetail example in the showcase using hibernate annotations. I have it working using hbm.xml files as in the showcase example, but when I switch to using annotations i get this error when loading the datasource.

    I found another post with a solution for smartclient, however I am using smartGWT.

    http://forums.smartclient.com/showthread.php?t=10915

    Version:
    SmartGWT EE 2.3 EVAL Deployment 2010-12-02
    FF 3.6

    Error:
    Code:
    [Server@ce2187]: [Thread[main,5,main]]: checkRunning(false) entered
    [Server@ce2187]: [Thread[main,5,main]]: checkRunning(false) exited
    [Server@ce2187]: Startup sequence initiated from main() method
    [Server@ce2187]: Loaded properties from [C:\springgwt\war\server.properties]
    [Server@ce2187]: Initiating startup sequence...
    [Server@ce2187]: Server socket opened successfully in 0 ms.
    [Server@ce2187]: Database [index=0, id=0, db=file:C:\springgwt\war\WEB-INF\db\hsqldb\isomorphic, alias=isomorphic] opened sucessfully in 203 ms.
    [Server@ce2187]: Startup sequence completed in 203 ms.
    [Server@ce2187]: 2010-12-14 12:28:14.156 HSQLDB server 1.8.0 is online
    [Server@ce2187]: To close normally, connect and execute SHUTDOWN SQL
    [Server@ce2187]: From command line, use [Ctrl]+[C] to abort abruptly
    log4j:WARN No appenders could be found for logger (org.apache.jasper.compiler.JspRuntimeContext).
    log4j:WARN Please initialize the log4j system properly.
    ISC: Configuring log4j from: file:/C:/springgwt/war/WEB-INF/classes/log4j.isc.config.xml
    === 2010-12-14 12:28:14,578 [main] INFO  ISCInit - Isomorphic SmartClient Framework - Initializing
    === 2010-12-14 12:28:14,578 [main] INFO  ConfigLoader - Attempting to load framework.properties from CLASSPATH
    === 2010-12-14 12:28:14,625 [main] INFO  ConfigLoader - Successfully loaded framework.properties from CLASSPATH at location: jar:file:/C:/springgwt/war/WEB-INF/lib/isomorphic_core_rpc.jar!/framework.properties
    === 2010-12-14 12:28:14,625 [main] INFO  ConfigLoader - Attempting to load project.properties from CLASSPATH
    === 2010-12-14 12:28:14,625 [main] INFO  ConfigLoader - Unable to locate project.properties in CLASSPATH
    === 2010-12-14 12:28:14,640 [main] INFO  ConfigLoader - Successfully loaded isc_interfaces.properties from CLASSPATH at location: jar:file:/C:/springgwt/war/WEB-INF/lib/isomorphic_core_rpc.jar!/isc_interfaces.properties
    === 2010-12-14 12:28:14,640 [main] INFO  ConfigLoader - Attempting to load server.properties from CLASSPATH
    === 2010-12-14 12:28:14,640 [main] INFO  ConfigLoader - Successfully loaded server.properties from CLASSPATH at location: file:/C:/springgwt/war/WEB-INF/classes/server.properties
    === 2010-12-14 12:28:14,640 [main] INFO  Logger - Logging system started.
    === 2010-12-14 12:28:14,640 [main] INFO  ISCInit - Isomorphic SmartClient Framework (SC_SNAPSHOT-2010-12-02/EVAL Deployment 2010-12-02) - Initialization Complete
    === 2010-12-14 12:28:14,640 [main] INFO  ISCInit - Auto-detected webRoot - using: C:\springgwt\war
    === 2010-12-14 12:28:23,500 [l0-1] INFO  PoolManager - SmartClient pooling disabled for 'masterDetail_order' objects
    === 2010-12-14 12:28:23,546 [l0-1] DEBUG XML - Parsed XML from C:\springgwt\war\ds\masterDetail_order.ds.xml: 0ms
    === 2010-12-14 12:28:23,546 [l0-1] DEBUG XML - Parsed XML from C:\springgwt\war\SpringGWT_js\sc\system\schema\DataSource.ds.xml: 0ms
    === 2010-12-14 12:28:23,562 [l0-1] DEBUG XML - Parsed XML from C:\springgwt\war\SpringGWT_js\sc\system\schema\builtinTypes.xml: 0ms
    === 2010-12-14 12:28:23,656 [l0-1] DEBUG XML - Parsed XML from C:\springgwt\war\SpringGWT_js\sc\system\schema\DataSourceField.ds.xml: 0ms
    === 2010-12-14 12:28:23,781 [l0-1] DEBUG XML - Parsed XML from (in memory stream): 0ms
    === 2010-12-14 12:28:23,828 [l0-1] ERROR DataSourceLoader - Exception while attempting to load a DataSource
    org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class="com.smartgwt.sample.server.Order"/>
    	at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1634)
    	at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1589)
    	at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1568)
    	at org.hibernate.cfg.Configuration.configure(Configuration.java:1557)
    	at com.isomorphic.hibernate.HibernateDataSource.initStaticConfigAndSessionFactory(HibernateDataSource.java:425)
    	at com.isomorphic.hibernate.HibernateDataSource.initConfigAndSessionFactory(HibernateDataSource.java:339)
    	at com.isomorphic.hibernate.HibernateDataSource.init(HibernateDataSource.java:179)
    	at com.isomorphic.datasource.BasicDataSource.fromConfig(BasicDataSource.java:165)
    	at com.isomorphic.datasource.DataSource.fromConfig(DataSource.java:337)
    	at com.isomorphic.datasource.FileSystemDSRepo.loadDS(FileSystemDSRepo.java:110)
    	at com.isomorphic.datasource.DataSource.forName(DataSource.java:156)
    	at com.isomorphic.datasource.DataSource.forName(DataSource.java:148)
    	at com.isomorphic.datasource.DataSource.forName(DataSource.java:143)
    	at com.isomorphic.datasource.PoolableDataSourceFactory.makeUnpooledObject(PoolableDataSourceFactory.java:95)
    	at com.isomorphic.datasource.PoolableDataSourceFactory.makeObject(PoolableDataSourceFactory.java:102)
    	at com.isomorphic.pool.PoolManager.borrowObject(PoolManager.java:82)
    	at com.isomorphic.datasource.DataSourceManager.getDataSource(DataSourceManager.java:62)
    	at com.isomorphic.servlet.DataSourceLoader.processRequest(DataSourceLoader.java:81)
    	at com.isomorphic.servlet.DataSourceLoader.doGet(DataSourceLoader.java:64)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
    	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
    	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
    	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.Server.handle(Server.java:324)
    	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
    	at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)
    	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
    	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
    === 2010-12-14 12:28:23,828 [l0-1] ERROR DataSourceLoader - Top-level servlet error: 
    javax.servlet.ServletException: org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class="com.smartgwt.sample.server.Order"/>
    	at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1634)
    	at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1589)
    	at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1568)
    	at org.hibernate.cfg.Configuration.configure(Configuration.java:1557)
    	at com.isomorphic.hibernate.HibernateDataSource.initStaticConfigAndSessionFactory(HibernateDataSource.java:425)
    	at com.isomorphic.hibernate.HibernateDataSource.initConfigAndSessionFactory(HibernateDataSource.java:339)
    	at com.isomorphic.hibernate.HibernateDataSource.init(HibernateDataSource.java:179)
    	at com.isomorphic.datasource.BasicDataSource.fromConfig(BasicDataSource.java:165)
    	at com.isomorphic.datasource.DataSource.fromConfig(DataSource.java:337)
    	at com.isomorphic.datasource.FileSystemDSRepo.loadDS(FileSystemDSRepo.java:110)
    	at com.isomorphic.datasource.DataSource.forName(DataSource.java:156)
    	at com.isomorphic.datasource.DataSource.forName(DataSource.java:148)
    	at com.isomorphic.datasource.DataSource.forName(DataSource.java:143)
    	at com.isomorphic.datasource.PoolableDataSourceFactory.makeUnpooledObject(PoolableDataSourceFactory.java:95)
    	at com.isomorphic.datasource.PoolableDataSourceFactory.makeObject(PoolableDataSourceFactory.java:102)
    	at com.isomorphic.pool.PoolManager.borrowObject(PoolManager.java:82)
    	at com.isomorphic.datasource.DataSourceManager.getDataSource(DataSourceManager.java:62)
    	at com.isomorphic.servlet.DataSourceLoader.processRequest(DataSourceLoader.java:81)
    	at com.isomorphic.servlet.DataSourceLoader.doGet(DataSourceLoader.java:64)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
    	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
    	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
    	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.Server.handle(Server.java:324)
    	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
    	at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)
    	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
    	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
    
    	at com.isomorphic.servlet.DataSourceLoader.processRequest(DataSourceLoader.java:89)
    	at com.isomorphic.servlet.DataSourceLoader.doGet(DataSourceLoader.java:64)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
    	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
    	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
    	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.Server.handle(Server.java:324)
    	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
    	at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)
    	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
    	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
    masterDetail_order.ds.xml

    Code:
    DataSource
        ID="masterDetail_order"
        serverType="hibernate"
        tableName="masterDetail_order"
        beanClassName="com.smartgwt.sample.server.Order"
        testFileName="/ds/test_data/masterDetail_order.data.xml"
    >
        <fields>
            <field name="orderId" type="sequence" primaryKey="true" canEdit="false" />
            <field name="customerName" type="text" />
            <field name="orderDate" type="date" />
    
            <field name="items" title= "Order Items" multiple="true"
                   type="masterDetail_orderItemHB" 
                   javaClass="com.smartgwt.sample.server.OrderItem"
            />
            <field name="trackingNumber" type="integer" />
        </fields>
        
    </DataSource>
    hibernate.cfg.xml

    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>
    
            <!-- Database connection settings -->
            <property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
            <property name="connection.url">jdbc:hsqldb:hsql://localhost/isomorphic</property>
    
            <!-- disable native hibernate connection pooling: it's not recommended for production
                 use and can't handle connection re-establishment.  The recommended approach is
                 to obtain database connections from the container and have the container manage
                 the pool
            -->        
            <property name="connection.pool_size">0</property>
    
            <!-- SQL dialect -->
            <property name="dialect">org.hibernate.dialect.HSQLDialect</property>
    
            <!-- Enable Hibernate's automatic session context management -->
            <property name="current_session_context_class">org.hibernate.transaction.JDBCTransactionFactory</property>
            
            <!-- Release database connections when session are closed.  Otherwise, if the DB
                 agressively cuts connections, we could end up trying to use a broken connection.
            -->
            <property name="hibernate.connection.release_mode">on_close</property>
    
            <!-- don't use a data cache -->
            <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
    
            <!-- Pretty-print logged sql -->
            <property name="format_sql">true</property>
    
            <property name="show_sql">true</property>
    
            <!-- Drop and re-create the database schema on startup -->
            <property name="hbm2ddl.auto">update</property>
    		
    	<mapping class="com.smartgwt.sample.server.Order"/>
    	<mapping class="com.smartgwt.sample.server.OrderItem"/>
    
        </session-factory>
    
    </hibernate-configuration>
    Order.java
    Code:
    package com.smartgwt.sample.server;
    
    //----------------------------------------------------------------------
    // Master-Detail load and save example (Hibernate)
    //
    // Order Bean - to be managed by Hibernate
    //----------------------------------------------------------------------
    
    import java.io.Serializable;
    import java.util.Date;
    import java.util.Set;
    
    import javax.persistence.*;
    
    @Entity
    @Table(name="orders")
    public class Order implements Serializable {
    	private static final long serialVersionUID = -2722967662983593881L;
    
    	@Id
    	@GeneratedValue(strategy=GenerationType.AUTO)   
    	Long orderID;
        String customerName;
        Date orderDate;
        Long trackingNumber;
        @OneToMany
        @JoinColumn(name="orderId",nullable=true)
        Set<OrderItem> items;
    	public Long getOrderID() {
    		return orderID;
    	}
    	public void setOrderID(Long orderID) {
    		this.orderID = orderID;
    	}
    	public String getCustomerName() {
    		return customerName;
    	}
    	public void setCustomerName(String customerName) {
    		this.customerName = customerName;
    	}
    	public Date getOrderDate() {
    		return orderDate;
    	}
    	public void setOrderDate(Date orderDate) {
    		this.orderDate = orderDate;
    	}
    	public Long getTrackingNumber() {
    		return trackingNumber;
    	}
    	public void setTrackingNumber(Long trackingNumber) {
    		this.trackingNumber = trackingNumber;
    	}
    	public Set<OrderItem> getItems() {
    		return items;
    	}
    	public void setItems(Set<OrderItem> items) {
    		this.items = items;
    	}
    
    }
    The hibernate configuration loads correctly via spring. Note the configuration class is set to org.hibernate.cfg.AnnotationConfiguration.

    applicationContext.xml

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
        
        
        
        <!-- Transaction manager for supplyItemDMI -->
        <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
            <property name="sessionFactory" ref="hibernateSessionFactory"/>
        </bean>
        
        <!-- Hibernate SessionFactory -->
        <bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
            <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
            <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />
        </bean>
        
    </beans>
    Please help.
    Last edited by jbausewein; 14 Dec 2010, 13:32. Reason: Added spring configuration

    #2
    Any server-side suggested solution for SmartClient applies to SmartGWT as well. Did you try the suggested fix for SmartClient?

    Comment


      #3
      The solution was

      "We've just added support for AnnotationConfiguration and lookup via Spring. Grab the latest nightly build to try it out - look at the Hibernate Configuration overview in the Reference for details."

      I've only got the SmartGWT EE Eval, so I don't have access to nightly builds.

      I also read the "Integration with Hibernate" section in the SmartClient reference, and it doesn't mention hibernate annotations.

      Comment


        #4
        Everyone has access to nightly builds: smartclient.com/builds. You can get a new nightly Eval there to try out the new support (and you'll also see that the documentation has been updated).

        Comment


          #5
          Ok, I downloaded and installed the 12-14-2010 build. I looked at the updated javadocs. I'm still getting the same error.

          The log shows I have the new version.

          Isomorphic SmartClient Framework (SC_SNAPSHOT-2010-12-14/EVAL Deployment 2010-12-14)

          Code:
          [Server@15253d5]: [Thread[main,5,main]]: checkRunning(false) entered
          [Server@15253d5]: [Thread[main,5,main]]: checkRunning(false) exited
          [Server@15253d5]: Startup sequence initiated from main() method
          [Server@15253d5]: Loaded properties from [C:\springgwt\war\server.properties]
          [Server@15253d5]: Initiating startup sequence...
          [Server@15253d5]: Server socket opened successfully in 0 ms.
          [Server@15253d5]: Database [index=0, id=0, db=file:C:\springgwt\war\WEB-INF\db\hsqldb\isomorphic, alias=isomorphic] opened sucessfully in 172 ms.
          [Server@15253d5]: Startup sequence completed in 172 ms.
          [Server@15253d5]: 2010-12-14 15:49:06.593 HSQLDB server 1.8.0 is online
          [Server@15253d5]: To close normally, connect and execute SHUTDOWN SQL
          [Server@15253d5]: From command line, use [Ctrl]+[C] to abort abruptly
          log4j:WARN No appenders could be found for logger (org.apache.jasper.compiler.JspRuntimeContext).
          log4j:WARN Please initialize the log4j system properly.
          ISC: Configuring log4j from: file:/C:/springgwt/war/WEB-INF/classes/log4j.isc.config.xml
          === 2010-12-14 15:49:07,015 [main] INFO  ISCInit - Isomorphic SmartClient Framework - Initializing
          === 2010-12-14 15:49:07,015 [main] INFO  ConfigLoader - Attempting to load framework.properties from CLASSPATH
          === 2010-12-14 15:49:07,078 [main] INFO  ConfigLoader - Successfully loaded framework.properties from CLASSPATH at location: jar:file:/C:/springgwt/war/WEB-INF/lib/isomorphic_core_rpc.jar!/framework.properties
          === 2010-12-14 15:49:07,078 [main] INFO  ConfigLoader - Attempting to load project.properties from CLASSPATH
          === 2010-12-14 15:49:07,078 [main] INFO  ConfigLoader - Unable to locate project.properties in CLASSPATH
          === 2010-12-14 15:49:07,078 [main] INFO  ConfigLoader - Successfully loaded isc_interfaces.properties from CLASSPATH at location: jar:file:/C:/springgwt/war/WEB-INF/lib/isomorphic_core_rpc.jar!/isc_interfaces.properties
          === 2010-12-14 15:49:07,078 [main] INFO  ConfigLoader - Attempting to load server.properties from CLASSPATH
          === 2010-12-14 15:49:07,078 [main] INFO  ConfigLoader - Successfully loaded server.properties from CLASSPATH at location: file:/C:/springgwt/war/WEB-INF/classes/server.properties
          === 2010-12-14 15:49:07,078 [main] INFO  Logger - Logging system started.
          === 2010-12-14 15:49:07,078 [main] INFO  ISCInit - Isomorphic SmartClient Framework (SC_SNAPSHOT-2010-12-14/EVAL Deployment 2010-12-14) - Initialization Complete
          === 2010-12-14 15:49:07,078 [main] INFO  ISCInit - Auto-detected webRoot - using: C:\springgwt\war
          === 2010-12-14 15:49:13,281 [l0-0] INFO  PoolManager - SmartClient pooling disabled for 'masterDetail_order' objects
          === 2010-12-14 15:49:13,343 [l0-0] DEBUG XML - Parsed XML from C:\springgwt\war\ds\masterDetail_order.ds.xml: 0ms
          === 2010-12-14 15:49:13,359 [l0-0] DEBUG XML - Parsed XML from C:\springgwt\war\SpringGWT_js\sc\system\schema\DataSource.ds.xml: 16ms
          === 2010-12-14 15:49:13,359 [l0-0] DEBUG XML - Parsed XML from C:\springgwt\war\SpringGWT_js\sc\system\schema\builtinTypes.xml: 0ms
          === 2010-12-14 15:49:13,453 [l0-0] DEBUG XML - Parsed XML from C:\springgwt\war\SpringGWT_js\sc\system\schema\DataSourceField.ds.xml: 16ms
          === 2010-12-14 15:49:13,593 [l0-0] DEBUG XML - Parsed XML from (in memory stream): 0ms
          === 2010-12-14 15:49:13,640 [l0-0] ERROR DataSourceLoader - Exception while attempting to load a DataSource
          org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class="com.smartgwt.sample.server.Order"/>
          	at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1634)
          	at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1589)
          	at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1568)
          	at org.hibernate.cfg.Configuration.configure(Configuration.java:1557)
          	at com.isomorphic.hibernate.HibernateDataSource.initStaticConfigAndSessionFactory(HibernateDataSource.java:425)
          	at com.isomorphic.hibernate.HibernateDataSource.initConfigAndSessionFactory(HibernateDataSource.java:339)
          	at com.isomorphic.hibernate.HibernateDataSource.init(HibernateDataSource.java:179)
          	at com.isomorphic.datasource.BasicDataSource.fromConfig(BasicDataSource.java:165)
          	at com.isomorphic.datasource.DataSource.fromConfig(DataSource.java:337)
          	at com.isomorphic.datasource.FileSystemDSRepo.loadDS(FileSystemDSRepo.java:110)
          	at com.isomorphic.datasource.DataSource.forName(DataSource.java:156)
          	at com.isomorphic.datasource.DataSource.forName(DataSource.java:148)
          	at com.isomorphic.datasource.DataSource.forName(DataSource.java:143)
          	at com.isomorphic.datasource.PoolableDataSourceFactory.makeUnpooledObject(PoolableDataSourceFactory.java:95)
          	at com.isomorphic.datasource.PoolableDataSourceFactory.makeObject(PoolableDataSourceFactory.java:102)
          	at com.isomorphic.pool.PoolManager.borrowObject(PoolManager.java:82)
          	at com.isomorphic.datasource.DataSourceManager.getDataSource(DataSourceManager.java:62)
          	at com.isomorphic.servlet.DataSourceLoader.processRequest(DataSourceLoader.java:81)
          	at com.isomorphic.servlet.DataSourceLoader.doGet(DataSourceLoader.java:64)
          	at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
          	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
          	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
          	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
          	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
          	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
          	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
          	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
          	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
          	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
          	at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
          	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
          	at org.mortbay.jetty.Server.handle(Server.java:324)
          	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
          	at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)
          	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
          	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
          	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
          	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
          	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)

          If it helps, here is a link to the source code to reproduce the exception. The project structure is based off the ds-jpa example.

          http://www.zumodrive.com/share/919UYzBkYT

          Comment


            #6
            I also have tried to provide Hibernate configuration to the Smart GWT server in the following three ways with no luck.

            * You can place a traditional hibernate.cfg.xml file somewhere on the classpath
            * You can have Smart GWT look up a Hibernate Configuration to use. This works in the same way as a ServerObject, and in fact makes use of the ServerObject code. To do this, add ServerObject-compliant properties to your server.properties file, prefixed with hibernate.config. For example:

            hibernate.config.lookupStyle: spring
            hibernate.config.bean: mySessionFactory

            * You can provide a Hibernate configuration at the level of individual DataSources, by specifying a configBean on the dataSource (this is only applicable if you are using Spring; see below)

            I would like to use the configBean option, but the datasource still wants to open the hibernate.cfg.xml using the wrong Configuration class.

            Comment


              #7
              OK, at this point you must just have a broken installation, since #1 (hibernate.cfg.xml) is demonstrated in a sample.

              Did you use this install instructions to install? If you skip steps or just try to copy .jars around, that won't work.

              As far as this specific error, it suggests that you have no hibernate.cfg.xml in the classpath - at the moment, you do need to have one, even if you leave it empty and rely on Spring or annotations for the bulk of your configuration.

              Comment


                #8
                If you read my first post, I do have a sample working using a hibernate.cfg.xml file. Its using the same hibernate configuration as the master detail example in the showcase.

                The problem is when I change it to use hibernate annotations, the isomorphic Datasource is using:

                org.hibernate.cfg.Configuration

                when it should be using:

                org.hibernate.cfg.AnnotationConfiguration

                The stack trace shows that it is using the wrong configuration class.

                Please check the sample zip I posted, the project has the correct structure since its based off your ds-jpa sample.

                Comment


                  #9
                  At the moment, we only support annotated classes via Spring. This problem is probably arising because you are configuring annotated classes in the hibernate.cfg.xml file. Please try removing those entries from that file and instead switch to using the Spring property "annotatedClasses".

                  Comment


                    #10
                    Thanks Isomorphic, that worked. Here is my working configuration to help others.

                    masterDetail_order.ds.xml
                    Code:
                    <DataSource
                        ID="masterDetail_order"
                        serverType="hibernate"
                        configBean="mySessionFactory"
                        beanClassName="com.smartgwt.sample.server.Order"
                        dropExtraFields="false"
                    >
                        <fields>
                            <field name="orderID" type="sequence" primaryKey="true" canEdit="false" />
                            <field name="customerName" type="text" />
                            <field name="orderDate" type="date" />
                    
                            <field name="items" title= "Order Items" multiple="true"
                                   type="masterDetail_orderItem" 
                                   javaClass="com.smartgwt.sample.server.OrderItem"
                            />
                            <field name="trackingNumber" type="integer" />
                        </fields>
                        
                    </DataSource>
                    server.properties
                    Code:
                    # The webRoot directory:
                    # the directory that the servlet engine regards as the place where applications 
                    # that use the servlet engine should be installed.  Generally, it is safe to leave
                    # this at the default setting of __AUTODETECT__.  When the SmartClient server is
                    # started, it logs a message to stdout telling you the autodetected path to your
                    # webRoot.  If this path is not your actual webRoot, then you'll want to override
                    # this config parameter here.
                    #
                    # Valid values: 
                    #
                    # 1. Absolute path to the webRoot directory
                    #
                    # 2. Special token:  __AUTODETECT__
                    #    When this token is used, SmartClient attempts to auto-detect the webRoot using
                    #    standard servlet APIs.  This may or may not work - depending on your
                    #    container type and deployment type.  For example, WAR/EAR deployments
                    #    on some containers never make it to disk, and so the container refuses
                    #    to provide the webRoot path.
                    #  
                    #    If SmartClient cannnot detect the webRoot, it sets the webRoot to
                    #    __USE_CONTAINER__ (see below).
                    #
                    # 3.  Special token: __USE_CONTAINER__
                    #     When this token is used, SmartClient uses standard servet APIs for accessing
                    #     filesystem resources.  This is slower than direct file access and, since
                    #     the servlet APIs provide no mechanism for writing to disk, means that some
                    #     development tools like the FileAssembler will not work.
                    #
                    webRoot: __AUTODETECT__
                    
                    # if you've moved the isomorphic directory from its default location in webRoot,
                    # set the root-relative path to it here
                    #
                    # For example, if in your deployment the 'isomorphic' dir is in /foo/bar, then set
                    # then you'll need to set this to foo/bar/isomorphic
                    isomorphicPathRootRelative: SpringGWT_js/sc
                    
                    # administration app
                    apps.adminConsole.location: $webRoot/SpringGWT_js/sc/tools
                    ui.adminConsole.location: $webRoot/SpringGWT_js/sc/tools
                    
                    # -------------- PICK DATABASE TO USE --------------------
                    #
                    # The SmartClient SDK ships with examples that use a database as the persistence
                    # layer.  By default, the SDK uses a built-in version of HSQLDB, but you can
                    # specify a different database to use here.
                    
                    # which database do you want to use?  HSQLDB is enabled by default.
                    #sql.defaultDatabase: HSQLDB
                    
                    # If you want to use Mysql instead, uncomment the following line
                    # and comment all other sql.defaultDatabase definitions
                    #sql.defaultDatabase: Mysql
                    
                    # If you want to use Oracle instead, uncomment the following line
                    # and comment all other sql.defaultDatabase definitions
                    #sql.defaultDatabase: Oracle
                    
                    # If you want to use Postgres instead, uncomment the following line
                    # and comment all other sql.defaultDatabase definitions
                    #sql.defaultDatabase: PostgreSQL
                    
                    # If you want to use DB2 instead, uncomment the following line
                    # and comment all other sql.defaultDatabase definitions
                    #sql.defaultDatabase: DB2
                    
                    # -------------- SETTINGS FOR HSQLDB --------------------
                    
                    #sql.HSQLDB.database.type: hsqldb
                    #sql.HSQLDB.interface.type: driverManager
                    
                    #sql.HSQLDB.driver: org.hsqldb.jdbcDriver
                    #sql.HSQLDB.driver.url: jdbc:hsqldb:hsql://localhost/isomorphic
                    
                    # -------------- SETTINGS FOR JPA --------------------
                    
                    # According to JPA specifications only simple class name can be used in queries.
                    # Some providers follows these specs strictly (for example EclipseLink).
                    # Some providers allows using fully-qualified class name usage (for example Hibernate, Datanucleus).
                    # Setting defaluts to false - simple class name usage.
                    # To resolve class name collisions this setting can be set to true
                    # (should be used with provider supporting fully-qualified class name usage).
                    #jpa.useQualifiedClassName: true
                    
                    # Default EMF provider implementation (implements EMFProviderInterface).
                    # Fully qualified class name.
                    # Existing implementations:
                    # com.isomorphic.jpa.EMFProviderLMT - for Locally Managed Transactions (LMT)
                    # com.isomorphic.jpa.EMFProviderNoTransactions - no transactions support
                    # com.isomorphic.jpa.EMFProviderCMT - for Container Managed Transactions (CMT)
                    jpa.emfProvider: com.isomorphic.jpa.EMFProviderLMT
                    
                    # Settings for LMT type
                    
                    # Name of the datasource
                    jpa.persistenceUnitName: ds
                    
                    # Resource references for CMT type
                    
                    # EntityManager resource reference name declared in /WEB-INF/web.xml.
                    # Example declaration:
                    # <persistence-context-ref>
                    #     <persistence-context-ref-name>persistence/em</persistence-context-ref-name>
                    #     <persistence-unit-name>PERSISTENCE_UNIT_NAME</persistence-unit-name>
                    # </persistence-context-ref>
                    jpa.cmt.entityManager: persistence/em
                    
                    # Transaction resource reference name declared in /WEB-INF/web.xml.
                    # Example declaration:
                    # <resource-env-ref>
                    #     <resource-env-ref-name>persistence/tx</resource-env-ref-name>
                    #     <resource-env-ref-type>javax.transaction.UserTransaction</resource-env-ref-type>
                    # </resource-env-ref>
                    jpa.cmt.transaction: persistence/tx
                    
                    
                    # -------------- LOADING APP AND DATASOURCE DEFINITIONS --------------------
                    
                    # Where the system looks for DataSource definition files ([dataSourceId].ds.xml or
                    # [dataSourceID].ds.js).  It's useful to put all your DataSources in one 
                    # directory since DataSources are frequently shared between applications.  
                    # "project.datasources" is also where the DataSource Importer tool looks 
                    # for available DataSources.
                    project.datasources: $webRoot/ds
                    project.ui: $webRoot/shared/ui
                    project.apps: $webRoot/shared/app
                    
                    hibernate.config.lookupStyle: spring
                    hibernate.config.bean: mySessionFactory
                    hibernate.cfg.xml
                    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>
                    
                            <!-- Database connection settings -->
                            <property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
                            <property name="connection.url">jdbc:hsqldb:hsql://localhost/isomorphic</property>
                    
                            <!-- disable native hibernate connection pooling: it's not recommended for production
                                 use and can't handle connection re-establishment.  The recommended approach is
                                 to obtain database connections from the container and have the container manage
                                 the pool
                            -->        
                            <property name="connection.pool_size">0</property>
                    
                            <!-- SQL dialect -->
                            <property name="dialect">org.hibernate.dialect.HSQLDialect</property>
                    
                            <!-- Enable Hibernate's automatic session context management -->
                            <property name="current_session_context_class">org.hibernate.transaction.JDBCTransactionFactory</property>
                            
                            <!-- Release database connections when session are closed.  Otherwise, if the DB
                                 agressively cuts connections, we could end up trying to use a broken connection.
                            -->
                            <property name="hibernate.connection.release_mode">on_close</property>
                    
                            <!-- don't use a data cache -->
                            <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
                    
                            <!-- Pretty-print logged sql -->
                            <property name="format_sql">true</property>
                    
                            <property name="show_sql">true</property>
                    
                            <!-- Drop and re-create the database schema on startup -->
                            <property name="hbm2ddl.auto">update</property>
                    
                        </session-factory>
                    
                    </hibernate-configuration>
                    applicationContext.xml
                    Code:
                    <?xml version="1.0" encoding="UTF-8"?>
                    <beans xmlns="http://www.springframework.org/schema/beans"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
                    
                        <!-- Transaction manager for Hibernate-->
                        <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
                            <property name="sessionFactory" ref="mySessionFactory"/>
                        </bean>
                        
                        <!-- Hibernate SessionFactory -->
                        <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
                        <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
                        <property name="annotatedClasses">
                          <list>
                            <value>com.smartgwt.sample.server.Order</value>
                            <value>com.smartgwt.sample.server.OrderItem</value>
                          </list>
                        </property>
                        </bean>
                        
                    </beans>

                    Comment

                    Working...
                    X