Ok, When I said that it was working, it was that it all started up ok!!! But when I actually test it, i.e. attempt to read something from the other database(astral_analytics) it fails stating that the table in question doesn't exist. When I look into the trace some more it shows that it is attempting to connect to the original DB(astral_test). So even though the dependency injection of the EntityManager succeed it looks as if it is using the EM for the original DB.
Here is an extract from the log;
Code:
[2010-11-26 15:00:39.921] AGGREGATION_THREAD System.out [EL Config]: 2010-11-26 15:00:39.921--ServerSession(16520985)--Connection(7698449)--Thread(Thread[AGGREGATION_THREAD,5,main])--Connected: jdbc:postgresql://localhost/astral_test
[2010-11-26 15:00:39.921] AGGREGATION_THREAD System.out User: test
[2010-11-26 15:00:39.921] AGGREGATION_THREAD System.out Database: PostgreSQL Version: 8.4.4
[2010-11-26 15:00:39.921] AGGREGATION_THREAD System.out Driver: PostgreSQL Native Driver Version: PostgreSQL 8.3 JDBC4 with SSL (build 604)
[2010-11-26 15:00:39.937] AGGREGATION_THREAD System.out [EL Info]: 2010-11-26 15:00:39.937--ServerSession(16520985)--Thread(Thread[AGGREGATION_THREAD,5,main])--file:/C:/virgo-web-server-2.1.0.M06-incubation/work/osgi/configuration/org.eclipse.osgi/bundles/36/data/store/org.eclipse.osgi/bundles/88/1/bundlefile/_AstralAnalyticsPU login successful
So it says that it is connected to jdbc: postgresql://localhost/astral_test which is incorrect it should be jdbc: postgresql://localhost/astral_analytics but it goes on to say, also visible in the log above that '....._AstralAnalyticsPU login successful' so it has used the correct Persistent Unit in some form!
I have my two data sources defined correctly
Code:
<!-- Data Sources -->
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close"
scope="singleton">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<bean id="dataSourceAnalytics"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close"
scope="singleton">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url.analytics}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
I also have my DAO annotated correctly;
Code:
@PersistenceContext(unitName="AstralAnalyticsPU")
public void setEntityManager(EntityManager entityManager) {
this._em = entityManager;
}
I'm not sure what I'm missing to make this work, has this something to do with the Transaction Manager, any guidance appreciated!
Chris.