I'm a complete newbie when it comes to Tapestry.  So forgive my
inexperience here.  I'm having a problem taking my Hello World Tapestry
Application to do a simple Hibernate thing.  A good chance I'm doing
something way wrong so I hope a kind soul can point out where I am
making my error.

I Have a Home.html that looks like:

<html>
<head>

</head>

<body>
  This is a test Application<p>
  Word = <span jwcid="insertWord">This text will be replaced by
Tapesty</span> <p>
  Opportunity = '<span jwcid="insertName">This text will be replaced by
Tapesty</span>' 
</body>
</html>

Home.page:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE page-specification PUBLIC
  "-//Apache Software Foundation//Tapestry Specification 3.0//EN"
  "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd";>
<!-- generated by Spindle, http://spindle.sourceforge.net -->

<page-specification class="edu.asu.clas.TapestryHibernate.Home">

    <description>add a description</description>
    
    <component id="insertWord" type="Insert">
                <binding name="value" expression="word"/>
    </component>

    <component id="insertName" type="Insert">
                <binding name="value" expression="name"/>
    </component>
    
Home.java: (This is the troublesome spot):

package edu.asu.clas.TapestryHibernate;

import org.apache.log4j.*;

import org.apache.tapestry.html.BasePage;
import org.hibernate.*;
import org.hibernate.cfg.*;
import edu.asu.clas.TapestryHibernate.Opportunity;
import java.util.List;
import java.util.ListIterator;

public class Home extends BasePage
{
  Session session = null;
  static SessionFactory sessionFactory = null;
  
  public String getWord()
  {
    Category.getInstance(Home.class).error("Returning Hubba");
    return "hubba";    
  }
  
  public String getName()
  {
    initSessionFactory();
    return "AA";
  }
  private void initSessionFactory()
  {
    try
    {
      if (sessionFactory == null)
      {
      // This step will read hibernate.cfg.xml and prepare hibernate for
use
//     sessionFactory = new
Configuration().configure().buildSessionFactory();
      
      Category.getInstance(Home.class).error("I'm ready to create a
configuration");      
      Configuration cfg = new Configuration();
      Category.getInstance(Home.class).error("I created a
configuration");      
      Category.getInstance(Home.class).error("I'm ready to configure the
configuration");      
      cfg.configure("hibernate.cfg.xml");
      Category.getInstance(Home.class).error("I configured the
configuration");      
      
      Category.getInstance(Home.class).error("I'm ready to build the
sessionFactory");
      sessionFactory = cfg.buildSessionFactory();
      Category.getInstance(Home.class).error("I built the
sessionFactory");
      }
    }
    catch(Exception e)
    {      
      Category.getInstance(Home.class).error("Transaction- " +
e.getMessage());
    }   
  }
}
-----------------------------------------------------------------------

Here's the problem. In getName(), if I comment out the call to
initSessionFactory() all runs as expected. If I make a call to
initSessionFactory() from getName I get the error:

org.apache.tapestry.BindingException
Unable to read OGNL expression '<parsed OGNL expression>' of
[EMAIL PROTECTED]: name
binding:        ExpressionBinding[Home name]
location:       context:/WEB-INF/Home.page, line 16, column 44
11      <component id="insertWord" type="Insert">
12      <binding name="value" expression="word"/>
13      </component>
14      
15      <component id="insertName" type="Insert">
16      <binding name="value" expression="name"/>
17      </component>
18      
19      </page-specification>

 With line 16 highlighted.  

 I'm using log4j but not all of the error lines are logged.  The log
looks as follows:

14:41:01,927 INFO  [TomcatDeployer] deploy, ctxPath=/TapestryHibernate,
warUrl=.../tmp/deploy/tmp216TapestryHibernate.war/
14:41:04,416 INFO  [ApplicationServlet] Initialized application servlet
'TapestryHibernate': 791 millis to create HiveMind Registry, 2,337
millis overall.
14:41:17,204 ERROR [Home] Returning Hubba
14:41:17,291 ERROR [Home] I'm ready to create a configuration
14:41:17,293 ERROR [Home] I created a configuration
14:41:17,294 ERROR [Home] I'm ready to configure the configuration
14:41:17,295 INFO  [Configuration] configuring from resource:
hibernate.cfg.xml
14:41:17,296 INFO  [Configuration] Configuration resource:
hibernate.cfg.xml
14:41:17,319 INFO  [Configuration] Reading mappings from resource:
edu/asu/clas/TapestryHibernate/Opportunity.hbm.xml
14:41:17,412 INFO  [HbmBinder] Mapping class:
edu.asu.clas.TapestryHibernate.Opportunity -> opportunity
14:41:17,415 INFO  [Configuration] Configured SessionFactory:
researchopps
14:41:17,416 ERROR [Home] I configured the configuration
14:41:17,417 ERROR [Home] I'm ready to build the sessionFactory
14:41:17,418 INFO  [Configuration] processing extends queue
14:41:17,419 INFO  [Configuration] processing collection mappings
14:41:17,419 INFO  [Configuration] processing association property
references
14:41:17,420 INFO  [Configuration] processing foreign key constraints
14:41:17,421 INFO  [DriverManagerConnectionProvider] Using Hibernate
built-in connection pool (not for production use!)
14:41:17,422 INFO  [DriverManagerConnectionProvider] Hibernate
connection pool size: 20
14:41:17,423 INFO  [DriverManagerConnectionProvider] autocommit mode:
false
14:41:17,423 INFO  [DriverManagerConnectionProvider] using driver:
com.mysql.jdbc.Driver at URL:
jdbc:mysql://server.la.asu.edu/researchopps
14:41:17,424 INFO  [DriverManagerConnectionProvider] connection
properties: {user=xxx, password=xxx}
14:41:17,474 INFO  [SettingsFactory] RDBMS: MySQL, version: 5.0.18-log
14:41:17,475 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:41:17,478 INFO  [Dialect] Using dialect:
org.hibernate.dialect.MySQLDialect
14:41:17,480 INFO  [TransactionFactoryFactory] Using default transaction
strategy (direct JDBC transactions)
14:41:17,480 INFO  [TransactionManagerLookupFactory] No
TransactionManagerLookup configured (in JTA environment, use of
read-write or transactional second-level cache is not recommended)
14:41:17,481 INFO  [SettingsFactory] Automatic flush during
beforeCompletion(): disabled
14:41:17,482 INFO  [SettingsFactory] Automatic session close at end of
transaction: disabled
14:41:17,482 INFO  [SettingsFactory] JDBC batch size: 15
14:41:17,483 INFO  [SettingsFactory] JDBC batch updates for versioned
data: disabled
14:41:17,484 INFO  [SettingsFactory] Scrollable result sets: enabled
14:41:17,484 INFO  [SettingsFactory] JDBC3 getGeneratedKeys(): enabled
14:41:17,485 INFO  [SettingsFactory] Connection release mode: auto
14:41:17,486 INFO  [SettingsFactory] Maximum outer join fetch depth: 2
14:41:17,486 INFO  [SettingsFactory] Default batch fetch size: 1
14:41:17,487 INFO  [SettingsFactory] Generate SQL with comments:
disabled
14:41:17,487 INFO  [SettingsFactory] Order SQL updates by primary key:
disabled
14:41:17,488 INFO  [SettingsFactory] Query translator:
org.hibernate.hql.ast.ASTQueryTranslatorFactory
14:41:17,490 INFO  [ASTQueryTranslatorFactory] Using
ASTQueryTranslatorFactory
14:41:17,491 INFO  [SettingsFactory] Query language substitutions: {}
14:41:17,531 INFO  [SettingsFactory] Second-level cache: enabled
14:41:17,532 INFO  [SettingsFactory] Query cache: disabled
14:41:17,532 INFO  [SettingsFactory] Cache provider:
org.hibernate.cache.EhCacheProvider
14:41:18,302 INFO  [DriverManagerConnectionProvider] cleaning up
connection pool: jdbc:mysql://server.la.asu.edu/researchopps

 There is no "I created the sessionFactory in in the log or a "I created
the configuration" in the log :(
 
 The interesting part is that if I comment all the of if (sessionFactory
== null) statements and then uncomment them one by one, the line that
definitively causes this break to happen is when I finally uncomment:

sessionFactory = cfg.buildSessionFactory();

 If I comment out this line I get all the log4j error lines (which
should be info lines but I was getting frustrated).  Even the "I
configured the configuration" entry.

 I'm assuming I am doing something very very stupid here.  When it bombs
it apparently fries the ability to give me what exactly caused the bomb.
I assume that it is a hibernate exception causing the grief but I cannot
get to what the exact Exception actually is (as it doesn't get logged).
A useful error message would be nice for me to google on and continue my
jedi studies).

 Any ideas?

 In oodles and oodles of frustration,

- Damian


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to