Hosted mode with local database

118 views
Skip to first unread message

alejeune

unread,
Sep 19, 2011, 12:06:19 PM9/19/11
to gwt-cx
Hi Rob,

I'm running the web application 'gwtcx-sample-serendipity-0.7.0-
SNAPSHOT' in hosted mode. I reached the login page successfully but
when I trying to send the credentials to the server, it fails due to
'cannot open connection' exception.

I updated the PU-NAME context parameter in web.xml to HSQLDB-HOSTED-
MODE-PU
[INFO] 16:52:01,500 DEBUG gwt-log:72 - set Persistence Unit name =
HSQLDB-HOSTED-MODE-PU

but when I run the application I got this error message
00:00:25,031 [INFO] (SerendipitySignInPagePresenter.java:93)
2011-09-19 16:52:34,359 [DEBUG] onFailure() -
org.hibernate.exception.GenericJDBCException: Cannot open connection

I checked in the persistence in order to change the connection url to
this value
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.HSQLDialect" />
<property name="hibernate.connection.driver_class"
value="org.hsqldb.jdbcDriver" />
<property name="hibernate.connection.url" value="jdbc:hsqldb:file:/
data/serendipitydb;ifexists=true" />
<property name="hibernate.connection.username" value="sa" />
<property name="hibernate.connection.password" value="" />
</properties>

but now do I need to create a database with these following steps ?
java -cp lib/hsqldb.jar org.hsqldb.Server -database.0 file:<localdb> -
dbname.0 <dbidentifier>
java -cp lib\hsqldb.jar org.hsqldb.util.SqlTool --rcFile sqltool.rc
<localdb> "<path to sql>\user.sql"

or is there another way to build the local database for a hosted
mode ?

Thanks,

Arnaud


Rob Ferguson

unread,
Sep 19, 2011, 4:39:53 PM9/19/11
to gwt...@googlegroups.com
Hi,

There is a copy of the database in the sample's \src\main\webapp\data directory. When you build the sample is copied to \target\gwtcx-sample-serendipity-0.7.0-SNAPSHOT\data.

A copy of the SQL for the sample database is generated in /target/hibernate3 directory.

You just need to update the url entry in the persistence.xml file:

->

  <!-- HSQLDB HOSTED MODE PU -->
  <persistence-unit name="HSQLDB-HOSTED-MODE-PU" transaction-type="RESOURCE_LOCAL">
  <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <class>com.gwtcx.server.domain.User</class>
    <class>com.gwtcx.server.domain.Account</class>
    <class>com.gwtcx.server.domain.Address</class>
    <class>com.gwtcx.server.domain.Report</class>
    <exclude-unlisted-classes/>

    <properties>
    <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
    <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver" />
    <property name="hibernate.connection.url" value="jdbc:hsqldb:file:/tools/common/tomcat-7.0.16/webapps/serendipity/data/serendipitydb;ifexists=true" />

    <property name="hibernate.connection.username" value="sa" />
    <property name="hibernate.connection.password" value="" />
    </properties>
  </persistence-unit>

->

And, remember there are two copies of the persistence.xml file. One in META-INF and one in WEB-INF/classes/META-INF.

You also need to update the PU-NAME context parameter in web.xml from HSQLDB-
TOMCAT7-CP-PU to HSQLDB-HOSTED-MODE-PU.

If you deploy an exploded war to tomcat's webapp directory then don't
forget to copy the application's context.xml to tomcat-'s conf\Catalina
\localhost directory and rename it so that it matches the
application's directory name (e.g. serendipity.xml).

My HSQLDB sqltool.rc file:

->

# $Id: sqltool.rc 3348 2009-12-15 14:24:19Z unsaved $

# This is a sample RC configuration file for HSQLDB's SqlTool

# You can run SqlTool as follows:
#    On Unix: java -jar $HSQLDB_HOME/lib/sqltool.jar localdb
#             java -jar ./sqltool.jar localdb
#    On Windows: java -jar %HSQLDB_HOME%/lib/sqltool.jar localdb
#                java -jar sqltool.jar localdb

# This will access the 'localdb' urlid definition.

# A local, persistent database.
urlid localdb
url jdbc:hsqldb:file:/tools/common/tomcat-7.0.16/webapps/serendipity/data/serendipitydb;shutdown=true
username SA
password
transiso TRANSACTION_READ_COMMITTED

# This file must be placed in $HSQLDB_HOME/home (e.g. C:\Users\Rob Ferguson).

->

Cheers
Rob

alejeune

unread,
Sep 20, 2011, 9:34:42 AM9/20/11
to gwt-cx
Thanks again for all your support !

I did change the persistence.xml files but then I got this error
message.

[INFO] 14:37:14,796 DEBUG gwt-log:72 - puName: HSQLDB-HOSTED-MODE-PU
[INFO] 14:37:14,796 DEBUG gwt-log:72 - dsName: jdbc/HSQLDB-TOMCAT7-CP
[INFO] 14:37:14,796 DEBUG gwt-log:72 - set Persistence Unit name =
HSQLDB-HOSTED-MODE-PU
[INFO] 14:37:14,828 DEBUG gwt-log:72 - FileUpload Servlet
[INFO] 14:37:14,828 DEBUG gwt-log:72 - tmpDir: C:\DOCUME~1\arlejeun
\LOCALS~1\Temp\Jetty_127_0_0_1_8888_www____-fojw0f
[INFO] 14:37:14,828 DEBUG gwt-log:72 - destinationDir: C:\eclipse
\Workspace\gwtcx\gwtcx-samples\gwtcx-sample-serendipity\target\www
\files\upload
[INFO] 14:37:14,828 DEBUG gwt-log:72 - FileDownload Servlet
[INFO] 14:37:14,828 DEBUG gwt-log:72 - destinationDir: C:\eclipse
\Workspace\gwtcx\gwtcx-samples\gwtcx-sample-serendipity\target\www
\files\download
[INFO] 14:37:14,859 DEBUG JspServlet:80 - Le répertoire de travail
(scratch dir) pour le moteur de JSP est: C:\DOCUME~1\arlejeun
\LOCALS~1\Temp\Jetty_127_0_0_1_8888_www____-fojw0f\jsp
[INFO] 14:37:14,859 DEBUG JspServlet:82 - IMPORTANT: Ne pas modifier
les servlets générées
[INFO] 14:37:47,562 DEBUG gwt-log:72 - createEntityManager() - puName:
HSQLDB-HOSTED-MODE-PU
[INFO] 14:37:49,125 WARN SettingsFactory:147 - Could not obtain
connection to query metadata
[INFO] java.sql.SQLException: wrong database file version

The latest version I installed on my environment is hsqldb-2.2.5 and
I've seen that this database is not compatible with the one used in
the gwtcx\libs folder so I install the latest hsqldb.jar on my local
repository.

Then it did work just fine .. with the dashboard examples and the
calendar modules.

I'm learning a lot from your framework & tutorials which are both very
clear and instructive.


Thanks again Rob for your time !

Arnaud

On 19 sep, 22:39, Rob Ferguson <rob.fergu...@uptick.com.au> wrote:
> Hi,
>
> There is a copy of the database in the sample's \src\main\webapp\data
> directory. When you build the sample is copied to
> \target\gwtcx-sample-serendipity-0.7.0-SNAPSHOT\data.
>
> A copy of the SQL for the sample database is generated in /target/hibernate3
> directory.
>
> You just need to update the url entry in the persistence.xml file:
>
> ->
>
>   <!-- HSQLDB HOSTED MODE PU -->
>   <persistence-unit name="HSQLDB-HOSTED-MODE-PU"
> transaction-type="RESOURCE_LOCAL">
>   <provider>org.hibernate.ejb.HibernatePersistence</provider>
>     <class>com.gwtcx.server.domain.User</class>
>     <class>com.gwtcx.server.domain.Account</class>
>     <class>com.gwtcx.server.domain.Address</class>
>     <class>com.gwtcx.server.domain.Report</class>
>     <exclude-unlisted-classes/>
>     <properties>
>     <property name="hibernate.dialect"
> value="org.hibernate.dialect.HSQLDialect" />
>     <property name="hibernate.connection.driver_class"
> value="org.hsqldb.jdbcDriver" />
> *    <property name="hibernate.connection.url"
> value="jdbc:hsqldb:file:/tools/common/tomcat-7.0.16/webapps/serendipity/dat­a/serendipitydb;ifexists=true"
> />*
> jdbc:hsqldb:file:/tools/common/tomcat-7.0.16/webapps/serendipity/data/seren­dipitydb;shutdown=true
> username SA
> password
> transiso TRANSACTION_READ_COMMITTED
>
> # This file must be placed in $HSQLDB_HOME/home (e.g. C:\Users\Rob
> Ferguson).
>
> ->
>
> Cheers
> Rob
>
> > Arnaud- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -
Reply all
Reply to author
Forward
0 new messages