Re: PrettyFaces, CDI and the case of the missing ?cid=xxx…

Splash Forums PrettyFaces Users PrettyFaces, CDI and the case of the missing ?cid=xxx… Re: PrettyFaces, CDI and the case of the missing ?cid=xxx…

#22069

Tony Herstell
Participant

Once you synch then the only thing you need to set up is the PU and the Database schema I guess.

This is the simplest way of setting up the system with MySQL I have found and details the setup with MySQL and JBoss7:

This is in the file persistence.xml under META-INF in the project…

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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_2_0.xsd">

<!-- JBoss7 JBoss7 JBoss7 JBoss7 JBoss7 JBoss7 JBoss7 JBoss7 JBoss7 JBoss7 JBoss7 JBoss7 JBoss7 JBoss7
Download MySQLConnector (was mysql-connector-java-5.1.18.zip in my case)
Add a new directory: modules/com/mysql/main
put the MySQLConnector in the new directory: modules/com/mysql/main
Create a new file in directory: modules/com/mysql/main called module.xml and add in this code:

<?xml version="1.0" encoding="UTF-8"?>

<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.18-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>

Edit the file in the existing directory : /standalone/configuration called standalone.xml and add in this code inside the <drivers> tags:

<driver name="mysql" module="com.mysql"/>

now add in this code inside the <datasource> tags:

<datasource jndi-name="java:/datasources/entermyeventsDatasource" pool-name="my_pool" enabled="true" jta="true" use-java-context="true" use-ccm="true">
<connection-url>
jdbc:mysql://localhost:3306/entermyevents
</connection-url>
<driver>
mysql
</driver>
<security>
<user-name>
entermyevents
</user-name>
<password>
xxxxxxxxxxx
</password>
</security>
<statement>
<prepared-statement-cache-size>
100
</prepared-statement-cache-size>
<share-prepared-statements/>
</statement>
</datasource>

Run up server and look for something like:
04:45:09,525 INFO [org.jboss.jpa] (MSC service thread 1-3) JBAS011402: Starting Persistence Unit Service 'entermyevents.war#entermyeventsDatasource'

-->

<persistence-unit name="entermyeventsDatasource">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/datasources/entermyeventsDatasource</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<property name="hibernate.hbm2ddl.auto" value="update" /> <!-- create-drop update -->
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<!-- These are the default for JBoss EJB3, but not for HEM: -->
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider" />
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.JBossTransactionManagerLookup" />
<property name="jboss.entity.manager.factory.jndi.name"
value="java:/essistantEntityManagerFactories" />
</properties>
</persistence-unit>

</persistence>

I guess you probably don’t need this but just want to ensure I provide as much info as possible…

Tony