Hello KasunG,

I forgot to mention that I am using wso2ei-6.0.0.

During the build of my connector, I noticed that a .jar is created with the
.zip for the connector so I tried to deploy it. Actually, I tried the
following directories and my sequence does not find any of the components
like if my connector was not deployed :
- <WSO2_ESB_HOME>/repository/components/dropins (this directory did not
exist so I created it)
- <WSO2_ESB_HOME>/dropins

In addition, I don't find anything in the documentation mentioning that we
can deploy connectors as an OSGi bundle :(

When I deploy the .zip of the connector via the interface, it is deployed
in <WSO2_ESB_HOME>/repository/deployment/server/synapse-libs which is the
same directory used by Synapse:
http://synapse.apache.org/userguide/template_library.html

Concerning the "architecture" of my component, I deployed a .zip with a
META-INF directory containing the persistence.xml but I don't think it is
used like the absence of mention in the Synaspe documentation above. :)
Then, I call OpenJPA with the following lines:

EntityManagerFactory emf = Persistence.createEntityManagerFactory("my-pu");
EntityManager mgr = emf.createEntityManager();

But then, I have the exception.

I made a topic on StackOverflow one or two weeks ago:
https://stackoverflow.com/questions/43538743/wso2-is-there-a-way-to-use-jpa-in-a-custom-connector

I you know a documentation to generate an OSGi bundle for a connector, I am
very interested. :)

Regards,

Thomas

2017-05-03 18:29 GMT+02:00 KasunG Gajasinghe <[email protected]>:

> You are working in an OSGi environment, so you need to be thinking from
> the osgi classloading perspective. Each osgi bundle under
> repository/components/{plugins,dropins} has its own classloader and a
> classpath.
>
> Hence, the place you put your persistence.xml is important. I'm not sure
> how you call OpenJPA, so I cannot comment on what steps to follow. But in
> essence, re-build your connector as an osgi bundle (its just a jar with a
> set of manifest entries in MANIFEST.MF), and place it in
> repository/components/dropins. I have not tested this myself though.
>
> Regards,
> KasunG
>
>
> On Wed, May 3, 2017 at 8:38 PM, Thomas LEGRAND <
> [email protected]> wrote:
>
>> Hello everybody,
>>
>> I am currently writing a custom connector to retrieve information from a
>> database. Because the mediators to do so does not fit my needs, I am using
>> a custom Java class which is currently implemented to retrieve a DataSource
>> via the JNDI name I configured in the ESB interface. That works nicely :)
>>
>> But then, for maintenance purpose, I would like to use JPA (preferably,
>> the OpenJPA implementation :)) but it is like the persistence.xml is not
>> even read. :(
>> My libraries are placed in the lib/ directory in the generated zip of my
>> connector and I don't have any problem using the classes of OpenJPA.
>> Actually, just this error message appears:
>>
>> 1 INFO [PassThroughMessageProcessor-313] openjpa.Runtime - Starting
>> OpenJPA 2.4.0 org.apache.openjpa.persistence.ArgumentException: The
>> persistence provi der 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:
>> "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@442ce698".
>>
>> In the persistence.xml, you have the following content :
>>
>> <?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";>
>>     <persistence-unit name="my-pu" transaction-type="RESOURCE_LOCAL">
>>         <provider>org.apache.openjpa.persistence.PersistenceProvider
>> Impl</provider>
>>         <jta-data-source>jdbc/MyDataSource</jta-data-source>
>>     </persistence-unit>
>> </persistence>
>>
>> Is there some hidden magic to make it work?
>>
>> Thank you :)
>>
>> Regards,
>>
>> Thomas
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
>
> *Kasun Gajasinghe*Associate Technical Lead, WSO2 Inc.
> email: kasung AT spamfree wso2.com
> linked-in: http://lk.linkedin.com/in/gajasinghe
> blog: http://kasunbg.org
> phone: +1 650-745-4499 <(650)%20745-4499>, 77 678 0813
>
>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to