java - How to import a class from third party jar file in an OSGi component -


i using https://eclipse.adobe.com/aem/dev-tools/ create project. once created, have following structure in eclipse:

enter image description here

i want able use googlemaps api in component. add dependency in hometest.core/pom.xml

<dependency>     <groupid>com.google.maps</groupid>     <artifactid>google-maps-services</artifactid>     <version>0.1.7</version>     <scope>compile</scope> </dependency> 

i've added _exportcontents in hometest.core/pom.xml

        <plugin>             <groupid>org.apache.felix</groupid>             <artifactid>maven-bundle-plugin</artifactid>             <extensions>true</extensions>             <configuration>                 <instructions>                     <embed-dependency>*;scope=compile|runtime</embed-dependency>                     <embed-directory>osgi-inf/lib</embed-directory>                     <_exportcontents>                                     *                     </_exportcontents>                 </instructions>             </configuration>         </plugin> 

i import com.google.maps.model.geocodingresult helloserviceproxy.java shown below:

enter image description here

i install package local instance of aem using mvn clean install -pautoinstallpackage

however, when try add component page following error:

java.lang.error: unresolved compilation problem: type can imported. com.google.maps.model.geocodingresult resolves package

below screenshot of error:

enter image description here

update 1

i started brand new aem project , did following things:

  • in core/pom.xml added configuration settings maven-bundle-plugin this

        <plugin>         <groupid>org.apache.felix</groupid>         <artifactid>maven-bundle-plugin</artifactid>         <extensions>true</extensions>         <configuration>             <instructions>         <embed-dependency>*;scope=compile|runtime</embed-dependency>         <embed-directory>osgi-inf/lib</embed-directory>         <_exportcontents>          *         </_exportcontents>         </instructions>         </configuration>     </plugin> 
  • added google maps dependency this:

    <dependency> <groupid>com.google.maps</groupid> <artifactid>google-maps-services</artifactid> <version>0.1.7</version> <scope>compile</scope> </dependency> 
  • deployed mvn clean install -pautoinstallpackage

when try add component page errors:

java.lang.error: unresolved compilation problems:      type can imported. com.google.maps.model.geocodingresult resolves package     type can imported. org.demo.anothertest.core.helloservice resolves package     helloservice cannot resolved type     helloservice cannot resolved type 

the error indicates classes google-maps-services bundle not available hometest.core bundle. might embedding bundles not work @ point.

can try deploying separate bundle embeds google-maps-services , see if works?


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -