Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
1 reply Latest Post - ‏2013-10-28T13:45:52Z by C7YC_David_Westerman
C7YC_David_Westerman
12 Posts
ACCEPTED ANSWER

Pinned topic Can't Find DataSource from OSGi App

‏2013-10-25T22:32:18Z |

I'm writing an OSGi App, and I'm having trouble with it, because it can't find the DataSource that I have defined on my server.

When I try to access the JPA entity, I get the following error:
[ERROR   ] The DataSource jdbc/DvdListDataSource required by bundle DvdList.JPA/1.0.0.0 could not be found.
Intermediate context does not exist: jdbc/DvdListDataSource
 

I have a separate JPA OSGi bundle, with the following in the persistence.xml:
    <persistence-unit name="DvdList.JPA" transaction-type="JTA">
        <jta-data-source>jdbc/DvdListDataSource</jta-data-source>
        <class>westerlywinds.dvdlist.jpa.Dvd</class>
    </persistence-unit>
 

And here is the server.xml for my Liberty Profile 8.5.5 server:
<server description="DlwAppServer">
    <featureManager>
        <feature>jsp-2.2</feature>
        <feature>localConnector-1.0</feature>
        <feature>blueprint-1.0</feature>
        <feature>jpa-2.0</feature>
    </featureManager>
    <jdbcDriver id="DerbyJdbcDriver" libraryRef="derbyLibrary">
        <library description="Derby Classes" id="derbyLibrary" name="derbyLibrary">
            <fileset dir="resources/derby"/>
        </library>
    </jdbcDriver>
    <dataSource id="DvdListDataSource" jdbcDriverRef="DerbyJdbcDriver" jndiName="jdbc/DvdListDataSource" type="javax.sql.XADataSource">
        <properties.derby.embedded createDatabase="create" databaseName="${server.config.dir}/derbyDatabases/DVDLIST"/>
    </dataSource>
    <osgiApplication id="DvdList.App" location="DvdList.App.eba" name="DvdList.App"/>
</server>

I have also tried every value for the 'type' attribute in the 'dataSource' element, including not specifying it at all, but nothing works.

Any ideas? I think I must be missing a "wiring" or "binding" setting somewhere.

  • C7YC_David_Westerman
    12 Posts
    ACCEPTED ANSWER

    Re: Can't Find DataSource from OSGi App

    ‏2013-10-28T13:45:52Z  in response to C7YC_David_Westerman

    I am seeing the following in the messages.log file:

     

    Caused by: <openjpa-2.2.2-SNAPSHOT-r422266:1462076 fatal user error> org.apache.openjpa.persistence.ArgumentException: The persistence provider is attempting to use properties in the persistence.xml file to resolve the data source. A Java Database Connectivity (JDBC) driver or data source class name must be specified in the openjpa.ConnectionDriverName or javax.persistence.jdbc.driver property. The following properties are available in the configuration: "WsJpaJDBCConfigurationImpl@c76c7698: PDQ disabled: AccessIntent Task=disable".