Short Eclipse proxy guidelines

If you consider yourself as developer and if you use Eclipse as IDE you might at least once faced that problem that you sat behind a proxy in some customers network and need to use to connect to the internet downloading either maven dependencies or plugins for your IDE. Since I struggle with the configuration of the proxy in nearly every project I decided to write these few facts down in case they might help you, too.

In Eclipse → Window → Preferences → General → Network Connections you find the following view. The combobox named Active Provider lists three options to configure a proxy. Native uses the native OS settings, Manual allows you to enter a proxy host, port, user name and password yourself and Direct connects directly to the desired URL.

ProxyEclipse

As a first step you might want to edit the proxy settings for a manual setup and enter the proxy server properties as provided by your network administrator. Then follow these two simple rules for your later work in Eclipse:

  • When downloading software from an online repository or the Eclipse marketplace – Set the proxy to Manual
  • When downloading maven dependencies – Set to proxy to Native

That’s it!

 

Deploy a web application to an embedded Tomcat 8

I’ve found various tutorials on creating an embedded tomcat programatically and deploy a web application to it. Unfortunately, non of the tutorials was up to date using Tomcat 8 and actually non was showing how to deploy anything else but a servlet so I decided to write a short tutorial on how to create the server and deploy either a WAR file or a folder containing a non archived web application.

Create a simple Java project in ecplipse, enable maven and add the following dependencies:

<dependencies>
  <dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>tomcat-catalina</artifactId>
    <version>8.0.21</version>
  </dependency>
  <dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>tomcat-util</artifactId>
    <version>8.0.21</version>
  </dependency>
  <dependency>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-core</artifactId>
    <version>8.0.21</version>
  </dependency>
  <dependency>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-jasper</artifactId>
    <version>7.0.8</version>
  </dependency>
</dependencies>

Optionally, you can enable the maven-assembly-plugin to package your application as JAR at the end and have maven include all dependencies you specified. As build goal you’ll have to use assembly:single.

<plugin>
  <artifactId>maven-assembly-plugin</artifactId>
  <configuration>
    <archive>
      <manifest>
        <mainClass>de.jofre.embeddedtc.runtime.Main</mainClass>
      </manifest>
    </archive>
    <descriptorRefs>
      <descriptorRef>jar-with-dependencies</descriptorRef>
    </descriptorRefs>
  </configuration>
</plugin>

Now create the class de.jofre.embeddedtc.runtime.Main (The name is arbitrary) and add write the code according to the next listing:

package de.jofre.embedded.runtime;
 
import java.io.File;
import java.util.logging.Logger;
 
import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.startup.Tomcat;
 
public class Main {
  private final static Logger LOGGER = Logger.getLogger(Main.class.getName());
  private final static String mWorkingDir = System.getProperty("java.io.tmpdir");
  private static Tomcat tomcat = null;
 
  public static void main(String[] args) {
 
    tomcat = new Tomcat();
    tomcat.setPort(8080);
    tomcat.setBaseDir(mWorkingDir);
    tomcat.getHost().setAppBase(mWorkingDir);
    tomcat.getHost().setAutoDeploy(true);
    tomcat.getHost().setDeployOnStartup(true);
 
    try {
      tomcat.start();
    } catch (LifecycleException e) {
      LOGGER.severe("Tomcat could not be started.");
      e.printStackTrace();
    }
    LOGGER.info("Tomcat started on " + tomcat.getHost());
 
    // Alternatively, you can specify a WAR file as last parameter in the following call e.g. "C:\\Users\\admin\\Desktop\\app.war"
    Context appContext = Main.getTomcat().addWebapp(Main.getTomcat().getHost(), "/app", "C:\\Users\\admin\\Desktop\\app\\");
    LOGGER.info("Deployed " + appContext.getBaseName() + " as " + appContext.getBaseName());
 
    tomcat.getServer().await();
  }
}

The last question is how the directory in C:\\Users\\admin\\Desktop\\app\\ respectively the C:\\Users\\admin\\Desktop\\app.war looks like. Well, it contains a simple HTML file…

<html><body>Test</body></html>

… and another folder called WEB-INF containing the web.xml with the following content:

<?xml version="1.0" encoding="ISO-8859-1"?>
 
<!DOCTYPE web-app 
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
    "http://java.sun.com/dtd/web-app_2_3.dtd">
 
<web-app>
 
    <display-name>Test App</display-name>
    <description>A test app</description>
 
	<welcome-file-list>
			<welcome-file>index.html</welcome-file>
	</welcome-file-list>
 
    <session-config>
      <session-timeout>30</session-timeout>
    </session-config>
 
</web-app>

Now if you start the java application you call http://localhost:8080/app and the content of index.html should be displayed. Hope this helps you!

Devmania 2014 – Derp in Trouble

Die Devmania ist eine Veranstaltung in Mainz, auf der sich Spieleentwickler aus ganz Deutschland treffen, um in einem Overnight-Contest gegeneinander anzutreren und zu einem bestimmten Thema ein Spiel zu entwickeln. Dieses Jahr war das Thema Memes. Nils und ich haben mit unserem Projekt Derp in Trouble den dritten Platz belegt. Das Spiel könnt ihr hier herunterladen, ein kurzes Video gibt es am Ende des Posts. Zwar ist der Umfang mit einem einzelnen Level recht gering, dafür sind aber sämtliche Inhalte in etwa 12 Stunden entstanden. Einzige Ausnahme ist der Soundtrack, für den mal wieder ein Dank an Ruben geht 🙂

[Leap Motion] Setting up a C++ project with Visual Studio 2010

Yesterday, my Leap Motion Developer Device arrived and I started imeadiately to try the diverse SDKs. Setting up a Java project is simple because the official resource side provides an easy but great tutorial. A C++ project is some more difficult but fairly uncomplicated, as well, when you know how to configure include and library paths. Follow these easy steps to set up a project:

  1. Create a Win32 project via File -> New Project…
  2. Right click the project and select Properties
  3. Under Configuration Properties -> VC++ Directories -> Include directories add a link to [LeapSDK]\include
  4. Under Configuration Properties -> VC++ Directories -> Library directories add a link to [LeapSDK]\lib\x86
  5. Add Leap.dll (Or Leapd.dll in debug mode) under Linker -> Input.
  6. Include at least leap.h in your project and follow the official C++ tutorial to begin your first project.

Have fun! 🙂

Developing custom JSF 2.0 components

In this tutorial I want to show you how to create a classic JSF 2.0 component in pure Java (Classic != Composite Component).

 

 

Furthermore, you learn how to package it to an own JSF taglib (meaning: as a JAR) so that you it can be distribute easily.

 

HDFS Explorer – Managing the Hadoop file system on a remote machine

Working with hadoop means working with the Hadoop File System (HDFS). Therefore, it is mandatory to read, write and delete files via command line. That can be quite difficult and exhausting when you are not familiar with the common unix and hadoop commands. To handle this task, I wrote a small application that is able to work with an HDFS running on Ubuntu.

So far, the application is able to:

  • Read the HDFS in a treeview
  • Upload / Download files to/from the local machine
  • Delete files on the HDFS
  • Create directories on the HDFS

When there is a need (and if I get enough good feedback 😉 ), I’ll add session management for several file systems as well as the function to start MapReduce jobs from the application (as it can be seen in the lower group box).

A download is about to follow soon!

Eine einfache Logging-Klasse in C++

Ich schreibe gerade an einigen DLLs für Gamestudio und hatte da das Problem, dass es nicht einfach ist diese zu Debuggen. Dafür habe ich hier eine einfache Logging-Klasse geschrieben die als Singleton agiert, er muss also nicht explizit initialisiert sondern einfach nur aufgerufen werden. Das geht so:

Logger::getInstance()->log("Skins: %i", 1);

Es ist also möglich, beliebig lange Argumentelisten zu verarbeiten. Das Log wird in der Datei “Log.txt” im Verzeichnis der Anwendung gespeichert.

Den Quelltext findet ihr hinter dem More-Tag. Viel Spaß damit!

Continue reading “Eine einfache Logging-Klasse in C++”

[Hadoop] hadoop.job.ugi nicht in Lokations-Optionen vorhanden

Ein weiteres Problem über das ist beim Einrichten des Eclipse-Plugins gestolpert bin, ist, dass die Eigenschaft hadoop.job.ugi die laut dem Yahoo-Tutorial gesetzt werden soll nicht vorhanden ist.

Diese erscheint erst, wenn einmal eine erfolgreiche Verbindung zum Filesystem hergestellt werden konnte (Sollten Sie damit Probleme haben, lesen Sie bitte hier weiter), vorher nicht!

[Hadoop] Auf HDFS auf Virtual Machine über Eclipse zugreifen

Ich beschäftige mich in letzter Zeit ein wenig mit dem Thema BigData. Yahoo stellt dafür ein gutes Tutorial bereit, allerdings klappt es nicht wie beschrieben eine Verbindung aus Eclipse auf eine Virtual Machine herzustellen auf der das entsprechende Filesystem liegt (HDFS). Eclipse kommentiert dieses Unvermögen mit einem Simplen Error: null.

Dieser Fehler tritt auf, wenn Eclipse auf einem Windowssystem läuft und der Trick ist es: Starte Eclipse aus Cygwin!

Der Befehl cygstart “C:\eclipse\eclipse.exe” sollte reichen und die Verbindung kommt zustande.