Search

Mark Ashworth

Designing applications, writing, photography and reading

Tag

linkedin

Installing Apache Karaf features behind a firewall

Apache Karaf can either use :-

  • the proxy settings in the Maven settings.xml in the specific user’s .m2 directory running the Karaf instance
  • the proxy settings in the global settings.xml in the conf directory of the Maven installation
  • the mvn repository can be changed within Karaf to include a local Maven repository like Sonatype Nexus

To use the settings.xml file, specify the following in the file in the global conf directory or in the user’s .m2 directory.

<proxies>
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>username</username>
<password>password*</password>
<host>hostname or ip</host>
<port>port</port>
<nonProxyHosts>localhost|127.0.0.1|10.0.0.3|10.0.0.4</nonProxyHosts>
</proxy>
</proxies>

The approach that I prefer is to add the Sonatype Nexus public url to the list of repositories that Apache Karaf should use when resolving features. This allows all the developers in a team to utilize the same shared resource for resolving artifacts. Open the ${karaf install folder}\etc\org.ops4j.pax.url.mvn.cfg file and add the url to the org.ops4j.pax.url.mvn.repositories config item.

org.ops4j.pax.url.mvn.repositories= \
http://localhost:9091/nexus/content/groups/public, \
http://repo1.maven.org/maven2@id=central, \
http://repository.apache.org/content/groups/snapshots-group@id=apache@snapshots@noreleases, \
https://oss.sonatype.org/content/repositories/ops4j-snapshots@id=ops4j.sonatype.snapshots.deploy@snapshots@noreleases, \
file:${karaf.home}/${karaf.default.repository}@id=systemrepo, \
file:${karaf.data}/kar@id=karrepos@multi

Advertisements

YouTube Downloader commands

Download a video
youtube-dl

Continue a previously cancelled download
youtube-dl -c

Request the file formats of the video
youtube-dl -F

Download the video in specified format
youtube-dl -f

Batch download
youtube-dl -a filename.txt

Batch download and use title in filename
youtube-dl -at filename.txt

Extract audio
youtube-dl –extract-audio
youtube-dl –audio-format mp3
youtube-dl –audio-quality 256k

Extract audio and keep the video
youtube-dl –audio-format mp3 –audio-quality 176 -k

cURL commands

1. Download a Single File
$ curl http://www.centos.org

2. Save the cURL Output to a file
-o (lowercase o) the result will be saved in the filename provided in the command line
-O (uppercase O) the filename in the URL will be taken and it will be used as the filename to store the result

$ curl -o mygettext.html http://www.gnu.org/software/gettext/manual/gettext.html
$ curl -O http://www.gnu.org/software/gettext/manual/gettext.html

3. Fetch Multiple Files at a time
$ curl -O URL1 -O URL2

4. Follow HTTP Location Headers with -L option
$ curl -L http://www.google.com

5. Continue/Resume a Previous Download
curl -C - -O http://www.gnu.org/software/gettext/manual/gettext.html

6. Limit the Rate of Data Transfer
$ curl --limit-rate 1000B -O http://www.gnu.org/software/gettext/manual/gettext.html

7. Download a file only if it is modified before/after the given time
$ curl -z 21-Dec-11 http://www.example.com/yy.html
$ curl -z -21-Dec-11 http://www.example.com/yy.html

8. Pass HTTP Authentication in cURL
$ curl -u username:password URL

9. Download Files from FTP server
$ curl -u ftpuser:ftppass -O ftp://ftp_server/public_html/xss.php
$ curl -u ftpuser:ftppass -O ftp://ftp_server/public_html/

10. List/Download using Ranges
$ curl ftp://ftp.uk.debian.org/debian/pool/main/[a-z]/

11. Upload Files to FTP Server
$ curl -u ftpuser:ftppass -T myfile.txt ftp://ftp.testserver.com
$ curl -u ftpuser:ftppass -T "{file1,file2}" ftp://ftp.testserver.com
$ curl -u ftpuser:ftppass -T - ftp://ftp.testserver.com/myfile_1.txt

12. More Information using Verbose and Trace Option
curl -v http://google.co.in

13. Get Definition of a Word using DICT Protocol
$ curl dict://dict.org/d:ravenous:english

14. Use Proxy to Download a File
$ curl -x proxysever.test.com:3128 http://google.co.in

15. Send Mail using SMTP Protocol
$ curl --mail-from blah@test.com --mail-rcpt foo@test.com smtp://mailserver.com

Excellent blog about resolving project dependencies into a Shrinkwrap archive for Arquillian. Now I just hope Pax Exam takes note for OSGi testing.

Adding Apache Shiro feature to Apache Karaf

Start Apache Karaf
cd bin
./karaf or karaf.bat

Adding a feature repository
feature:repo-add mvn:org.apache.shiro/shiro-features/1.2.1/xml/features

List features
feature:list
shiro-core | 1.2.1 | | shiro-1.2.1
shiro-web | 1.2.1 | | shiro-1.2.1
shiro-aspectj | 1.2.1 | | shiro-1.2.1
shiro-cas | 1.2.1 | | shiro-1.2.1
shiro-ehcache | 1.2.1 | | shiro-1.2.1
shiro-quartz | 1.2.1 | | shiro-1.2.1
shiro-spring | 1.2.1 | | shiro-1.2.1

Install the feature
feature:install -v shiro-web

feature:list
shiro-core | 1.2.1 | x | shiro-1.2.1
shiro-web | 1.2.1 | x | shiro-1.2.1
shiro-aspectj | 1.2.1 | | shiro-1.2.1
shiro-cas | 1.2.1 | | shiro-1.2.1
shiro-ehcache | 1.2.1 | | shiro-1.2.1
shiro-quartz | 1.2.1 | | shiro-1.2.1
shiro-spring | 1.2.1 | | shiro-1.2.1

Adding Microsoft SQL Server JDBC driver to Nexus and local maven repository

The Microsoft SQL Server JDBC driver is not available in public repositories because of licensing issues but it is easy to install into a company wide repository like Sonatype Nexus or into the local repository on your machine. This procedure can be used for other libraries as well.

Step 1 : Download the driver from http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=11774

Step 2: Extract the file and locate the sqljdbc.jar and sqljdbc4.jar. The table below indicates the usage of the jars respectively.

JAR

Description

sqljdbc.jar sqljdbc.jar class library provides support for JDBC 3.0.sqljdbc.jar class library requires a Java Runtime Environment (JRE) of version 5.0. Using sqljdbc.jar on JRE 6.0 will throw an exception when connecting to a database.The JDBC Driver does not support JRE 1.4. You must upgrade JRE 1.4 to either JRE 5.0 or JRE 6.0 when using the JDBC Driver. In some cases, you might need to recompile your application because it might not be compatible with JDK 5.0 or later. For more information, see the documentation on Sun Microsystems Web site.
sqljdbc4.jar sqljdbc4.jar class library provides support for JDBC 4.0. It includes all of the features of the sqljdbc.jar as well as the new JDBC 4.0 methods.sqljdbc4.jar class library requires a Java Runtime Environment (JRE) of version 6.0. Using sqljdbc4.jar on JRE 1.4 or 5.0 will throw an exception.Use sqljdbc4.jar when your application must run on JRE 6.0, even if your application does not use JDBC 4.0 features.

Step 3: If you have Nexus then use the following pom.xml to add the sqljdbc.jar

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>sqljdbc</artifactId>
    <version>4.0.2206.100</version>
</project>

Step 4: Select the 3rd Party Releases repository in Nexus. In the image I am showing my local Nexus 2.0 repository

3rd party repository

Step 5: Click the Artifact Upload tab.

a. Select the GAV Definition: From POM

b. POM file name: Select the file containing the pom.xml from step 3

c. Select artifacts to upload: Select the sqljdbc.jar from enu folder in the extracted zip folder

Adding sqljdbc.jar to Nexus 3rd Party Releases

Step 6: Select Upload

Uploaded

Step 7: Installing the sqljdbc4.jar uses the following pom.xml and the steps outlined above

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>sqljdbc4</artifactId>
    <version>4.0.2206.100</version>
</project>

Step 8: If you do not have Sonatype Nexus, then to install the libraries into the local repository using the following command. You do not need the pom.xml files since these will be created by Maven.

mvn install:install-file -Dfile=sqljdbc4.jar -Dpackaging=jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0.2206.100

Step 9: Reference the library in you project

<dependency>
  <groupId>com.microsoft.sqlserver</groupId>
  <artifactId>sqljdbc4</artifactId>
  <version>4.0.2206.100</version>
</dependency>

NOTE: Tomorrow I will be deploying the driver into Apache Karaf.

OSGi enabled LMAX Disruptor

A friend of mine,John Steinberg, introduced me to the high performance currency framework LMAX Disruptor. In a recent project I wanted to use the Disruptor as an OSGi bundle that my application could make use of but the MANIFEST.MF supplied with the library just contained the default build information.

I have contributed a patch that adds the relevant bundle information, but if you would like LMAX Disruptor 2.9 built library with the OSGi information then have a look here. I did get confirmation from the LMAX Disruptor developers that the patch has been committed and will be available in the next release.

Below is a screen shot of Apache Karaf with the LMAX Disruptor deployed.

Apache Karaf showing deployed Disruptor bundle

Social Media JSR 357 is voted no go in current form

The JCP voted 8 no, 5 yes and 3 abstains for the Social Media API (JSR 357) with the main complaint being that the specification is too broad in it’s current form and would hamper the natural formation of the technology since it is still early days for this technology.

The JSR review ballot can be found here.

JSR 343: JMS 2.0 – the next version of the JMS Specification

This version should actually be called JMS 1.2 since the minor changes and clarifications in the specification (a total of 18 defects). However these defects will address many of the frustrations that developers have had when trying to implement business critical software against the specification and I hope the clarification of interchangeability between JMS providers, i.e. JMS_SPEC-42.

Some my personal highlights are:-

JMS_SPEC-63 : The idea of a default connection factory (akin to the java:/ConnectionFactory in JBoss 7.x)

JMS_SPEC-7 : Similar to the HTTP and SOAP bindings that Oracle has in their Weblogic Server offering

JMS_SPEC-42 / 54 : Defining a standard way to define the message destination without the convoluted message-destination-link, although the message-destination-link will still be used if the current naming of resources between JBoss, Glassfish and Weblogic continues with the one application server requiring java:/ or java:jboss and the others not.

JMS_SPEC-56 : Although there is no mention of the reason for requesting allowing batches of messages to be delivered listeners, it seems like it was requested to improve performance, but probably opens more issues than it would solve since it would require the application developer to custom build logic to handle the different nuances when a failure occurs. A better alternative would be for example like Weblogic Server messaging, which has a process where it batches off a set of messages that is then delivered to the listeners.

References

http://java.net/projects/jms-spec/pages/Home

http://java.net/projects/jms-spec/pages/JSR343EarlyDraft

Create a free website or blog at WordPress.com.

Up ↑