Installl Logitech Unified Receiver

2. November 2012 1 Kommentar

I just bought some new Input devices (the same I already use at work with Win7), a Performance MX Mouse and a K350 Keyboard from Logitech. Both devices use the Unified Receiver from Logitech. I used the Unified Receiver of the Keyboard initially and after starting the Laptop with the Receiver connected and the Keyboard and the Mouse turned on I did not get a connection from the mouse.

After fiddling around I stumbled across the following article, which described exactly what I had to do. Thanks to the Archlinux community another device is ready to be used ;-)

https://wiki.archlinux.org/index.php/Logitech_Unifying_Receiver

But there is more to come, because I want to use all the nice little buttons on the mouse and on the Keyboard as well, so lets see how this is going to work out ;-)

KategorienCommon Tags:

tonidoplug 2 and Western Digital Blue Scorpio 1TB

30. August 2012 Keine Kommentare

I just bought a 2,5″ Blue Scorpio from Western Digital. Basically I thought that it is 2,5″ and should fit into my Tonido Plug 2. Unfortunately this is only true with some minor “Hardware modifications” on the Tonido Plug. I had to use a Scissor to adopt the Tonido Plug to the HDD and also the cover does not fit anymore. Anyway, the drive seems to work and I am now in the process to install ArchLinux ARM on this new device and boot permanently from it.
More on this one in a later post.

KategorienCommon Tags:

Tonido Plug 2 – Wlan

12. August 2012 7 Kommentare

I have the problem, that after a certain amount of time, the wlan is not responding anymore on my Tonido Plug 2. I have now updated the Power Management on the device to “off” using the following commands:


sudo iwconfig mlan0 power off

Hope, that this helps ;-)

KategorienCommon Tags:

SparkleShare Dashboard

30. Juli 2012 Keine Kommentare

Today I wanted to install SparkleShare-Dashboard on my Linux Laptop. I was pretty glad, since it is a nodejs application and the target plattform, where I would like to install this application finally, will be a nodejs system (ArchLinux ARM) as well.

To install SparkleShare Dashboard on the latest nodejs-Version (v0.8.4) I had to adopt the Git-Child-Process creation in the backend/git.js-Module. For the full working version, please see .

There is also a little “difficulty” and probably a miss-understanding in the community of how to create a “SparkleShare-Git-Repository”. I have done it, therefore please find a step-by-step guide:


mkdir -p /home/USERNAME/sparkle/public.git
cd /home/USERNAME/sparkle/public.git
git init --bare
mkdir /home/USERNAME/tmp
cd /tmp
git clone file:///home/USERNAME/sparkle/public.git
cd /tmp/public
touch README.txt
git add README.txt
git commit -m "Initial commit"
git push origin master
cd ..
rm /tmp/public -rf

This should be it, you do have an initial commit in the repository, and therefor SparkleShare can attach the id to the repository (the id is the SHA1-id of the first commit in the repository).

KategorienArch Linux, Common, Linux Tags:

ArchLinux on a TonidoPlug2 with WLAN

29. Juli 2012 Keine Kommentare

Hello,

for my current vacation (my wife is going to look Olympic Games via TV the whole time) I decided to do me a favor and bought a TonidoPlug2. Since I am pretty much into ArchLinux, I decided to put ArchLinux on this device as well (see ArchLinux ARM). I used the Installation description on the above site without any problems, the way I did it, it went quite smooth. The difference was, that I did install the whole distribution on an USB-Stick before the device even arrived using my ArchLinux Laptop. Very nice ;-)

Now I am in the process of finish the Installation on the device (following some advice from binarybitme and this went pretty smooth as well. The tipp with the haveged is pretty useful for the current upgrade of pacman, which requires some entropy for the pacman-key --init command.

Furthermore I decided to use WLAN on this device (hey, thats why I decided to buy this one). Therefor I found one interesting forum entry which helped a lot ;-) In the current version of Arch Linux, the firmware is beneath /usr/lib and not under /lib, like described in the post. Then I installed netcfg and configured /etc/rc.conf and /etc/network.d/w-int-static (wireless device) as well as the /etc/conf.d/netcfg (without this one, netcfg can work, as long as rc.conf is configured correctly). For the whole wlan stuff to work (depending on your used security key) I had to install wpa_supplicant.

rc.conf:

MODULES=(mwifiex_sdio)

HOSTNAME="triton"

# Default network config (fallback, just to get access to the device, if
# wlan configs fail)
interface=eth0
address=192.168.1.25
netmask=255.255.255.0
gateway=

DAEMONS=(... network net-profiles ...)

/etc/network.d/w-int-static

CONNECTION='wireless'
DESCRIPTION='A wpa_supplicant configuration based wireless connection'
INTERFACE='mlan0'
SECURITY='wpa-config'
WPA_CONF='/etc/wpa_supplicant/wpa_supplicant.conf'
IP='static'
ADDR='192.168.0.25'
#ROUTES=('default via 192.168.0.1')
GATEWAY='192.168.0.1'
DNS=('192.168.0.1')
# Uncomment this if your ssid is hidden
#HIDDEN=yes

/etc/conf.d/netcfg

NETWORKS=(w-int-static)
# Specify the name of your wired interface for net-auto-wired
WIRED_INTERFACE="eth0"
# Specify the name of your wireless interface for net-auto-wireless
WIRELESS_INTERFACE="mlan0"

I am not going to show my wpa_supplicant-settings, but these were fairly easy and could already be tested on the laptop.

KategorienCommon Tags:

dbUnit in a Spring Environment with MSSQL

20. Oktober 2011 Keine Kommentare

Today I needed to export and import some data from a database for testing purposes. I do knew dbUnit already and this seemed to be the tool of choice. I stumbled about a couple of problems, because another example of the usage of dbUnit with the Spring Framework was using Oracle and furthermore the FlatXmlDataSet. I wanted to use the XmlDataSet, because this seems to be easier to maintain manually.

In the following I will try to show, how to integrate dbUnit into the project. First of all, I needed to put the Maven Plugin into place:

<dependencies>
        <dependency>
            <groupId>org.dbunit</groupId>
            <artifactId>dbunit</artifactId>
            <version>2.4.8</version>
            <scope>test</scope>
        </dependency>
...
</dependencies>
...
<build>
   <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>dbunit-maven-plugin</artifactId>
                <version>1.0-beta-3</version>
                <!--jar file that has the jdbc driver -->
                <dependencies>
                    <dependency>
                        <groupId>net.sourceforge.jtds</groupId>
                        <artifactId>jtds</artifactId>
                        <version>${jtds.version}</version>
                    </dependency>
                </dependencies>

                <configuration>
                    <driver>${database.driver.classname}</driver>
                    <url>${database.url}</url>
                    <username>${database.user}</username>
                    <password>${database.password}</password>
                    <dataTypeFactoryName>org.dbunit.ext.mssql.MsSqlDataTypeFactory</dataTypeFactoryName>
                    <ordered>true</ordered>
                </configuration>
            </plugin>
...
</plugins>
</build>

After this I was able to call mvn dbunit:export, which gave me an export of the current datastructure inside the database. It will generate a file target/dbunit/export.xml, which could then be used in the TestCases (we are using JUnit).

The TestCases are now looking something like this:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/META-INF/spring/testAC.xml"})
public class ServiceTest {
...
	@Autowired
	private DataSource dataSource;

Here we are autowiring the dataSource from the Application Context, this is needed to extract all necessary information for the database connection of dbUnit.

	// the following methods do make sure, that the database is setup correctly with
	// dbUnit
	private IDatabaseConnection getConnection() throws Exception {
    	// get connection
        Connection con = dataSource.getConnection();
        DatabaseMetaData databaseMetaData = con.getMetaData();
        IDatabaseConnection connection = new DatabaseConnection(con);
        DatabaseConfig config = connection.getConfig();
        config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new MsSqlDataTypeFactory());
        return connection;
	}

Here we are making sure, that the connection is setup correctly and that the right DataTypeFactory is used. This should be the same factory as used in the pom.xml (see above).

	private IDataSet getDataSet() throws IOException, DataSetException {
		File file = new File("src/test/resources/dbexport.xml");
		assertTrue(file.exists());
		Reader reader = new FileReader(file);
		return new XmlDataSet(reader);
	}

Fetching the dataset from a file and use it in the DatabaseOperation of dbUnit.

	@Test
	@Transactional
	public void testDelete() throws Exception {
        DatabaseOperation.CLEAN_INSERT.execute(getConnection(), getDataSet());
		EntityVersionId id = new VersionId("9a5a8eb1f02b4e06ba9117a771f2b69c", 2L);
		Entity entity = this.entityService.find(id);
		assertNotNull(entity);
		this.entityService.delete(id);
	}

Please note, that we are using a special EntityVersionId, which is part of our Framework and contains two values. This is a combined ID. The usual ID is an UUID (String) and a “version” of type long. I guess, you will most probably not use something like this in your project.

Thats it, now everything works like expected ;-)

KategorienJava, Projects Tags:

Getting into CXF

9. Oktober 2011 Keine Kommentare

For my new Job (oh, i did not blog about this one, but more information will follow soon) I am currently investigating a couple of EAI frameworks. One of them is Apache CXF. For this investigation, I am implementing a very easy task and use an easy tutorial (Creating a REST service with CXF and Spring in 10 minutes. Well, to be totally honest, it took me more then 10 minutes to get this up and running. Of course, this is mainly due to the fact, that I wanted to gather some more information about JXF and used my own services.
The first issue I stumbled upon was a problem with the error message: “no resource classes found”. Problem here was, that my ResourceService (call it Controller or whatever) implemented an interface and the JAX-RS Annotations were defined on the interface, instead of the concrete class. This was not working correctly. No I define all the annotations on the concrete class and everything went fine.
Another issue, I gathered on Tomcat, but not on Jetty, was a problem with the @Path-Annotation. I defined a @Path(“/folder”) on the class, and on the concrete method I defined another @Path(“/{id}”). This throw an exception on starting up Tomcat. After removing the “/” from the second @Path (so: @Path(“{id}”). This was another step into the right direction.

KategorienJava, Projects Tags:

Java 7 – minor classloading difficulties

13. August 2011 Keine Kommentare

Since I am using Arch Linux, I am more then accustomed to using the latest and greates versions of all the stuff. Unfortunately this is not always very good. During the last couple of days I experienced a couple of class loading issues with Java 7 (as opposed to Java 6).
I am currently testing Broadleaf Commerce and had to report an issue to theses guys because of some problems I did receive during compilation and running this application. Something similar happened to me on my project at work as well. I call this “class loading issues”, but it is probably slightly more. I do have problems loading configuration data correctly. (see issue 96 on the Broadleaf JIRA)-
To work around this issue, I just installed Java 6 again. Now it is working like a charm.

KategorienArch Linux, Common, Java, Linux Tags:

JAXB Experiences II

13. August 2011 1 Kommentar

Like already stated, we do have a large object tree, which we are exporting to xml using JAXB. Now we are also importing this tree again. Because of several Bi-/Uni-Directional Depedencies this object tree is kind of hard to reflect in XML. We do have one Root-Element, and several objects depending on this element uni-directional. Since the export is started fro the Root element, we are calling the corresponding service to find all uni-directional dependencies. These dependencies are exported into separate XML-files.
Since we do have in the child a reference to the root, we need to reflect this via an Reference on the property, otherwise the XML-file would be quite large and reflect the whole objects more then once, which leads to problems as well.
Problem is now, that the XMLIDRef is not really working, because the XMLIDRef is not referencing another object in the same file (the root element is defined in the original file). To work around this, we are using @XmlJavaTypeAdapter on the root property in the child object. This Adapter needs to get initialized and assigned to the unmarshaller. Please take a look onto the example below:

	private Object unmarshall(Class clazz, Map<Class, XmlAdapter> adapters, String fileName) throws Exception {
        // Create a JAXB context passing in the class of the object we want to marshal/unmarshal
        final JAXBContext context = JAXBContext.newInstance(clazz);

        // Create the marshaller, this is the nifty little thing that will actually transform the object into XML
		final Unmarshaller unmarshaller = context.createUnmarshaller();
		unmarshaller.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());
		for (Class adapterClass : adapters.keySet()) {
			unmarshaller.setAdapter(adapterClass, adapters.get(adapterClass));
		}

		log.info("Starting unmarshaller");
		Object unmarshalledObject = unmarshaller.unmarshal(new FileInputStream(fileName));
		log.info("Finished unmarshaller");

        return unmarshalledObject;
	}

The concrete adapters are added in the calling method:


	public Child unmarshallEntityWrapper(RootElement element, String fileName) throws Exception {
		Map<Class, XmlAdapter> adapters = new HashMap<Class, XmlAdapter>();

		determineAdapter(element, adapters);
        return (Child)this.unmarshall(Child.class, adapters, fileName);
	}

	private void determineAdapter(RootElement element, Map<Class, XmlAdapter> adapters) {
		RootElementAdapter adapter = new RootElementAdapter();
		for (SubElement subElement : element.getSubElements()) {
			adpater.put(subElement.getId(), subElement);
		}

		adapters.put(Adapter.class, adapter);
	}

The Adapter itself is pretty straight forward:

public class RootElementAdapter extends XmlAdapter<String, RootElement> {

	private Map<String, RootElement> rootElements = new HashMap<String, RootElement>();

	public Map<String, RootElement> getRootElements() {
		return rootElements;
	}

	@Override
	public RootElement unmarshal(String id) throws Exception {
		return rootElements.get(id);
	}

	@Override
	public String marshal(RootElement rootElement) throws Exception {
		return rootElement.getId();
	}
}

The classes itself are pretty straight forward as well. Please notice, that the ChildElement is stored in another XML-file and because of this, we do need the Adapter, like already stated above. The RootElement does not have any relationship to the Child-elements:

@XmlRootElement(name = "RootElement")
public class RootElement implements Serializable {
   ...
}

public class ChildElement implements Serializable {
   @XmlJavaTypeAdapter(RootElementAdapter.class)
   public RootElement getRootElement() {
     ....
   }
}

In the service, which is handling the marshalling, we are now fetching all ChildElements belonging to the RootElement via a service method like so:

public List<ChildElement> findChildsByRootElement(RootElement rootElement) {
   ...
}

Because we would like to marshall these elements into their own XML-file, we do have to create a Wrapper Object, which basically wraps all elements:

@XmlRootElement
@XmlSeeAlso({ChildElement.class, ChildA.class, ChildB.class})
public class ChildElementWrapper {

	private Collection<ChildElement> childElements;

	public ChildElementWrapper() {
	}

	public ChildElementWrapper(Collection<ChildElement> childElements) {
		this.childElements = childElements;
	}

	@XmlElementWrapper(name = "childElements")
	@XmlElement(name = "childElement")
	public Collection<ChildElement> getChildElements() {
		return childElements;
	}

	public void setChildElements(Collection<ChildElement> childElements) {
		this.childElements = childElements;
	}
}

Another important thing, we learned during the implementation of this Import/Export layer was that the usual Inheritance from Hibernate using Discriminators is not really nicely handled. The Wrapper-Class has to use the @XmlSeeAlso-Annotation, like stated above. Now all the concrete implementations of the ChildElement-Class are marked with the type-attribute in the XML-file. Since we are using hibernates replicate and we need the Discriminator Value, we are using the following solution:

...
			switch (childElement.getElementType()) {
				case A:
					ChildA childA = (ChildA)childElement;
					this.jcDao.store(childA);
					this.jcDao.updateDiscriminator(childA, "DiscriminatorA");
					break;
				case B:
					ChildB childB = (childB)childElement;
					this.jcDao.store(childB);
					this.jcDao.updateDiscriminator(childB, "DiscriminatorB");
					break;
				default:
					break;
			}
...

	public Object store(Object object) {
		if (this.entityManager == null) throw new IllegalStateException("Entity manager has not been injected");

		Session session = (Session)this.entityManager.getDelegate();

		session.replicate(object, ReplicationMode.OVERWRITE);

		return object;
	}

	public void updateDiscriminator(Object object, String discriminator) {
		if (this.entityManager == null) throw new IllegalStateException("Entity manager has not been injected");

		Session session = (Session)this.entityManager.getDelegate();

		String hqlUpdate = "update ChildElement set type = :discriminator where id = :id";
		int updateEntities = session.createQuery(hqlUpdate).setString("id", object.toString())
									 .setString("discriminator", discriminator)
									 .executeUpdate();
	}

I hope, that this explanation is easy enough to follow ;-)

KategorienJava Tags:

Domain-Movement

31. Juli 2011 Keine Kommentare

During the last weekend, I moved my domains (javafreedom.org and wifi-frankfurt.de) to the uberspace.de location. Because of this, it can happen, that emails where not delivered or bounced.

The movement was quite fast (something like 24 hours) for all things. The guys at uberspace.de were really really nice and helped a lot. I can only recommend to any geek out there, to move her domains to uberspace.de.

KategorienCommon Tags: