[jboss-user] [JBoss Seam] - Problems Using Oracle datasource to run a Seam Test using Te

kfletcher2005 do-not-reply at jboss.com
Tue Nov 27 12:54:56 EST 2007


I am using the booking example as a reference for my testNG test suite.  I am basically trying to accomplish the same thing only I want to use oracle as my database instead of the hypersonic db.   Any help would be greatly appreciated.

Apparently the microcontainer that the tests are executed in needs some tables created in the datasource in order to function properly, and I have set the property in the persistence.xml to allow create/drop ability.  However, only 2 of N tables gets created (I'm guessing the sql to create the tables is not speaking oracle entirely correctly, it is possibly talking in HSSQL).  The 2 tables that were successfully created are simple tables with varchar2 datatypes as columns, the others tables that are trying to be created have datatypes that don't match oracles datatypes, so I'm guessing table creation is not speaking in oracle somehow.  So now when I try to launch a unit test, I get the table or view does not exist error, because the table that the microcontainer needed did not get auto-created properly (probably due to malformed oracle syntax)

Here is the exception I get....

  [testng]   C:\devSeam\InternalJavaWebAppTemplate\test-build\ijwatTest.xml
  |    [testng] ERROR [org.jboss.jms.util.ExceptionUtil] ServerPeer[0] startService
  |    [testng] java.sql.SQLException: ORA-00942: table or view does not exist
  |    [testng] 	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
  |    [testng] 	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
  |    [testng] 	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
  |    [testng] 	at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
  |    [testng] 	at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
  |    [testng] 	at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:799)
  |    [testng] 	at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1038)
  |    [testng] 	at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:839)
  |    [testng] 	at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1133)
  |    [testng] 	at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
  |    [testng] 	at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)
  | 

To reproduce this error, I did the following bootstrap replacements/modifications and other ds and config files:

1) replaced a bootstrap file for the microcontainer (generated by seam-gen), namely:  replaced the hsqldb-persisence-service.xml with mine-persistenence-service.xml to point my datasource instead of DefaultDS.


  | <?xml version="1.0" encoding="UTF-8"?>
  | 
  | <!--
  |      Hypersonic persistence deployment descriptor.
  | 
  |      $Id: hsqldb-persistence-service.xml,v 1.1 2007/06/15 05:20:58 gavin Exp $
  |  -->
  | 
  | <server>
  | 
  |    <mbean code="org.jboss.messaging.core.plugin.JDBCPersistenceManagerService"
  |       name="jboss.messaging:service=PersistenceManager"
  |       xmbean-dd="xmdesc/JDBCPersistenceManager-xmbean.xml">
  |       <depends>jboss.jca:service=DataSourceBinding,name=InternalJavaWebAppTemplateDatasource</depends>
  |       <depends optional-attribute-name="TransactionManager">jboss:service=TransactionManager</depends>
  |       <attribute name="DataSource">java:/InternalJavaWebAppTemplateDatasource</attribute>
  |       <attribute name="CreateTablesOnStartup">true</attribute>
  |       <attribute name="UsingBatchUpdates">false</attribute>
  |       <attribute name="MaxParams">500</attribute>
  |    </mbean>
  | 
  | 
  |    <mbean code="org.jboss.messaging.core.plugin.DefaultPostOfficeService"
  |       name="jboss.messaging:service=PostOffice"
  |       xmbean-dd="xmdesc/DefaultPostOffice-xmbean.xml">
  |       <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
  |       <depends>jboss.jca:service=DataSourceBinding,name=InternalJavaWebAppTemplateDatasource</depends>
  |       <depends optional-attribute-name="TransactionManager">jboss:service=TransactionManager</depends>
  |       <attribute name="PostOfficeName">JMS</attribute>
  |       <attribute name="DataSource">java:/InternalJavaWebAppTemplateDatasource</attribute>
  |       <attribute name="CreateTablesOnStartup">true</attribute>
  |    </mbean>
  | 
  |    <mbean code="org.jboss.jms.server.plugin.JDBCJMSUserManagerService"
  |       name="jboss.messaging:service=JMSUserManager"
  |       xmbean-dd="xmdesc/JMSUserManager-xmbean.xml">
  |       <depends>jboss.jca:service=DataSourceBinding,name=InternalJavaWebAppTemplateDatasource</depends>
  |       <depends optional-attribute-name="TransactionManager">jboss:service=TransactionManager</depends>
  |       <attribute name="DataSource">java:/InternalJavaWebAppTemplateDatasource</attribute>
  |       <attribute name="CreateTablesOnStartup">true</attribute>
  |       <attribute name="SqlProperties"><![CDATA[
  | POPULATE.TABLES.1=INSERT INTO JBM_USER (USER_ID,PASSWD,CLIENTID) VALUES ('dilbert','dogbert','dilbert-id')
  |       ]]></attribute>
  |    </mbean>
  | 
  | </server>
  | 

2) replace and added the hsqldb-ds.xml file with mine-ds.xml  to

<?xml version="1.0" encoding="UTF-8"?>
  | 
  | <!DOCTYPE datasources
  |     PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
  |     "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
  |     
  | <datasources>
  |    
  |    <local-tx-datasource>
  |       <jndi-name>InternalJavaWebAppTemplateDatasource</jndi-name>
  |       <connection-url>jdbc:oracle:thin:@<myhost>:1521:DWEBAPPS</connection-url>
  |       <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
  |       <user-name>myusername</user-name>
  |       <password>mypassword</password>
  | <!-- 
  |       <exception-sorter-class-name>
  |          org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
  |       </exception-sorter-class-name>
  |       <metadata>
  |          <type-mapping>mySQL</type-mapping>
  |       </metadata>
  | -->
  |    </local-tx-datasource>
  |     
  | </datasources>
  | 
  | 

3) Changed the login-config.xml

   <application-policy name="OracleDbRealm">
  |      <authentication>
  |        <login-module code="org.jboss.resource.security.ConfiguredIdentityLoginModule"
  |          flag="required">
  |          <module-option name="userName">myusername</module-option>
  |          <module-option name="password">mypassword</module-option>
  |          <module-option name="managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=InternalJavaWebAppTemplateDatasource</module-option>
  |        </login-module>
  |      </authentication>
  |    </application-policy>

4) changed the persistence-test.xml to point to my datasource.

5) made sure of this in my mine-persistenence-service.xml :  <attribute name="CreateTablesOnStartup">true</attribute>  

6) made sure of this in my persistence-test.xml

<property name="hibernate.hbm2ddl.auto" value="create-drop"/>


And oh, by the way..  my testNG class is as follows... really simple...

package com.cox.ijwat.test;
  | 
  | import org.jboss.seam.contexts.Contexts;
  | import org.jboss.seam.mock.SeamTest;
  | import org.testng.annotations.Test;
  | 
  | public class IjwatTest extends SeamTest
  | {
  | 
  | 	@Test
  | 	public void testSomeCrud() throws Exception
  | 	{
  | 		new FacesRequest()
  | 		{
  | 
  | 			@Override
  | 			protected void invokeApplication() throws Exception
  | 			{
  | 				//Contexts.getSessionContext().set("user", new User("Gavin King", "foobar", "gavin"));
  | 				Contexts.getSessionContext().set("user", null);
  | 				setValue("#{identity.username}", "gavin");
  | 				setValue("#{identity.password}", "foobar");
  | 				invokeAction("#{identity.login}");
  | 			}
  | 
  | 		}.run();
  | 
  | 	}
  | }
  | 

Thanks in advance... Kent

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4108173#4108173

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4108173



More information about the jboss-user mailing list