Installing the Apache Abdera libraries
The IBM® support for feeds, using Apache Abdera libraries, is
referred to as Feed. Feed primarily consists of the
following items:
- Feeds support libraries: JavaTM archive (JAR) files for Apache
Abdera and the required XML Stax parser support.
- Feed application: A sample application that demonstrates
the use of the feeds support libraries
This document is for the Feeds Support libraries, and how
they can be used to run the feed samples that you create.
Using the Feeds support libraries to build and run a sample
feeds application
- Important: The feeds support libraries do not contain a
sample application. To understand how to build and use a feed-based
application, refer to the Feed sample application that is
packaged along with the feature pack, or refer to the Abdera examples
present Abdera examples.
- A sample feed application requires the following JAR files.
Refer to the Overview
section to locate these files :
- Abdera JAR files: files have the pattern abdera.*.jar, and
retroweaver*.jar
- Axiom JAR files: axiom-api-1.2.5.jar, axiom-impl-1.2.5.jar
- Stax API support: xlxpScannerUtils.jar, xlxpScanner.jar,
stax-api.jar, xml-apis.jar. These files are for
WebSphere® Application Server Version 6.0.x, 6.1.x and 7.0.0.x.
- Support for the Abdera client calls:
commons-httpclient-3.1-rc1.jar, commons-codec-1.3.jar
- Jaxen API support : Since Abdera uses the jaxen XPath implementation by default.
- For build time, include the previously mentioned JAR files
in the build-time class path, while developing your sample
feeds application
- Deploy your sample WAR file in the application server, and as
part of the deployment process, enter the context root for the application.
For example, use "SampleFeedApp" as the context root. In the case of WebSphere Application
Server Community Edition, the WEB-INF/geronimo-web.xml plan contains the context root.
- In the case of WebSphere
Application Server Version 6.x, and 7.x the previously mentioned Abdera-related
JAR files must be added into the class path. As a recap, the JAR files
referred earlier are of the pattern: axiom-*.jar, xlxp*.jar,
stax-api.jar, commons-*.jar, jaxen-*.jar, xml-apis.jar. One mechanism is to create a shared
library, and associate it with the applications that need these JAR
files. The following steps illustrate creation of a shared library, and
associating it with the application:
- Create a folder for the shared library option. For example,
name this folder, feed-library.
- Copy the JAR files into that folder: axiom-api-1.2.5.jar,
commons-httpclient-3.1-rc1.jar, xlxpScannerUtils.jar,
axiom-impl-1.2.5.jar, stax-api.jar, commons-codec-1.3.jar,
xlxpScanner.jar, xml-apis.jar, jaxen-1.1.1.jar
- Open the WebSphere Application Server administrative console, and
select your feed sample application. Name this sample
application SampleFeedApp.war. Click Applications >
Enterprise Applications > SampleFeedApp_war.
- Click the "Shared library" link. Select
the checkbox for the SampleFeedApp_war file, and click Reference
shared libraries.
- Register the shared library, if it is not already present.
Click New, and on the Shared Library Mapping >
New page, enter fslib, for the shared library name, and the class
path to the shared libraries. Enter the following information as an example:
/feed-library/axiom-api-1.2.5.jar
/feed-library/axiom-impl-1.2.5.jar
/feed-library/stax-api.jar
/feed-library/xlxpScanner.jar
/feed-library/xlxpScannerUtils.jar
/feed-library/xml-apis.jar
/feed-library/commons-httpclient-3.1-rc1.jar
/feed-library/commons-codec-1.3.jar
/feed-library/jaxen-1.1.1.jar
- Click OK to save this information. The
page switches to the Shared library mapping page. Select the "fslib"
library and move it to the Selected list box. Click OK.
- You return to the Shared library references page.
Select the checkbox for the SampleFeedApp_war file, and click OK.
- Save these changes to the master configuration. This
message is displayed on your current page.
- Start your SampleFeedApp_war application.
Note: The xml-apis.jar is to be used as part of shared library, only by the users on WebSphere Application Server Version 6.0.x/ Java 1.4.2
ATOM Publishing Protocol (APP) and mapping to HTTP operations
- The APP samples require HTTP operations to work with the feed
entries. For example:
- HTTP POST is used to create an entry in a feed
- HTTP PUT is used to update a specific entry in a feed
- HTTP GET is used to retrieve a specific entry from a feed, or
the entire feed, or the service document related to the Abdera server
- HTTP DELETE is used to delete a specific entry from a feed
- You can use the following two options to complete these operations on the feed and view the results:
- Use XMLHttpRequest (XHR) object in the browser to perform the
PUT, POST, GET, DELETE operations. The normal form submit operation in
the browser supports only the GET and POST operations.
- The other, simpler, approach is to use a tool like cURL. The cURL tool provides a simple command-line
operation to invoke calls on the APP server. Use this option to use the APP samples.
Troubleshooting
Certain feeds are not being read by the Abdera libraries
- Use FeedValidator to
check the validity of a feed.
- Valid ATOM feeds are processed by Abdera.
- RSS processing is still being introduced into Abdera,
therefore some valid RSS feeds may still not be processed by Abdera
- In addition, also use cURL to check if the feeds are being
served correctly. cURL can be obtained from http://curl.haxx.se/download.html.
Try the following link to check if feeds are being served correctly:
curl -X GET http://news.google.com/?output=atom
- The last option is to use this sample Java program to
determine if a feed can be processed.
import java.io.InputStream;
import java.net.URL;
import org.apache.abdera.Abdera;
import org.apache.abdera.model.Document;
import org.apache.abdera.model.Feed;
import org.apache.abdera.parser.Parser;
public class TestFeed {
public static void main(String[] args) throws Exception {
Parser parser = Abdera.getNewParser();
InputStream input;
try {
input = new URL(args[0]).openStream();
Document doc = (Document) parser.parse(input);
Feed feed = (Feed) doc.getRoot();
System.out.println("Feed can be parsed");
System.out.println("Begin feed content -----");
feed.writeTo(System.out);
System.out.println("-------End feed content");
} catch (Exception e) {
e.printStackTrace();
}
}
}
Compile and run the previous Java program by providing a feed as the
program's argument. A command-line example follows: java TestFeed http://www.alphaworks.ibm.com/news/xml/aw.xml
Current Java 2 Security policy reported a potential violation
of Java 2 Security Permission.
- If you see this error in your system out log, notice that this
is a setting that needs to be applied or changed based on the
recommendations in the IBM® WebSphere Application Server information center.
Specifically, refer to:
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1//index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/rsec_rsecmgr2.html
- If this security setting is not necessary, use the following steps to disable this setting:
- Open the IBM WebSphere Application Server administrative console, and
expand Security. Select Secure administration > applications > infrastructure.
- On the Secure administration, applications, and
infrastructure configuration page, uncheck Use Java 2 security
to restrict application access to local resources. Click Apply.
- Save changes to the master configuration. Restart server1.