Accessing method from custom OSGi Service
I'm trying to access a method from a custom OSGi service I've built from a servlet.
How do I go about this with dependencies and initiating the variable from my servlet?
I'm trying to access a method from a custom OSGi service I've built from a servlet.
How do I go about this with dependencies and initiating the variable from my servlet?
Yeah - the trick here you need to put the JAR that contains the Service (the Java Classes) - into your local Maven respository. THIs one took me too the first time i did this. Since the JAR is not in Adobe Maven Repo - how does Maven do it.
The answer is here:
Upload the Jasper Urber OSGi bundle to your local Maven repository
You need to upload the OSGi bundle to your local Maven repository. The reason is because the AEM custom service that is built uses the Jasper Reports API exposed in this OSGi bundle.
As a result, when the AEM Service is build with a Maven 10 Archetype, Maven must be able to resolve all import statements (and Java logic) that use the Jasper Reports API such as these.
In order to resolve the Jasper Reports API within an AEM service, the Urber JasperReports JAR file must be located in the Maven repository. You can upload the Urber JAR to Maven by using this Maven command:
mvn install:install-file -Dfile=C:/JasperReports/plugins/JasperAEMUrber_1.0.0.jar -DgroupId=com.foo.reports -DartifactId=jrurbersrt1.0 -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true
Notice that you must specify the location of the Urber JAR file in the -Dfile argument. Also notice that you specify the Dgroup and DartifactID values. Once you upload the JAR to Maven using this command, you can reference this JAR file using this Dependency.
<groupId>com.foo.reports</groupId>
<artifactId>jrurbersrt1.0</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>C:\Users\scottm\.m2\repository\com\foo\reports\jrurbersrt1.0\1.0\jrurbersrt1.0-1.0.jar</systemPath>
</dependency>
Notice that scope element is system and systemPath references the location of the JAR file in the repository. (This dependency is used later in this article to build the AEM service)
Reference it is the POM
In the following POM file, notice the dependency that references the custom Urber file.
<groupId>com.foo.reports</groupId><artifactId>jrurbersrt1.0</artifactId><version>1.0</version><scope>system</scope><systemPath>C:\Users\scottm\.m2\repository\com\foo\reports\jrurbersrt1.0\1.0\jrurbersrt1.0-1.0.jar</systemPath></dependency>
Make sure you change the system path to point to the location in your Maven repository where the Jasper Urber JAR file is located.
<dependency>
<groupId>com.foo.reports</groupId>
<artifactId>jrurbersrt1.0</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>C:\Users\scottm\.m2\repository\com\foo\reports\jrurbersrt1.0\1.0\jrurbersrt1.0-1.0.jar</systemPath>
</dependency>
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.