The osgi bundle needs to be placed directly in the dropins/ folder. Sorry I missed to tell you that.
I still think this is a classloading issue. One thing you can try is including the openjpa classes and resources within your osgi bundle itself. Or, make your bundle a fragment of openjpa. See [1] [1] https://www.eclipse.org/gemini/blueprint/documentation/reference/2.0.0.RELEASE/html/appendix-tips.html On Tue, May 9, 2017 at 1:45 PM, Thomas LEGRAND <[email protected] > wrote: > Hello KasunG, > > OK. I generated the osgi bundle for OpenJPA with the following POM 'plugin > configuration': > > <build> > <plugins> > <plugin> > <groupId>org.apache.felix</groupId> > <artifactId>maven-bundle-plugin</artifactId> > <version>2.3.7</version> > <extensions>true</extensions> > <configuration> > <instructions> > <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> > <Bundle-Name>${project.artifactId}</Bundle-Name> > <Export-Package>javax.*, org.apache.openjpa.*</Export-Package> > <Private-Package>serp.*</Private-Package> > <Include-Resource>@openjpa-all-${version.openjpa}.jar!/META-INF/*, > @openjpa-all-${version.openjpa}.jar!/templates/*, > @openjpa-all-${version.openjpa}.jar!/testpool.jocl > </Include-Resource> > <Import-Package>com.ibm.*;resolution:=optional</Import-Package> > <DynamicImport-Package>*</DynamicImport-Package> > </instructions> > </configuration> > </plugin> > </plugins> > </build> > > But now, I am back to the initial error which occured when I just included > OpenJPA in the lib/ directory of the connector: > > <openjpa-2.4.2-r422266:1777108 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: > "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@2655aabb". > > So, I think this is because the persistence.xml in not detected in the > META-INF of my OSGI JPA project. Here is the buil and dependencies > configuration in the POM: > > <build> > <plugins> > <plugin> > <groupId>org.apache.felix</groupId> > <artifactId>maven-bundle-plugin</artifactId> > <version>2.3.7</version> > <extensions>true</extensions> > <configuration> > <instructions> > <Meta-Persistence>/META-INF/persistence.xml</Meta-Persistence> > <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> > <Bundle-Name>${project.artifactId}</Bundle-Name> > <Import-Package>org.apache.openjpa.*, javax.persistence</Import-Package> > <!-- <Include-Resource>META-INF/persistence.xml</Include-Resource> --> > <DynamicImport-Package>*</DynamicImport-Package> > </instructions> > </configuration> > </plugin> > </plugins> > </build> > <dependencies> > <dependency> > <groupId>my.group</groupId> > <artifactId>openjpa</artifactId> > <version>2.4.2</version> > <type>bundle</type> > </dependency> > </dependencies> > > Do you think I missed something to declare the persistence.xml in my JPA > project? > > > > 2017-05-05 14:36 GMT+02:00 KasunG Gajasinghe <[email protected]>: > >> >> That is probably because when creating an osgi bundle, EI simply wraps >> around the existing jar. So, any META-INF/services you had will be hidden >> under that wrapped jar. >> >> You can create your own osgi bundle via maven using a simple pom.xml like >> this. In there, you need to mention three things. >> >> 1. Your maven dependency for openjpa-all >> 2. Export packages - the openjpa-all has several such as - >> org.apache.openjpa.*, serp.* >> 3. Specify the resource files to copy >> >> This ought to do it. >> >> [1] https://github.com/wso2/orbit/blob/master/hazelcast/3.5. >> 4.wso2v2/pom.xml >> >> On Fri, May 5, 2017 at 2:07 PM, Thomas LEGRAND < >> [email protected]> wrote: >> >>> Hello, >>> >>> That seems to be OK :) >>> >>> osgi> p org.apache.openjpa.persistence >>> org.apache.openjpa.persistence; version="0.0.0"<openjpa_all_2.4.2_1.0.0 >>> [132]> >>> org.apache.openjpa.persistence; version="2.3.0"<tomee_1.7.2.wso2v2 >>> [632]> >>> compass_2.0.1.wso2v2 [54] imports >>> tomcat_7.0.75.wso2v1 [627] imports >>> osgi> ss openjpa >>> "Framework is launched." >>> >>> >>> id State Bundle >>> 132 ACTIVE openjpa_all_2.4.2_1.0.0 >>> osgi> >>> >>> So, I deployed my little JPA project and I can see that my package is >>> "registered": >>> >>> osgi> p my.little.project.jpa >>> my.little.project.jpa; version="1.0.0"<mylittleproject-jpa_1.0.0 [60]> >>> synapse-core_2.1.7.wso2v13 [619] imports >>> osgi> >>> >>> So I tried to invoke my class to retrieve an EntityManager and now, I >>> have: >>> >>> javax.persistence.PersistenceException: Failed to load provider from >>> META-INF/services >>> >>> I think that it is because the services/ directory in the META-INF in >>> the openjpa bundle is not parsed and I don't know what to do because this >>> is not me who generate the OSGi bundle but the ESB at startup. >>> >>> Do you have an idea? >>> >>> Regards, >>> >>> Thomas >>> >>> >>> 2017-05-04 20:37 GMT+02:00 KasunG Gajasinghe <[email protected]>: >>> >>>> >>>> I do not think openjpa register any osgi services. Can you check >>>> whether the package is exposed? Also verify the status of the openjpa >>>> bundle. >>>> >>>> osgi> p org.apache.openjpa.persistence >>>> osgi> ss openjpa >>>> >>>> On Thu, May 4, 2017 at 7:01 PM, Thomas LEGRAND < >>>> [email protected]> wrote: >>>> >>>>> Hello again :) >>>>> >>>>> I retrieved the openjpa-all-2.4.2.jar file and dropped it in the >>>>> <WSO2_ESB_HOME>/lib >>>>> directory to let the runtime taking care of the bundle generation during >>>>> the startup. The effect was the generation of the file >>>>> openjpa_all_2.4.2_1.0.0.jar in the directory <WSO2_ESB_HOME>/dropins. >>>>> >>>>> I restarted the EI with: >>>>> >>>>> D:\ProjetESB\wso2ei-6.0.0\bin> .\integrator.bat -DosgiConsole=19444 >>>>> >>>>> So I can connect to the OSGI console via telnet. But, when I try to >>>>> retrieve the objectclasses starting with org.apache.openjpa.*, I have >>>>> nothing :( >>>>> >>>>> osgi> services (objectclass=org.apache.openjpa.*) >>>>> "No registered services." >>>>> >>>>> Am I missing something? >>>>> >>>>> Regards, >>>>> >>>>> Thomas >>>>> >>>>> 2017-05-04 10:49 GMT+02:00 KasunG Gajasinghe <[email protected]>: >>>>> >>>>>> Hi Thomas, >>>>>> >>>>>> Well, the connector itself cannot be deployed as an osgi bundle. But, >>>>>> you can call classes in osgi bundles from your connector. So, place your >>>>>> JPA logic in an osgi bundle and add it to dropins/ folder. Then, call >>>>>> that >>>>>> from your connector. >>>>>> >>>>>> This should give you flexibility over your classloading. I cannot >>>>>> comment on JPA stuff though. >>>>>> >>>>>> On Thu, May 4, 2017 at 1:26 PM, Thomas LEGRAND < >>>>>> [email protected]> wrote: >>>>>> >>>>>>> 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.createEntityManage >>>>>>> rFactory("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_LOC >>>>>>>>> AL"> >>>>>>>>> <provider>org.apache.openjpa.p >>>>>>>>> ersistence.PersistenceProviderImpl</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 >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> >>>>>> *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 >>>>>> >>>>>> >>>>> >>>>> >>>> >>>> >>>> -- >>>> >>>> *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 >>>> >>>> >>> >>> >> >> >> -- >> >> *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 >> >> > > -- *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, 77 678 0813
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
