I'm trying to implement the example found at: https://helpx.adobe.com/experience-manager/using/restful-services.html , however, I keep getting the "Unexpected token <", due to the server probably returning a 404 or some other HTML error code. I followed the article and implemented it step by step in a 5.6.1 environment. When I initially imported my OSGI bundle containing the org.apache.httpclient jars, it was running/active, but now, it is only listed as "Installed", and when I click on the "start/run" button, I get the error shown below. After I couldn't get that service running, I installed the example 6.1 package in an AEM 6.1 environment, and it was working initially, but after uninstalling, re-installing and restarting the server, I can't get the associated OSGI services started anymore. They are in a "Installed" state, but won't start. Please help.
1. I'm also a little confused as to what my OSGI bundle should list in the manifest under "Export-package" and "Import-package".
Errors from 5.6.1 error.log:
An error occurred at line: 20 in the jsp file: /apps/dev-sandbox/components/restService/query.json.jsp com.adobe.restservice.Distance cannot be resolved to a type 17: String filter = request.getParameter("filter"); 18: 19: // Instatiate an instance of the appropriate service using Sling 20: com.adobe.restservice.Distance googleTagService = sling.getService(com.adobe.restservice.Distance.class); 21: 22: // Invoke the service 23: String jsonResponse = googleTagService.getDistance() ; at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:388) at org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:171) at org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:463) at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:508) at org.apache.sling.engine.impl.filter.SlingComponentFilterChain.render(SlingComponentFilterChain.java:45) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64) at com.day.cq.wcm.core.impl.WCMDebugFilter.doFilterWithErrorHandling(WCMDebugFilter.java:182) at com.day.cq.wcm.core.impl.WCMDebugFilter.doFilter(WCMDebugFilter.java:149) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at com.day.cq.wcm.core.impl.WCMComponentFilter.filterRootInclude(WCMComponentFilter.java:356) at com.day.cq.wcm.core.impl.WCMComponentFilter.doFilter(WCMComponentFilter.java:168) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at com.day.cq.personalization.impl.TargetComponentFilter.doFilter(TargetComponentFilter.java:96) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60) at org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:254) at org.apache.sling.engine.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:49) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64) at com.day.cq.wcm.core.impl.AuthoringUIModeServiceImpl.doFilter(AuthoringUIModeServiceImpl.java:301)
-------------
Errors from the 6.1 error.log:
31.01.2016 03:10:10.802 *INFO* [OsgiInstallerImpl] org.apache.sling.installer.core.impl.tasks.BundleInstallTask Exception during install of bundle TaskResource(url=jcrinstall:/apps/restservice/osgi-bundles/install/restful-bundle-1.0-SNAPSHOT.jar, entity=bundle:com.adobe.restservice.restful-bundle, state=INSTALL, attributes=[org.apache.sling.installer.api.tasks.ResourceTransformer=:24:43:21:, Bundle-SymbolicName=com.adobe.restservice.restful-bundle, Bundle-Version=1.0.0.SNAPSHOT], digest=1454226994663) : Bundle installation rejected by hook.. Retrying later. org.osgi.framework.BundleException: Bundle installation rejected by hook. at org.apache.felix.framework.Felix.installBundle(Felix.java:3123) at org.apache.felix.framework.BundleContextImpl.installBundle(BundleContextImpl.java:167) at org.apache.sling.installer.core.impl.tasks.BundleInstallTask.execute(BundleInstallTask.java:47) at org.apache.sling.installer.core.impl.OsgiInstallerImpl.doExecuteTasks(OsgiInstallerImpl.java:847) at org.apache.sling.installer.core.impl.OsgiInstallerImpl.executeTasks(OsgiInstallerImpl.java:689) at org.apache.sling.installer.core.impl.OsgiInstallerImpl.run(OsgiInstallerImpl.java:265) at java.lang.Thread.run(Thread.java:745) 31.01.2016 03:10:55.334 *ERROR* [qtp552317373-248] org.apache.felix.http.jetty %bundles.pluginTitle: Cannot start (org.osgi.framework.BundleException: Unresolved constraint in bundle RestFulDep [448]: Unable to resolve 448.0: missing requirement [448.0] osgi.wiring.package; (osgi.wiring.package=javax.security.auth.x500)) org.osgi.framework.BundleException: Unresolved constraint in bundle RestFulDep [448]: Unable to resolve 448.0: missing requirement [448.0] osgi.wiring.package; (osgi.wiring.package=javax.security.auth.x500) at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4095) at org.apache.felix.framework.Felix.startBundle(Felix.java:2114) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:977) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:964) at org.apache.felix.webconsole.internal.core.BundlesServlet.doPost(BundlesServlet.java:365) at javax.servlet.http.HttpServlet.service(HttpServlet.java:644) at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) --------- And also ------- An error occurred at line: 5 in the jsp file: /apps/restservice/components/page/templateRest/query.json.jsp com.adobe.restservice.Distance cannot be resolved to a type 2: <%@ page import="org.apache.sling.commons.json.io.*,org.w3c.dom.*" %><% 3: String filter = request.getParameter("filter"); 4: 5: com.adobe.restservice.Distance cs = sling.getService(com.adobe.restservice.Distance.class); 6: 7: String myJSON= cs.getDistance() ; 8: at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:388) at org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:171) at org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:463) at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:533) at org.apache.sling.engine.impl.filter.SlingComponentFilterChain.render(SlingComponentFilterChain.java:44) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:77)
Solved! Go to Solution.
Views
Replies
Total Likes
"Please help me understand how to go about determining which classes to export and import when I create OSGI bundles"
Here is a good article that talks about OSGi and the role of the Export-Package and Import-Package sections:
Now in the Creating Adobe Experience Manager bundles that invoke third party Restful web services example - the main Java OSGi bundle contains a service that uses these APIs to invoke the 3rd party Restful API:
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet getRequest = new HttpGet("http://maps.googleapis.com/maps/api/distancematrix/json?origins=Vancouver%20BC&destinations=San%20Fr...");
getRequest.addHeader("accept", "application/json");
HttpResponse response = httpClient.execute(getRequest);
Because we are using these Java HTTP APIs - we need to ensure that the OSGi service imports the required Java packages.
The main OSGi service that contains these HTTP APIs has this Manifest file Import-Package section (lets call this BUNDLE A):
Import-Package:
org.apache.http,
org.apache.http.client.methods,
org.apache.http.conn,
org.apache.http.impl.client,
Now - we have to make sure that all of these packages are exported in ANOTHER OSGi bundle in AEM. Otherwise BundleA will not start.
This is why we create a 2nd OSGi bundle in the article that uses these 2 JAR Files:
Lets call this bundle B.
The job of BUNDLE B is to expose these Java packages. That is why we wrap these 2 JAR files by using an Eclipse plug-in project. This is the Manifest file of Bundle B- notice that this bundle exposes these Java packages in the Export Package section.
Export-Package: org.apache.http,org.apache.http.annotation,org.apache.
http.auth,org.apache.http.auth.params,org.apache.http.client,org.apac
he.http.client.entity,org.apache.http.client.methods,org.apache.http.
client.params,org.apache.http.client.protocol,org.apache.http.client.
utils,org.apache.http.concurrent,org.apache.http.config,org.apache.ht
tp.conn,org.apache.http.conn.params,org.apache.http.conn.routing,org.
apache.http.conn.scheme,org.apache.http.conn.ssl,org.apache.http.conn
.util,org.apache.http.cookie,org.apache.http.cookie.params,org.apache
.http.entity,org.apache.http.impl,org.apache.http.impl.auth,org.apach
e.http.impl.client,org.apache.http.impl.conn,org.apache.http.impl.con
n.tsccm,org.apache.http.impl.cookie,org.apache.http.impl.entity,org.a
pache.http.impl.io,org.apache.http.impl.pool,org.apache.http.io,org.a
pache.http.message,org.apache.http.params,org.apache.http.pool,org.ap
ache.http.protocol,org.apache.http.util
To summarize - Bundle A imports the Java HTTP packages and Bundle B exports Java HTTP packages. Therefore the MF file of Bundle A has the IMPORT-Package section and Bundle B has the Export-Package section (shown above).
When you follow the article - you DO NOT NEED TO ADD any Java packages to the IMPORT-Package or Export-Package section. This is done automatically. When using Maven to build Bundle A (that contain the HTTP API to invoke the 3rd party Restful service)- Maven adds the Java packages to the IMPORT-Package section of the MF file of the bundle.
When you use Eclipse plug-in project - Eclipse adds Java packages to the Export-Package section. All you need to do is remove the version information (if there is any in the MF file in eclipse).
For this article - install the package on a clean version of AEM. If you ahve a clean AEM 6.1 instance - install the package at the start of the article. The example app - that invokes Google Restful service- will run.
If you want to see another example of using an API in AEM that uses dependancies - see this new community article:
https://helpx.adobe.com/experience-manager/using/aem_wordpress.html
This uses the WordPress API. We also need to get WordPress OSGi dependences into AEM.
Views
Replies
Total Likes
OSGI Bundle Information (from Console):
I'm not sure the Export-package and Import-package headers in the Manifest are correct.
Test Commons Sandbox Bundlecom.test.aem.sandbox-bundle Symbolic Name com.test.aem.sandbox-bundle Version 1.0.0.SNAPSHOT Bundle Location inputstream:sandbox-bundle-1.0-SNAPSHOT.jar Last Modification Tue Jan 26 14:44:32 COT 2016 Description Maven Multimodule project for TestCommons Sandbox. Start Level 20 Exported Packages com.test.aem.sandbox,version=1.0.0 Imported Packages javax.servlet,version=2.5.0 from cqse-httpservice (25) org.apache.http,version=0.0.0 from httpBundle (334) org.apache.http.client.methods,version=0.0.0 fromhttpBundle (334) org.apache.http.conn,version=0.0.0 from httpBundle (334) org.apache.http.impl.client,version=0.0.0 fromhttpBundle (334) org.apache.sling.api,version=2.2.0 fromorg.apache.sling.api (123) org.apache.sling.api.request,version=2.3.0 fromorg.apache.sling.api (123) org.slf4j,version=1.6.4 from slf4j.api (14) Service ID 2060 Types: com.test.aem.sandbox.Distance Service PID: com.test.aem.sandbox.DistanceImpl Component Name: com.test.aem.sandbox.DistanceImpl Component ID: 1534 Service ID 2061 Types: javax.servlet.Filter Service PID: com.test.aem.sandbox.impl.filters.LoggingFilter Component Name: com.test.aem.sandbox.impl.filters.LoggingFilter Component ID: 1535 Manifest Headers Bnd-LastModified: 1453834463706 Build-Jdk: 1.7.0_79 Built-By: O50563 Bundle-Description: Maven Multimodule project for Test Commons Sandbox. Bundle-ManifestVersion: 2 Bundle-Name: Test Commons Sandbox Bundle Bundle-SymbolicName: com.test.aem.sandbox-bundle Bundle-Version: 1.0.0.SNAPSHOT Created-By: Apache Maven Bundle Plugin Export-Package: com.test.aem.sandbox; uses:="org.apache.http.impl.client, org.apache.http.conn, org.apache.http.client.methods, org.apache.http"; version="1.0.0" Import-Package: javax.servlet, org.apache.http, org.apache.http.client.methods, org.apache.http.conn, org.apache.http.impl.client, org.apache.sling.api; version="[2.2, 3)", org.apache.sling.api.request; version="[2.2, 3)", org.slf4j; version="[1.5, 2)" Manifest-Version: 1.0 Service-Component: OSGI-INF/serviceComponents.xml Tool: Bnd-1.50.0 Used Services Service #13 of type(s) [org.osgi.service.log.LogService]
Views
Replies
Total Likes
I just installed on AEM 6.1 - the example application works fine:
You stated:
it was working initially, but after uninstalling, re-installing and restarting the server
why did you un-install. I am just wondering.
The OSGi bundle for this example imported these packages:
Imported Packages | org.apache.http,version=4.3.2 from org.apache.httpcomponents.httpcore (123) org.apache.http.client.methods,version=4.3.4 from org.apache.httpcomponents.httpclient (122) org.apache.http.conn,version=4.3.4 from org.apache.httpcomponents.httpclient (122) org.apache.http.impl.client,version=4.3.4 from org.apache.httpcomponents.httpclient (122) org.osgi.framework,version=1.8.0 from org.apache.felix.framework (0) org.osgi.service.component,version=1.3.0 from org.apache.felix.scr (31) org.slf4j,version=1.7.6 from slf4j.api (22) |
Views
Replies
Total Likes
I tested on 5.6 too and it works fine.
If you see weird OSGi message like this - install these community samples apps on a fresh instance of CQ. Looks like your other version had some sort of OSGi dependency conflicts or something else was corrupt for some reason.
Here is information on the hook rejection message:
https://issues.apache.org/jira/browse/KARAF-1728
So my advice would be to install on a fresh install and test. Remember these community articles are to teach you how to perform tasks - this one is to show you how to use Java HTTP classes to invoke 3rd party Restful services and embed that into AEM.
Views
Replies
Total Likes
Also - in step 13 of the article under this section Including HTTP client packages to CQ - all you need to do is to remove the version information from the MF files under import section. Do not add or remove any packages in this section - only remove the version information (if there is any). This tells CQ to use the available version. You can remove the version information in the MF file using Eclipse.
When you import the 2 dependency JARs (httpclient-4.0.jar and httpcore-4.3.2.jar) and build a plug-in project - the MF file is (There is no version information. ):
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: RestfulWbServiceDep
Bundle-SymbolicName: RestfulWbServiceDep
Bundle-Version: 1.0.0
Export-Package: org.apache.http,
org.apache.http.annotation,
org.apache.http.auth,
org.apache.http.auth.params,
org.apache.http.client,
org.apache.http.client.entity,
org.apache.http.client.methods,
org.apache.http.client.params,
org.apache.http.client.protocol,
org.apache.http.client.utils,
org.apache.http.concurrent,
org.apache.http.config,
org.apache.http.conn,
org.apache.http.conn.params,
org.apache.http.conn.routing,
org.apache.http.conn.scheme,
org.apache.http.conn.ssl,
org.apache.http.conn.util,
org.apache.http.cookie,
org.apache.http.cookie.params,
org.apache.http.entity,
org.apache.http.impl,
org.apache.http.impl.auth,
org.apache.http.impl.client,
org.apache.http.impl.conn,
org.apache.http.impl.conn.tsccm,
org.apache.http.impl.cookie,
org.apache.http.impl.entity,
org.apache.http.impl.io,
org.apache.http.impl.pool,
org.apache.http.io,
org.apache.http.message,
org.apache.http.params,
org.apache.http.pool,
org.apache.http.protocol,
org.apache.http.util
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Views
Replies
Total Likes
smacdonald2008 wrote...
I tested on 5.6 too and it works fine.
If you see weird OSGi message like this - install these community samples apps on a fresh instance of CQ. Looks like your other version had some sort of OSGi dependency conflicts or something else was corrupt for some reason.
Here is information on the hook rejection message:
https://issues.apache.org/jira/browse/KARAF-1728
So my advice would be to install on a fresh install and test. Remember these community articles are to teach you how to perform tasks - this one is to show you how to use Java HTTP classes to invoke 3rd party Restful services and embed that into AEM.
smacdonald2008 wrote...
I just installed on AEM 6.1 - the example application works fine:
You stated:
it was working initially, but after uninstalling, re-installing and restarting the server
why did you un-install. I am just wondering.
The OSGi bundle for this example imported these packages:
Imported Packages
org.apache.http,version=4.3.2 from org.apache.httpcomponents.httpcore (123)
org.apache.http.client.methods,version=4.3.4 from org.apache.httpcomponents.httpclient (122)
org.apache.http.conn,version=4.3.4 from org.apache.httpcomponents.httpclient (122)
org.apache.http.impl.client,version=4.3.4 from org.apache.httpcomponents.httpclient (122)
org.osgi.framework,version=1.8.0 from org.apache.felix.framework (0)
org.osgi.service.component,version=1.3.0 from org.apache.felix.scr (31)
org.slf4j,version=1.7.6 from slf4j.api (22)
I had to reboot my computer, and when I restarted AEM 6.1, the installation would no longer work. So, I uninstalled, re-installed etc. trying to get it working again. I couldn't understand what had changed so that I started getting the HTTP error message after re-starting.
Also, please help me understand how to go about determining which classes to export and import when I create OSGI bundles, (in general). I've assumed that whenever you create a bundle, you put the classes you are providing/exposing in the service, (from the jars you're wrapping, or creating from custom development), into the "Export-package" section, and you put any other classes that the jars or your custom code is dependent on, in the "Import-package" section. Is this correct? The article said to be sure that the Export-package, and Import-package sections in the Manifest were populated, but didn't tell you what should be in there. You're saying that all I have to do is to remove the version information, but using Eclipse, I had to explicitly select the classes that I wanted to include in the Export-package, and I thought this was the way I was making the classes from the two jars I wrapped, available in the service. I wasn't sure if I needed to include the "Distance" and/or "DistanceImpl" classes in the export-package section of the jar created from the code implementing the Distance() method.
Views
Replies
Total Likes
"Please help me understand how to go about determining which classes to export and import when I create OSGI bundles"
Here is a good article that talks about OSGi and the role of the Export-Package and Import-Package sections:
Now in the Creating Adobe Experience Manager bundles that invoke third party Restful web services example - the main Java OSGi bundle contains a service that uses these APIs to invoke the 3rd party Restful API:
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet getRequest = new HttpGet("http://maps.googleapis.com/maps/api/distancematrix/json?origins=Vancouver%20BC&destinations=San%20Fr...");
getRequest.addHeader("accept", "application/json");
HttpResponse response = httpClient.execute(getRequest);
Because we are using these Java HTTP APIs - we need to ensure that the OSGi service imports the required Java packages.
The main OSGi service that contains these HTTP APIs has this Manifest file Import-Package section (lets call this BUNDLE A):
Import-Package:
org.apache.http,
org.apache.http.client.methods,
org.apache.http.conn,
org.apache.http.impl.client,
Now - we have to make sure that all of these packages are exported in ANOTHER OSGi bundle in AEM. Otherwise BundleA will not start.
This is why we create a 2nd OSGi bundle in the article that uses these 2 JAR Files:
Lets call this bundle B.
The job of BUNDLE B is to expose these Java packages. That is why we wrap these 2 JAR files by using an Eclipse plug-in project. This is the Manifest file of Bundle B- notice that this bundle exposes these Java packages in the Export Package section.
Export-Package: org.apache.http,org.apache.http.annotation,org.apache.
http.auth,org.apache.http.auth.params,org.apache.http.client,org.apac
he.http.client.entity,org.apache.http.client.methods,org.apache.http.
client.params,org.apache.http.client.protocol,org.apache.http.client.
utils,org.apache.http.concurrent,org.apache.http.config,org.apache.ht
tp.conn,org.apache.http.conn.params,org.apache.http.conn.routing,org.
apache.http.conn.scheme,org.apache.http.conn.ssl,org.apache.http.conn
.util,org.apache.http.cookie,org.apache.http.cookie.params,org.apache
.http.entity,org.apache.http.impl,org.apache.http.impl.auth,org.apach
e.http.impl.client,org.apache.http.impl.conn,org.apache.http.impl.con
n.tsccm,org.apache.http.impl.cookie,org.apache.http.impl.entity,org.a
pache.http.impl.io,org.apache.http.impl.pool,org.apache.http.io,org.a
pache.http.message,org.apache.http.params,org.apache.http.pool,org.ap
ache.http.protocol,org.apache.http.util
To summarize - Bundle A imports the Java HTTP packages and Bundle B exports Java HTTP packages. Therefore the MF file of Bundle A has the IMPORT-Package section and Bundle B has the Export-Package section (shown above).
When you follow the article - you DO NOT NEED TO ADD any Java packages to the IMPORT-Package or Export-Package section. This is done automatically. When using Maven to build Bundle A (that contain the HTTP API to invoke the 3rd party Restful service)- Maven adds the Java packages to the IMPORT-Package section of the MF file of the bundle.
When you use Eclipse plug-in project - Eclipse adds Java packages to the Export-Package section. All you need to do is remove the version information (if there is any in the MF file in eclipse).
For this article - install the package on a clean version of AEM. If you ahve a clean AEM 6.1 instance - install the package at the start of the article. The example app - that invokes Google Restful service- will run.
If you want to see another example of using an API in AEM that uses dependancies - see this new community article:
https://helpx.adobe.com/experience-manager/using/aem_wordpress.html
This uses the WordPress API. We also need to get WordPress OSGi dependences into AEM.
Views
Replies
Total Likes
If you do not understand - we can arrange for a connect session and we will show you all of this. Let me know.
Views
Replies
Total Likes
Hi
I also have checked this helpx article (https://helpx.adobe.com/experience-manager/using/restful-services.html) in my instance (AEM 6.1), it is working perfectly fine.
To answer you question "please help me understand how to go about determining which classes to export and import when I create OSGI bundles", Please find below the reference article to help you with understanding this:
//The dependencies between bundles are expressed statically in terms of packages and dynamically in terms of services. A package is familiar to Java programmers. For example, a Java program may depend on a class org.foo.X, from package org.foo, and a bundle containing that program would either need to contain org.foo.X or depend on the package org.foo. Package dependencies are specified in the bundle manifest, for example:
Import-Package: org.foo
A bundle which provides a package for use by other bundles must export the package in its manifest. For example:
Export-Package: org.foo
Coming back to the article, just follow the steps mentioned in the article,
Step 1:- Run the following Maven command:
mvn archetype:generate -DarchetypeRepository=https://repo.adobe.com/nexus/content/groups/public/ -DarchetypeGroupId=com.day.jcr.vault -DarchetypeArtifactId=multimodule-content-package-archetype -DarchetypeVersion=1.0.2 -DgroupId=com.adobe.restservice -DartifactId=restful -Dversion=1.0-SNAPSHOT -Dpackage=com.adobe.restservice -DappsFolderName=myproject -DartifactName="My Project" -DcqVersion="5.6.1" -DpackageGroup="My Company"
Step 2:- mvn eclipse:eclipse
Step 3:- Add Java files to the Maven project using Eclipse
Step 4:- Including HTTP client packages to CQ (This step is important, this is helping us to add external libs to our project. Here external jars are converted to OSGI and then installed in console which would be later used by our main component as a dependency).
How to create it
//
Exported Packages
//
Note:-
You stated:
it was working initially, but after uninstalling, re-installing and restarting the server
I tried reproducing this behavior it is working perfectly fine.
I hope this would help you.
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
smacdonald2008 wrote...
If you do not understand - we can arrange for a connect session and we will show you all of this. Let me know.
Thank you SO much for the information, and the offer to do a connect session. Fortunately, I don't need it in this instance, (so I'll take a raincheck for a future issue ). I now have the example working in both the 5.6.1, and the 6.1 environments. The issue with the 6.1 environment, (which I simply downloaded and installed the package), had to do with the OSGI bundles not being removed when I uninstalled the package, (and tried to do a clean install). When I uninstalled the package, and then explicitly removed the two associated bundles manually, then re-installed, they both started up, ("Active"), and it works just fine.
The problem with the 5.6.1 component, (which I built myself following the step by step instructions), were simply due to not having listed all of the dependencies for the bundle in the "Import-package" section. The instructions tell you to ensure that the Import-package section is populated, but don't tell you the classes that need to be there. You have to go look in the error log file, (...AEM/author/crx-quickstart/logs/error.log), search for errors from the OSGI bundle attempting to start, and see which classes it's failing to find, (e.g. NoClassDefFoundError: org/apache/commons/logging/LogFactory). Once I got all of the dependent classes listed in the import-package, it worked just fine. I'd tried to use the automated dependency features in Eclipse, (when I built the bundle that wrapped the org.apache.httpclient jars), to give me the dependencies required by the jars I wrapped in the bundle, but it didn't list the classes that I eventually had to add to get it working. Maybe the dependency features don't work, or I'm simply still mis-understanding it a bit. In the future, I'd like an automated means of finding the dependency chain for any jars that I decide to expose/provide through a bundle, so that I can list them in the "Import.package" section in the header. How would I know that I needed to import the org.apache.commons.logging package???
Views
Replies
Total Likes
I will add a note that says it is automatically done. If it's empty - this means that Eclipse did not do its job for some reason. I am very glad you got it working.
Views
Replies
Total Likes
smacdonald2008 wrote...
I will add a note that says it is automatically done. If it's empty - this means that Eclipse did not do its job for some reason. I am very glad you got it working.
The article tells you to "make sure that the Import-Package header is MANIFEST.MF is populated", but it doesn't tell you what to do if Eclipse doesn't populate it. How would a AEM user typically find out that he needed to import the org.apache.commons.logging package, (and other dependent packages) in the Import-Package section???
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies