Archive for the ‘Java’ Category

How to start a simple embedded java based FTP server

February 11, 2015 2 comments

I recently needed to run a simple FTP server for a test, and found a nice solution: Apache FTP Server. This is a side-project of Apache MINA.

Look at the bottom of the download page to find the maven dependency coordinates (GAV).

Once you have ftpserver-core on the classpath you can start a simple FTP server on a non-root port, with user authentication using this code:

import org.apache.ftpserver.FtpServer;
import org.apache.ftpserver.FtpServerFactory;
import org.apache.ftpserver.ftplet.FtpException;
import org.apache.ftpserver.ftplet.UserManager;
import org.apache.ftpserver.listener.ListenerFactory;
import org.apache.ftpserver.usermanager.PropertiesUserManagerFactory;
import org.apache.ftpserver.usermanager.impl.BaseUser;

public class FTPTestServer {
	public static void main(String[] args) throws FtpException {
		PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
		UserManager userManager = userManagerFactory.createUserManager();
		BaseUser user = new BaseUser();
		ListenerFactory listenerFactory = new ListenerFactory();
		FtpServerFactory factory = new FtpServerFactory();
		factory.addListener("default", listenerFactory.createListener());
		FtpServer server = factory.createServer();

Categories: Apache Mina Tags: , ,

How to install Glassfish 3.1 Clustering on multiple hosts using linux command line

September 25, 2012 Leave a comment

Today a colleague needed help with setting up a Glassfish cluster and I remembered having read a very good tutorial that created the entire cluster using only asadmin commands. In my experience using only asadmin commands not only gives you a greater understanding of the way Glassfish works internally but also enables you to create scripts for Glassfish administration commands.

Anyway, I managed to find the blogpost that I read about a year ago and decided that it was a good link to share with the world:

Categories: Glassfish, Java, Uncategorized

How to connect Glassfish 3 to an external ActiveMQ 5 broker

April 20, 2012 16 comments


Here at ONVZ we’re using Glassfish 3 as our development and production application server, and we’re quite happy with its performance and stability, as well as the large community surrounding it. I rarely run into a problem that does not have a matching solution on stackoverflow or As part of our open source strategy we also run a customized ActiveMQ cluster called “ONVZ Message Bus”.

To enable Message Driven Beans and other EJBs to consume and produce messages to and from the ActiveMQ message brokers, ignoring the internal OpenMQ broker that comes shipped with Glassfish, an ActiveMQ Resource Adapter has to be installed. Luckily for me Sven Hafner wrote a blog post about running an embedded ActiveMQ 5 broker in Glassfish 3, and I was able to distill the information I needed to connect to an external broker instead. This blog post describes what I did to get it to work.

Read more…

Maven best practices

February 23, 2011 4 comments

Although Maven offers a “convention over configuration” solution, there is still more then enough configuration necessary to cause some serious headache.  In this post I will share some best practices with you that will ease maintenance of your POM files.

Read more…

Categories: Maven3 Tags: ,

How to add jars to your Maven project

If you want to physically add jar files to your maven project, so they don’t have to be downloaded from a repository, you can use the system dependency scope, and point to a location in your project:

Categories: Maven3 Tags: , , ,

How to create a webservice client with Maven and JAX-WS

Maven allows you to integrate the generation of a JAX-WS webservice client into your build process. To do this, do the following:

1. Create a new module for the webservice client in your maven project.
2. Add the following configuration to the pom.xml of the new module:



3. The jar that maven generates with the above config, can be used to write a client program like the following:

MovieInformation info = new MovieInformation();
ArrayOfTheater theaters = info.getMovieInformationSoap12().getTheatersAndMovies(“10001″, 1);
for (Theater t : theaters.getTheater()) {
  System.out.println(“Theatre: “+t.getName()+”, “+t.getAddress());
  ArrayOfMovie movies = t.getMovies();
  for (Movie m : movies.getMovie()) {
    System.out.println(” -”+m.getName()+”, (Rating: “+m.getRating()+”)”);
Categories: Java, Maven3 Tags: ,

Why the “MAVEN2_CLASSPATH_CONTAINER will not be exported or published”

March 5, 2009 13 comments

On certain occasions Eclipse will present you with the following warning:

Classpath entry org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER will not be exported or published. Runtime ClassNotFoundExceptions may result.

So solve this, do the following:

  1. Open the properties of the project that generates this warning
  2. Click on “Java Build Path”
  3. Click on the tab “Order and Export”
  4. Enable “Maven Dependencies”
  5. Click on “Ok”
  6. Open the “Problems” view
  7. Select the warning we are trying to solve, and press “Ctrl-1”
  8. Click on “Ok”

The problem is now solved. It may take some time before the warning disapears because the project needs to rebuild before it goes away.