Mantis - Resin
|
|||||
Viewing Issue Advanced Details | |||||
|
|||||
ID: | Category: | Severity: | Reproducibility: | Date Submitted: | Last Update: |
4488 | minor | always | 04-07-11 20:27 | 08-01-11 18:48 | |
|
|||||
Reporter: | reza | Platform: | |||
Assigned To: | ferg | OS: | |||
Priority: | normal | OS Version: | |||
Status: | closed | Product Version: | 4.0.17 | ||
Product Build: | Resolution: | fixed | |||
Projection: | none | ||||
ETA: | none | Fixed in Version: | 4.0.21 | ||
|
|||||
Summary: | 0004488: @DataSourceDefinition does not work with JPA (timing issue) | ||||
Description: |
The @DataSourceDefinition annotation does not work with JPA due to timing issues. It looks like JPA is getting bootstrapped before the data source is being bound to JNDI. It does not matter if the data source is defined on Servlet, EJB or CDI. Injecting the bound data source does work since there are no timing issues in that case. Here is an example data source definition: @DataSourceDefinition( name = "java:app/jdbc/AcmeBankDB3", className = "com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource", url = "jdbc:mysql://localhost:3306/acmebank", [^] serverName = "localhost", portNumber = 3306, databaseName = "acmebank", user = "root", password = "gemini6") @WebServlet(name = "DataPopulatorServlet", urlPatterns = { "/populate" }) public class DataPopulatorServlet extends HttpServlet { ... } The following persistence.xml will cause the application deployment to fail (JPA will not find the data source): <persistence> <persistence-unit name="acme-bank-db" transaction-type="JTA"> <jta-data-source>java:app/jdbc/AcmeBankDB3</jta-data-source> <validation-mode>AUTO</validation-mode> <properties> <property name="eclipselink.ddl-generation" value="create-tables" /> <property name="eclipselink.logging.level" value="INFO" /> </properties> </persistence-unit> </persistence> Injecting the plain data source will work: public class DefaultUserDao implements UserDao { @Resource(lookup = "java:app/jdbc/AcmeBankDB3") private DataSource dataSource; ... } |
||||
Steps To Reproduce: | |||||
Additional Information: | |||||
Relationships | |||||
Attached Files: |
Notes | |||||
|
|||||
|
|