[jboss-jira] [JBoss JIRA] (WFLY-2680) java:comp/DefaultDataSource doesn't work in persistence.xml
arjan tijms (JIRA)
issues at jboss.org
Mon Dec 23 13:57:32 EST 2013
[ https://issues.jboss.org/browse/WFLY-2680?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12933148#comment-12933148 ]
arjan tijms commented on WFLY-2680:
-----------------------------------
{quote}The reason why this does not work is because java:comp is scoped to a component{quote}
You're right, and this is perhaps a somewhat unfortunate choice. Perhaps {{java:app}} of even {{java:global}} would have been the better choice. I've always thought of {{java:comp}} to be a somewhat peculiar space anyway, as the entire web module counts as one component, but every single EJB bean is a component as well. With the EJB model being slowly retrofitted towards a set of CDI extensions and interceptors it's not clear to me what the long term usage of this name space will be anyway.
I guess {{java:comp}} was chosen so it can be more easily re-mapped to another data source on a per component basis, but not sure if that's worth the hassle.
Note that all the other default resources, like the JMS connection factory and executor service and such are also in {{java:comp}}.
{quote}We can probably just hack something in to make this work though, as it would be more user friendly.{quote}
That would be really great! I'll try to address this issue with the EG and ask for some clarification.
> java:comp/DefaultDataSource doesn't work in persistence.xml
> -----------------------------------------------------------
>
> Key: WFLY-2680
> URL: https://issues.jboss.org/browse/WFLY-2680
> Project: WildFly
> Issue Type: Feature Request
> Security Level: Public(Everyone can see)
> Components: EE, JPA / Hibernate
> Affects Versions: 8.0.0.CR1
> Reporter: arjan tijms
> Assignee: David Lloyd
> Labels: javaee7, jdbc
>
> Having a persistence.xml with the following content fails the deployment on WildFly 8 CR1:
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
>
> <persistence-unit name="testPU">
> <jta-data-source>java:comp/DefaultDataSource</jta-data-source>
> </persistence-unit>
> </persistence>
> {code}
> It results in the following error:
> {noformat}
> 13:51:40,367 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 2) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "dynamic-named-query.war")]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"dynamic-named-query.war#testPU\".__FIRST_PHASE__ is missing [jboss.naming.context.java.module.dynamic-named-query.dynamic-named-query.DefaultDataSource]"]}
> {noformat}
> When I proposed the feature for the default data source over at the Java EE JIRA (https://java.net/jira/browse/JAVAEE_SPEC-4) I intended this to work. In the description I hinted that the standard JNDI name would be the standard alternative for {{java:jboss/datasources/ExampleDS}} on JBoss. The latter indeed does work in {{persistence.xml}} using WildFly 8 CR1.
> Omitting the {{jta-data-source}} element altogether *does* work, which is great. However, I foresee a lot of users tripping over this in the future and just giving up the idea of using a default data source, especially since the error message is very cryptic for new developers.
> In GlassFish 4 using {{java:comp/DefaultDataSource}} in {{persistence.xml}} does work.
> See also WFLY-2027 and WFLY-2158
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list