Spring 3 und MyBatis 3.0.4 / 3.0.6

I was trying to use Spring 3.0.5.RELEASE together with MyBatis in a Maven environment. I added the mybatis-spring dependency. This turned out not to work due to a MalformedParameterizedTypeException (a detailed stacktrace is included below). There are quite some posts concerning this iusse, yet most of them refer to the problem as being caused by having some Spring 2 dependency somewhere in the classpath which was not the case for me:

The first link mentions an imcompatability to Spring 2 because of the BeanFactory being paramterized in Spring 3 but not in Spring 2. Well, it turns out that the real problem was, that I had a separate MyBatis version (3.0.4) in my dependencies. I changed version 3.0.4 to version 3.0.6 and everything worked just fine. Usually, if one does not have a separate MyBatis dependency somewhere in the project (or parent projects!), the mybatis-spring artifact from Maven comes with MyBatis 3.0.6.

Stacktrace:

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:679)
Caused by: java.lang.reflect.MalformedParameterizedTypeException
    at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:60)
    at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.<init>(ParameterizedTypeImpl.java:53)
    at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:95)
    at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:104)
    at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:140)
    at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
    at sun.reflect.generics.visitor.Reifier.visitArrayTypeSignature(Reifier.java:159)
    at sun.reflect.generics.tree.ArrayTypeSignature.accept(ArrayTypeSignature.java:42)
    at sun.reflect.generics.repository.ConstructorRepository.getParameterTypes(ConstructorRepository.java:94)
    at java.lang.reflect.Method.getGenericParameterTypes(Method.java:300)
    at java.beans.FeatureDescriptor.getParameterTypes(FeatureDescriptor.java:385)
    at java.beans.MethodDescriptor.setMethod(MethodDescriptor.java:116)
    at java.beans.MethodDescriptor.<init>(MethodDescriptor.java:74)
    at java.beans.MethodDescriptor.<init>(MethodDescriptor.java:58)
    at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1196)
    at java.beans.Introspector.getBeanInfo(Introspector.java:423)
    at java.beans.Introspector.getBeanInfo(Introspector.java:189)
    at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:224)
    at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:149)
    at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:305)
    at org.springframework.beans.BeanWrapperImpl.getPropertyDescriptorInternal(BeanWrapperImpl.java:335)
    at org.springframework.beans.BeanWrapperImpl.isWritableProperty(BeanWrapperImpl.java:407)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1327)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    ... 19 more

Side note: I had some other issues with the Maven dependency management system I was using because the changed pom.xml dependency would not propagate through to the top-level projects. Obviously after running a mvn clean install -Dmaven.text.skip=true dependencies got propagated to the top level projects and averything was working.

VN:F [1.9.11_1134]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.11_1134]
Rating: 0 (from 0 votes)

Orbital

I have a friend who wanted to get to work the program "Orbital" (http://www.itp.tu-berlin.de/menue/lehre/owl/quantenmechanik/wasserstoff-orbitale/parameter/maxhilfe/). The problem was that Orbital uses JOGL 1.1.1 (http://en.wikipedia.org/wiki/Java_OpenGL) in order to run the Webstart application. Webstart requires signed dependencies (JAR files) to be signed. Yet JOGL 1.1.1 is old and is not signed anymore by Oracle (http://www.java-gaming.org/index.php?topic=24806.0).

There are two ways to circumvent this problem.

Signing

One is to sign and host the JAR files oneself. This links might give some hint on how to do this:
http://www.dallaway.com/acad/webstart/

The source to obtain free certificates mentioned is not available anymore. Yet there are free certificates available here:
http://www.instantssl.com/ssl-certificate-products/free-email-certificate.html

These certificates might not be compatible. I don't know. I did not try.

Non-Webstart

The alternative way to get Oribtal to run is by using the source of JOGL directly (also available on the Orbital webpage).

This is what got Orbital running for me!

VN:F [1.9.11_1134]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.11_1134]
Rating: 0 (from 0 votes)

Eclips, Maven, WTP: AJDT Integration

It seems there is a configurator needed to make AJDT work with Maven in Eclipse as hinted by this article:
http://wiki.eclipse.org/M2E_plugin_execution_not_covered

Plugins, namely m2eclipse-ajdt exist or are being developed:

But then again, I have no idea what I am actually talking about. I will try to get by without worrying about this until I actually have to :) .

VN:F [1.9.11_1134]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.11_1134]
Rating: 0 (from 0 votes)

Maven WAR Context Root (m2e-wtp)

I was wondering how Maven determines the name of the context root when deploying directly from Eclipse using m2e-wtp (and probably also when deploying the *.war later). It turns out that the finalName tag in the pom.xml does the trick:

...
<build>
   <finalName>root context name</finalName>
   ...
</build>
...
VN:F [1.9.11_1134]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.11_1134]
Rating: 0 (from 0 votes)

Eclipse: Maven Integration and WTP

The Maven integration for Eclipse project (m2e or m2eclipse) by Sonartype (http://m2eclipse.sonatype.org/) has been moved to Eclipse. The version number was raised to 1.x. Since then the update sites by Sonartype are outdated and extras cannot be installed by accessing the usual update site (http://m2eclipse.sonatype.org/sites/m2e-extras) anymore as the provided extras are not compatible. Thus the WTP integration cannot be installed from that source.

When creating a default Maven project using m2e (either by using the simple or the archetype dialog - maven-archetype-quickstart or maven-archetype-webapp), no WTP functionality is given even though the pom.xml is configured to package a *.war*.war is important; the maven-archetype-quickstart needs to be modified accordingly, maven-archetype-webapp does it automatically and the simple dialog offers a corresponding option). Now neither of these settings allows to deploy to a server directly by choosing

Run As > Run on Server

.
This can be fixed by configuring the project as a faceted project:

Configure > Convert to Faceted Form...

The Project Facet "Dynamic Web Project" needs to be selected. There is a link showing up below the section showing the Project Facets. I clicked it and changed the "Content Directory" to src/main/webapp.

This will yield projects directly deploy-able to e.g. a Tomcat server, BUT will result in a warning:

org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER will not be exported or published. Runtime ClassNotFoundExceptions may result.

This warning is of consequence as dependencies are not correctly packaged an respective classes will not be found.

Several bug fixes exist out there. The only sensible solution is to install the WTP integration. The "preferred way" to do so is to use the m2e marketplace, where the m2e-wtp connector can be installed from:

Window > Preferences > Maven > Discovery > Open Catalog

After installing the connector and rebooting Eclipse as well as updating Maven dependencies and project configurations (just in case), things should work out of the box WITHOUT having to specify a faceted project(!). Configuring the pom.xml to use *.war* packaging is enough to allow direct deployment from Eclipse.

Remember to refresh the Eclipse workspace afterwards and run

Maven > Update Dependencies

and

Maven > Update Project Configuration

if things don't work right away.

Sources:

VN:F [1.9.11_1134]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.11_1134]
Rating: 0 (from 0 votes)

Java: Singleton Syntax

So today I learned, that it seems to be possible to specify a single variable without a type and any modifyer in a Java class. This seems to implement a singleton desgin pattern? I will have to investigate further.

 

package de.vogella.jersey.todo.dao;
 
import java.util.HashMap;
import java.util.Map;
 
import de.vogella.jersey.todo.model.Todo;
 
public enum TodoDao {
	instance;
 
	private Map<String, Todo> contentProvider = new HashMap<String, Todo>();
 
	private TodoDao() {
 
		Todo todo = new Todo("1", "Learn REST");
		todo.setDescription("Read http://www.vogella.de/articles/REST/article.html");
		contentProvider.put("1", todo);
		todo = new Todo("2", "Do something");
		todo.setDescription("Read complete http://www.vogella.de");
		contentProvider.put("2", todo);
 
	}
	public Map<String, Todo> getModel(){
		return contentProvider;
	}
 
}

Source: http://www.vogella.de/articles/REST/article.html

VN:F [1.9.11_1134]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.11_1134]
Rating: 0 (from 0 votes)

Eclipse - WTP - Dynamic Web Project - Deployment Assemly

When using Eclipse WTP to develop dynamic web projects, it is often necessary to deploy resources to the WebContent folder. Keeping resources in the WebContent folder is ugly and manually copying them is tedious. The propject property "Deployment Assembly" allows to specify which folders are deployed to the WebContent folder upon calling "Run As > Run on Server".

Properties > Deployment Assembly
VN:F [1.9.11_1134]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.11_1134]
Rating: 0 (from 0 votes)

Compiz: Switch Screens / Outout Shortcut

So, I like to use my keyboard. And one problem I was fighting with was how to set a shortcut to move windows between physical screens (not viewports) quickly. I finally found the setting myself as there seems to be different names to this options in different Compiz versions:

For the Ubuntu 11.04 (Natty Narwhal) I found the option at

CompizConfig Settings Manager > Window Management > Put > Bindings > Put To Next Output
VN:F [1.9.11_1134]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.11_1134]
Rating: 0 (from 0 votes)

Ubuntu and NTFS

I installed Ubuntu 11.04 (Natty Narwhal) and I was not able to run binaries from the NTFS partition. The solution was adding information about the mounting to the /etc/fstab manually.

After creating the directory /media/data

sudo mkdir /media/data

I added to following entry to the /etc/fstab:

/dev/sda7       /media/data     ntfs    user,exec,rw    0       0

and everything works miraculously.

Note one thing: the options user and exec must appear in the order specified above.

After editing the fstab, type the following line of code to apply the changes:

sudo mount -a

The corresponding information is aggregated from:

VN:F [1.9.11_1134]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.11_1134]
Rating: 0 (from 0 votes)

LaTeX: Line Spacing

I keep forgetting the command to set line spacing in LaTeX. The package being is setspace. The command I keep forgetting is \setstretch{1.5}

\usepackage{setspace} % for setting linespace
\setspace{1.5} % command to set line spacing
VN:F [1.9.11_1134]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.11_1134]
Rating: 0 (from 0 votes)
Return top
 

Warning: array_filter() [function.array-filter]: The first argument should be an array in /var/www/web41/html/hp_fstyle/wordpress/wp-content/plugins/wordpress-tweaks/tweaks.php on line 650