[JBoss Seam] - Re: Test database with Seam2, Maven and TestNG?
by andrew.rw.robinson
I got it working, but it was a configuration pain. For those that read this post here is a very quick howto:
| * create src/main/conf - this will be files that are added to the war but not added to target/classes on build (and therefore will not interfere with testing)
| * move src/main/resources/META-INF/persistence.xml to src/main/conf/META-INF/persistence.xml
| * create src/test/resources/META-INF/persistence.xml (see below for example)
| * set the base directory for surefire to ensure that the relative paths work
| * configure pom to include src/main/conf
|
src/test/resources/META-INF/persistence.xml:
<persistence
| xmlns="http://java.sun.com/xml/ns/persistence"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
| version="1.0">
| <persistence-unit name="testDatabase" transaction-type="RESOURCE_LOCAL">
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <mapping-file>file:classes/META-INF/orm.xml</mapping-file>
| <jar-file>file:classes</jar-file>
| <properties>
| ...
| </properties>
| </persistence-unit>
| </persistence>
The mapping-file and jar-file allow the entities be picked up as if the file was in the src/main/resources/META-INF was used.
pom.xml excerpts:
...
| <plugin>
| <artifactId>maven-surefire-plugin</artifactId>
| <version>2.4-SNAPSHOT</version>
| <configuration>
| <workingDirectory>${project.build.directory}</workingDirectory>
| <includes>
| <include>**/*Test.java</include>
| </includes>
| </configuration>
| </plugin>
| <plugin>
| <artifactId>maven-war-plugin</artifactId>
| <version>2.1-alpha-2-SNAPSHOT</version>
| <configuration>
| <webResources>
| <resource>
| <directory>src/main/conf</directory>
| <targetPath>WEB-INF/classes</targetPath>
| </resource>
| </webResources>
| </configuration>
| </plugin>
| ...
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4114496#4114496
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4114496
18 years, 4 months
[JBoss Seam] - How to uses DateTimeConverter in .page.xml parameter?
by terryb
I am in a process of upgrading to Seam 2GA; and getting this error I wasn't getting with Seam 1.2.1GA.
I have date/time fields on xhtml form; for which I set default values in page action. I am getting attached errors which appears to be related to date value conversion when writing to bean props.
I am not sure how to add converter to page paramter???
convertjavax.faces.convert.DateTimeConverter
| .page.xml
| ...
| <param name="settlementDateFrom" value="#{paymentReconciliation.settlementDateFrom}"/>
| <param name="settlementDateTo" value="#{paymentReconciliation.settlementDateTo}"/>
| ...
|
|
| Error: If without converter in page parameter
| ...
| ERROR [SeamPhaseListener] uncaught exception
| javax.el.ELException: java.lang.IllegalArgumentException: argument type mismatch
| at javax.el.BeanELResolver.setValue(BeanELResolver.java:116)
| at javax.el.CompositeELResolver.setValue(CompositeELResolver.java:68)
| at com.sun.faces.el.FacesCompositeELResolver.setValue(FacesCompositeELResolver.java:93)
| at org.jboss.el.parser.AstPropertySuffix.setValue(AstPropertySuffix.java:73)
| at org.jboss.el.parser.AstValue.setValue(AstValue.java:84)
| at org.jboss.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:249)
| at org.jboss.seam.core.Expressions$1.setValue(Expressions.java:117)
| at org.jboss.seam.navigation.Pages.applyConvertedValidatedValuesToModel(Pages.java:779)
| ...
|
|
| when adding converter, the error below occurs
|
| ...
| <param name="settlementDateFrom" converterId="javax.faces.convert.DateTimeConverter" value="#{paymentReconciliation.settlementDateFrom}"/>
| <param name="settlementDateTo" converterId="javax.faces.convert.DateTimeConverter" value="#{paymentReconciliation.settlementDateTo}"/>
| ...
|
|
| FATAL [application] JSF1006: Cannot instantiate converter of type javax.faces.convert.DateTimeConverter
| 11:51:56,045 WARN [Param] could not create converter for: settlementDateTo
| javax.faces.FacesException: Expression Error: Named Object: javax.faces.convert.DateTimeConverter not found.
| at com.sun.faces.application.ApplicationImpl.createConverter(ApplicationImpl.java:726)
| at org.jboss.seam.jsf.SeamApplication.createConverter(SeamApplication.java:112)
| at org.jboss.seam.navigation.Param.getConverter(Param.java:52)
|
| OR
| ...
| <param name="settlementDateFrom" converterId="org.jboss.seam.ui.converter.DateTimeConverter" value="#{paymentReconciliation.settlementDateFrom}"/>
| <param name="settlementDateTo" converterId="org.jboss.seam.ui.converter.DateTimeConverter" value="#{paymentReconciliation.settlementDateTo}"/>
| ...
|
| FATAL [application] JSF1006: Cannot instantiate converter of type org.jboss.seam.ui.converter.DateTimeConverter
| 11:58:57,301 WARN [Param] could not create converter for: settlementDateFrom
| javax.faces.FacesException: Expression Error: Named Object: org.jboss.seam.ui.converter.DateTimeConverter not found.
| at com.sun.faces.application.ApplicationImpl.createConverter(ApplicationImpl.java:726)
| at org.jboss.seam.jsf.SeamApplication.createConverter(SeamApplication.java:112)
| at org.jboss.seam.navigation.Param.getConverter(Param.java:52)
| at org.jboss.seam.navigation.Param.getStringValueFromModel(Param.java:142)
| at org.jboss.seam.navigation.Pages.updateStringValuesInPageContextUsingModel(Pages.java:820)
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4114495#4114495
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4114495
18 years, 4 months
[JBoss Seam] - Re: Integration test - PROVIDER_URL not provided in jndi.pr
by piotr.porzucek
I've downgraded to 2.0.0.GA. However now I'm getting this exception:
| ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error installing to Described: name=ServerConfig state=PreInstall
| java.lang.NoClassDefFoundError: Lorg/jboss/system/server/BaseServerConfig;
| at java.lang.Class.getDeclaredFields0(Native Method)
| at java.lang.Class.privateGetDeclaredFields(Class.java:2232)
| at java.lang.Class.getDeclaredFields(Class.java:1715)
| at org.jboss.aop.ClassContainer$1.run(ClassContainer.java:100)
| at java.security.AccessController.doPrivileged(Native Method)
| at org.jboss.aop.ClassContainer.populateFieldTable(ClassContainer.java:96)
| at org.jboss.aop.ClassContainer.createFieldTable(ClassConta
|
Strange, but class jboss/system/server/BaseServerConfig doesn't exist in jboss-system.jar. My classpath looks like this:
jboss-seam-2.0.0.GA/bootstrap/
jboss-seam-2.0.0.GA/lib/test/*.jar
jboss-seam-2.0.0.GA/lib/*.jar (apart from jboss-seam-ui.jar)
compiled tests
classpath for compiling tests
What is wrong with my settings?
Regards,
Piotr
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4114492#4114492
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4114492
18 years, 4 months
[Persistence, JBoss/CMP, Hibernate, Database] - CMT doesn't rollback
by su27
My application is using Jboss 4.2.1, EJB3(stateless session bean), EntityManager, Hibernate and Postgresql. it doesn't rollback.
ds.xml
| <local-tx-datasource>
| <jndi-name>PGDS/JTA</jndi-name>
| <connection-url>jdbc:postgresql://localhost:5432/postgres</connection-url>
| <driver-class>org.postgresql.Driver</driver-class>
| <user-name>xxxxxx</user-name>
| <password>yyyyyy</password>
| <metadata>
| <type-mapping>PostgreSQL 8.0</type-mapping>
| </metadata>
| </local-tx-datasource>
|
persistence.xml
| <?xml version="1.0" encoding="UTF-8"?>
| <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
| <persistence-unit name="JTA-EJBPU" transaction-type="JTA">
| <jta-data-source>java:/PGDS/JTA</jta-data-source>
| <properties>
| <property name="hibernate.show_sql" value="true"/>
| </properties>
| </persistence-unit>
| </persistence>
|
session bean
| @Stateless
| @LocalBinding(jndiBinding="JTA/JTALocal")
| public class JTABean implements JTALocal {
| @PersistenceContext(unitName = "JTA-EJBPU",type=PersistenceContextType.TRANSACTION)
| private EntityManager em ;
| @TransactionAttribute(TransactionAttributeType.REQUIRED)
| public void run (int i)throws Exception{
|
| try{
| School sc1 = new School("first");
| em.persist(sc1);
| if(i == 1) throw new Exception();
| School sc2 = new School("second");
| em.persist(sc2);
| }catch(Exception e){
|
| System.out.println("roll back?");
| throw e;
| }
| }
|
| }
|
JBoss startup info
| [ConnectionProviderFactory] Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
| [InjectedDataSourceConnectionProvider] Using provided datasource
| [SettingsFactory] RDBMS: PostgreSQL, version: 8.2.5
| [SettingsFactory] JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.2 JDBC4 with SSL (build 507)
| [Dialect] Using dialect: org.hibernate.dialect.PostgreSQLDialect
| [TransactionFactoryFactory] Transaction strategy: org.hibernate.ejb.transaction.JoinableCMTTransactionFactory
| [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
| [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
| [SettingsFactory] Automatic flush during beforeCompletion(): disabled
| [SettingsFactory] Automatic session close at end of transaction: disabled
| [SettingsFactory] JDBC batch size: 15
| [SettingsFactory] JDBC batch updates for versioned data: disabled
| [SettingsFactory] Scrollable result sets: enabled
| [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
| [SettingsFactory] Connection release mode: auto
| [SettingsFactory] Default batch fetch size: 1
| [SettingsFactory] Generate SQL with comments: disabled
| [SettingsFactory] Order SQL updates by primary key: disabled
| [SettingsFactory] Order SQL inserts for batching: disabled
| [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
| [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
| [SettingsFactory] Query language substitutions: {}
| [SettingsFactory] JPA-QL strict compliance: enabled
| [SettingsFactory] Second-level cache: enabled
| [SettingsFactory] Query cache: disabled
| [SettingsFactory] Cache provider: org.hibernate.cache.HashtableCacheProvider
| [SettingsFactory] Optimize cache for minimal puts: disabled
| [SettingsFactory] Cache region prefix: JTA-EAR_ear,JTA-EJB_jar,JTA-EJBPU
| [SettingsFactory] Structured second-level cache entries: disabled
| [SettingsFactory] Echoing all SQL to stdout
| [SettingsFactory] Statistics: disabled
| [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
| [SettingsFactory] Default entity-mode: pojo
| [SettingsFactory] Named query checking : enabled
| [SessionFactoryImpl] building session factory
| [SessionFactoryObjectFactory] Factory name: persistence.units:ear=JTA-EAR.ear,jar=JTA-EJB.jar,unitName=JTA-EJBPU
| [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
| [SessionFactoryObjectFactory] Bound factory to JNDI name: persistence.units:ear=JTA-EAR.ear,jar=JTA-EJB.jar,unitName=JTA-EJBPU
| [SessionFactoryObjectFactory] InitialContext did not implement EventContext
| [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
| [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
| [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=JTA-EAR.ear,jar=JTA-EJB.jar,name=JTABean,service=EJB3 with dependencies:
| [JmxKernelAbstraction] persistence.units:ear=JTA-EAR.ear,jar=JTA-EJB.jar,unitName=JTA-EJBPU
| [EJBContainer] STARTED EJB: com.ganz.jta.ejb.JTABean ejbName: JTABean
| [EJB3Deployer] Deployed: file:/E:/jboss-4.2.1.GA/server/default/tmp/deploy/tmp18536JTA-EAR.ear-contents/JTA-EJB.jar
| [TomcatDeployer] deploy, ctxPath=/JTA-WAR, warUrl=.../tmp/deploy/tmp18536JTA-EAR.ear-contents/JTA-WAR-exp.war/
| [EARDeployer] Started J2EE application: file:/E:/jboss-4.2.1.GA/server/default/deploy/JTA-EAR.ear
|
I have tried different configurations. in persistence.xml i changed to RESOURCE_LOCAL, non-jta--data-source. i have tried XA data source.
the transaction just doesn't rollback. when i call run(1). it throws an exception between two persistence, but the first record has been saved into database already.
according to the Jboss starup info, it is a CMT.
Transaction strategy: org.hibernate.ejb.transaction.JoinableCMTTransactionFactory
i tried jboss 4.2.0 4.2.1 4.2.2, same
tried pure JDBC connection, same
use MDB instead of Session Bean, same.
anybody can help me, give me a clue. what am i missing?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4114490#4114490
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4114490
18 years, 4 months