users@glassfish.java.net

RE: In memory HSQLDB fails to start inside Glassfish v2.1.1

From: Martin Gainty <mgainty_at_hotmail.com>
Date: Tue, 22 Jun 2010 16:07:29 -0400

running a database dependent on published WebService method configurations is not such as good idea (since a WebService doesnt become active until contacted)
http://java.sun.com/developer/technicalArticles/J2SE/jax_ws_2/

 

better to get yourself to shell prompt and run it there

this will have the ameliorative side-effect of retaining your db messages in the shell instead of loading up the Glassfish log with DB and Glassfish messages

 

# Sample ResourceBundle properties file
server.help = Usage: java org.hsqldb.Server [options]\n\
\n\
+----------------+-------------+----------+------------------------------+\n\
| OPTION | TYPE | DEFAULT | DESCRIPTION |\n\
+----------------+-------------+----------+------------------------------|\n\
| -? | -- | -- | prints this message |\n\
| -address | name|number | any | server inet address |\n\
| -port | number | 9001/544 | port at which server listens |\n\
| -database.i | [type]spec | 0=test | name of database i |\n\
| -dbname.i | alias | -- | url alias for database i |\n\
| -silent | true|false | true | false => display all queries |\n\
| -trace | true|false | false | display JDBC trace messages |\n\
| -tls | true|false | false | TLS/SSL (secure) sockets |\n\
| -no_system_exit| true|false | false | do not issue System.exit() |\n\
+----------------+-------------+----------+------------------------------+\n\


HTH
Martin Gainty
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.



 

> Date: Tue, 22 Jun 2010 12:57:37 -0700
> From: glassfish_at_javadesktop.org
> To: users_at_glassfish.dev.java.net
> Subject: In memory HSQLDB fails to start inside Glassfish v2.1.1
>
> I'm trying to start in memory HSQLDBs inside a webapp. These are meant as transient DBs, and I can't use JavaDB. I can never open a connection once HSQLDB is started. If you create a Webapp maven project in Netbeans and then add these to it. My hsqldb 1.8.0.10 jar is in my domain lib/ext. Once deployed, I tested the webservice, submitting "start" to it, then tried to connect to the now running DB using the Services->Database->HSLQDB connection, but it never connects.
>
> Any ideas?
>
> Maven pom.xml
> [code]
> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
> <modelVersion>4.0.0</modelVersion>
> <groupId>com.ciminc</groupId>
> <artifactId>Maven-Web</artifactId>
> <packaging>war</packaging>
> <version>1.0-SNAPSHOT</version>
> <name>Maven-Web JEE5 Webapp</name>
> <url>http://maven.apache.org</url>
> <dependencies>
>
> <dependency>
> <groupId>javax.servlet</groupId>
> <artifactId>servlet-api</artifactId>
> <version>2.5</version>
> <scope>provided</scope>
> </dependency>
>
> <dependency>
> <groupId>javax.servlet.jsp</groupId>
> <artifactId>jsp-api</artifactId>
> <version>2.1</version>
> <scope>provided</scope>
> </dependency>
>
> <dependency>
> <groupId>junit</groupId>
> <artifactId>junit</artifactId>
> <version>4.3.1</version>
> <scope>test</scope>
> </dependency>
>
> <dependency>
> <groupId>com.sun.xml.ws</groupId>
> <artifactId>webservices-rt</artifactId>
> <version>1.4</version>
> <scope>provided</scope>
> </dependency>
> <dependency>
> <groupId>org.hsqldb</groupId>
> <artifactId>hsqldb</artifactId>
> <version>1.8.0.10</version>
> <scope>provided</scope>
> </dependency>
> </dependencies>
> <build>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
> <version>2.0.2</version>
> <configuration>
> <source>1.5</source>
> <target>1.5</target>
> </configuration>
> </plugin>
> <plugin>
> <groupId>org.codehaus.mojo</groupId>
> <artifactId>jaxws-maven-plugin</artifactId>
> <version>1.10</version>
> <executions>
> <execution>
> <goals>
> <goal>wsimport</goal>
> </goals>
> <configuration>
> <wsdlFiles>
> <wsdlFile>localhost_8080/Maven-Web/ProtoWebServiceService.wsdl</wsdlFile>
> </wsdlFiles>
> <staleFile>${project.build.directory}/jaxws/stale/ProtoWebServiceService.stale</staleFile>
> </configuration>
> <id>wsimport-generate-ProtoWebServiceService</id>
> <phase>generate-sources</phase>
> </execution>
> </executions>
> <dependencies>
> <dependency>
> <groupId>javax.xml</groupId>
> <artifactId>webservices-api</artifactId>
> <version>1.4</version>
> </dependency>
> </dependencies>
> <configuration>
> <sourceDestDir>${project.build.directory}/generated-sources/jaxws-wsimport</sourceDestDir>
> <xnocompile>true</xnocompile>
> <verbose>true</verbose>
> <extension>true</extension>
> <catalog>${basedir}/src/jax-ws-catalog.xml</catalog>
> </configuration>
> </plugin>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-war-plugin</artifactId>
> <version>2.0.2</version>
> <configuration>
> <webResources>
> <resource>
> <directory>src</directory>
> <targetPath>WEB-INF</targetPath>
> <includes>
> <include>jax-ws-catalog.xml</include>
> <include>wsdl/**</include>
> </includes>
> </resource>
> </webResources>
> </configuration>
> </plugin>
> </plugins>
> <finalName>Maven-Web</finalName>
> </build>
> <properties>
> <netbeans.hint.deploy.server>J2EE</netbeans.hint.deploy.server>
> </properties>
> </project>
> [/code]
>
> Web service to start it
> [code]
> @WebService
> public class ProtoWebService {
> @WebMethod
> public String webProcedure(String arg) {
> if (arg.equals("start"))
> EmbeddedDatabase.startEmbeddedDb();
> else
> EmbeddedDatabase.stopEmbeddedDb();
>
> return arg;
> }
> }
> [/code]
>
> EmbeddedDatabase
> [code]
> public class EmbeddedDatabase {
> private enum Settings {user, password, driver, url, dialect};
> private static final Map<Settings,String> mobileSettings = new EnumMap<Settings,String>(Settings.class);
> private static Server mobileServer;
> static {
> mobileSettings.put(Settings.user, "mobileRepo");
> mobileSettings.put(Settings.password, "mobileRepo");
> mobileSettings.put(Settings.driver, "org.hsqldb.jdbcDriver");
> mobileSettings.put(Settings.url, "jdbc:hsqldb:hsql://localhost:10023/mobileRepo");
> mobileSettings.put(Settings.dialect, "org.hibernate.dialect.HSQLDialect");
> }
>
> public static void startEmbeddedDb() {
> mobileServer = new Server();
> String portStr = mobileSettings.get(Settings.url).substring(
> mobileSettings.get(Settings.url).indexOf("localhost:")+"localhost:".length(),
> mobileSettings.get(Settings.url).indexOf("/", mobileSettings.get(Settings.url).indexOf("localhost:")+1));
> mobileServer.setPort(Integer.parseInt(portStr));
> mobileServer.putPropertiesFromString("database.0=mem:" +
> mobileSettings.get(Settings.url).substring(mobileSettings.get(Settings.url).lastIndexOf("/") + 1));
> mobileServer.putPropertiesFromString("dbname.0=" + mobileSettings.get(Settings.user));
> mobileServer.setNoSystemExit(true);
> mobileServer.start();
> }
>
> public static void stopEmbeddedDb() {
> mobileServer.shutdown();
> mobileServer = null;
> }
> [/code]
> [Message sent by forum member 'ciminc']
>
> http://forums.java.net/jive/thread.jspa?messageID=475407
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
                                               
_________________________________________________________________
The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail.
http://www.windowslive.com/campaign/thenewbusy?tile=multiaccount&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4