<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ralf Schäftlein's Blog</title>
	<atom:link href="http://ralf.schaeftlein.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://ralf.schaeftlein.de</link>
	<description>tech stuff, talk,...</description>
	<lastBuildDate>Fri, 05 Mar 2010 15:39:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>JUnit Tests for Spring 3 Rest Services</title>
		<link>http://ralf.schaeftlein.de/2010/03/05/junit-tests-for-spring-3-rest-services/</link>
		<comments>http://ralf.schaeftlein.de/2010/03/05/junit-tests-for-spring-3-rest-services/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 15:39:31 +0000</pubDate>
		<dc:creator>ralf</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[JAXB]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[webservices]]></category>

		<guid isPermaLink="false">http://ralf.schaeftlein.de/?p=187</guid>
		<description><![CDATA[SpringSource has recently released 3.0.1 of their Spring Framework. Spring 3 extended the REST functionalities inside the Web MVC part of the Framework. Rest Service are defined as Controller and can be tested with the new Resttemplate. In this little sample project is Spring 3 combined with JUnit 4, Maven, Hibernate 3.2, Jetty, MySQL, JPA, [...]]]></description>
			<content:encoded><![CDATA[<p>SpringSource has recently released <a href="http://blog.springsource.com/2010/02/18/spring-framework-3-0-1-released/">3.0.1</a> of their Spring Framework. Spring 3 extended the REST functionalities inside the Web MVC part of the Framework. Rest Service are defined as <a href="http://blog.springsource.com/2009/03/08/rest-in-spring-3-mvc/">Controller</a> and can be tested with the new <a href="http://blog.springsource.com/2009/03/27/rest-in-spring-3-resttemplate/">Resttemplate</a>. In this little sample project is Spring 3 combined with JUnit 4, Maven, Hibernate 3.2, Jetty, MySQL, JPA, JAXB and AspectJ. Additional tests was made with <a href="https://addons.mozilla.org/de/firefox/addon/2691">Poster</a> as a Firefox Plugin to test REST bases Webservices. Jetty 6.1 is used as embedded container for the web application as backend for the seperated maven integration tests. Jetty can be started with mvn jetty:run for tests with Poster or will be started before the integration tests runs with mvn integration-test. The Project is configured via Maven pom.xml as seen later in this post. Via mvn eclipse:eclipse will the eclipse settings generated to use the project as WTP project. I used <a href="http://maven.apache.org/download.html">Maven 2.2.1</a> in combination with <a href="http://www.eclipse.org/downloads/">eclipse 3.5.2.</a>. As backend infrastructure runs inside Ubuntu 9.1 Server a <a href="http://www.bugzilla.org/">Bugzilla 3</a>, <a href="http://www.jfrog.org/products.php">Artifactory 2.2.1</a>, Subversion 1.6 and a <a href="http://hudson-ci.org/">Hudson 1.348</a>.</p>
<p>REST as <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">representational state transferr</a> has less protocol overhead as SOAP. It heavily depends on HTTP mechanism like PUT, GET, DELETE or POST method calls or HTTP accept header definition of the mime type like &#8216;text/xml&#8217;, &#8216;text/plain&#8217; or &#8216;image/jpeg&#8217; to define delivered and expected content. So you make a HTTP GET request with an accept header &#8216;image/jpeg&#8217; with a url like http://myserver/restservice/1 in firefox to see their a picture of catalog item with id 1. A HTTP Post send data to the server as new data and a PUT override existing data. HTTP 1.1 defines a <a href="http://http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html">list of methods</a> to use in your REST based Service. </p>
<p>The whole project is Java annotation driven and use JDK 1.6 but can easily switched to run with JDK 1.5 as well. Configuration is Spring based as <a href="http://de.wikipedia.org/wiki/Inversion_of_Control">IOC pattern</a> and as annotations inside the Java classes. XML content is converted by JAXB Marshaller to use only domain objects inside your business logic. Persistence is defined as JPA annotations with Hibernate as implementation against a MySQL 5 database. </p>
<p><strong>The Java Source files</strong></p>
<p>The controller RestServiceController</p>
<pre name="code" class='java'>
package de.schaeftlein.dev.spring.rest.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import de.schaeftlein.dev.spring.rest.dao.PersonDao;
import de.schaeftlein.dev.spring.rest.domain.People;
import de.schaeftlein.dev.spring.rest.domain.Person;

@Controller
@RequestMapping("/people")
public class RestServiceController
{
  @Autowired
  private PersonDao personDao;

  @RequestMapping(method = RequestMethod.GET)
  @Transactional(readOnly = true)
  @ResponseBody
  public People getAll() {
    List<Person> persons = personDao.getPeople();
    People people = new People(persons);
    return people;
  }

  @RequestMapping(value = "/person/{id}", method = RequestMethod.GET)
  @ResponseBody
  @Transactional(readOnly = true)
  public Person getPerson(@PathVariable("id") Long personId) {
    return personDao.getPerson(personId);
  }

  @RequestMapping(method = RequestMethod.POST)
  @Transactional(readOnly = false)
  @ResponseBody
  public Person savePerson(@RequestBody Person person) {
    personDao.savePerson(person);
    return person;
  }
}
</pre>
<p>The Interface for the DAO PersonDAO</p>
<pre name="code" class='java'>
package de.schaeftlein.dev.spring.rest.dao;

import java.util.List;

import de.schaeftlein.dev.spring.rest.domain.Person;

public interface PersonDao {

  public Person getPerson(Long personId);

  public void savePerson(Person person);

  public List<Person> getPeople();

  public Person getPersonByUsername(String username);

}
</pre>
<p>The DAO implementation PersonDAOHibernate</p>
<pre name="code" class='java'>
package de.schaeftlein.dev.spring.rest.dao.hibernate;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import de.schaeftlein.dev.spring.rest.dao.PersonDao;
import de.schaeftlein.dev.spring.rest.domain.Person;

@Repository
@Transactional
@SuppressWarnings("unchecked")
public class PersonDaoHibernate extends HibernateDaoSupport implements
    PersonDao {

  @Autowired
  public void setupSessionFactory(SessionFactory sessionFactory) {
    this.setSessionFactory(sessionFactory);
  }

  public Person getPerson(Long personId) throws DataAccessException {
    return this.getHibernateTemplate().get(Person.class, personId);
  }

  @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
  public void savePerson(Person person) throws DataAccessException {
    this.getHibernateTemplate().saveOrUpdate(person);
  }

  public List<Person> getPeople() throws DataAccessException {
    return this.getHibernateTemplate().find("select people from Person people");
  }

  public Person getPersonByUsername(String username) {
    List<Person> people = this.getHibernateTemplate().findByNamedParam(
        "select people from Person people "
            + "where people.username = :username", "username", username);
    Person person = getFirst(people);
    if (person != null)
      getHibernateTemplate().evict(person);
    return person;
  }

  private static <T> T getFirst(List<T> list) {
    return CollectionUtils.isEmpty(list) ? null : list.get(0);
  }
}
</pre>
<p>The JAXB domain object People</p>
<pre name="code" class='java'>
package de.schaeftlein.dev.spring.rest.domain;

import java.io.Serializable;
import java.util.List;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class People implements Serializable {
  private static final long serialVersionUID = 1L;

  private List<Person> person;

  public People() {
    // empty constructor required for JAXB
  }

  public People(List<Person> person) {
    this.person = person;
  }

  public List<Person> getPerson() {
    return person;
  }

  public void setPerson(List<Person> person) {
    this.person = person;
  }

}
</pre>
<p>The JAXB and JPA entity domain object Person</p>
<pre name="code" class='java'>
package de.schaeftlein.dev.spring.rest.domain;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Version;
import javax.xml.bind.annotation.XmlRootElement;

@Entity
@XmlRootElement
public class Person implements Serializable
{
  private static final long serialVersionUID = 1L;

  @Id
  @GeneratedValue
  private Long id;
  private String firstName;
  private String lastName;
  private String username;
  private String password;
  private int roleLevel;

  @Version
  private Integer version;

  public Person()
  {

  }

  public Person(String firstName, String lastName, String username, String password, int roleLevel)
  {
    this.firstName = firstName;
    this.lastName = lastName;
    this.username = username;
    this.password = password;
    this.roleLevel = roleLevel;
  }

  public Long getId()
  {
    return id;
  }

  public void setId(Long id)
  {
    this.id = id;
  }

  public String getFirstName()
  {
    return firstName;
  }

  public void setFirstName(String firstName)
  {
    this.firstName = firstName;
  }

  public String getLastName()
  {
    return lastName;
  }

  public void setLastName(String lastName)
  {
    this.lastName = lastName;
  }

  public String getUsername()
  {
    return username;
  }

  public void setUsername(String username)
  {
    this.username = username;
  }

  public String getPassword()
  {
    return password;
  }

  public void setPassword(String password)
  {
    this.password = password;
  }

  public int getRoleLevel()
  {
    return roleLevel;
  }

  public void setRoleLevel(int roleLevel)
  {
    this.roleLevel = roleLevel;
  }

  public Integer getVersion()
  {
    return version == null ? 1 : version;
  }

  public void setVersion(Integer version)
  {
    this.version = version;
  }

  public enum RoleLevel {
    ADMIN(1), GUEST(2), PUBLIC(3);
    private final int level;

    RoleLevel(int value)
    {
      this.level = value;
    }

    public static RoleLevel getLevel(String roleName)
    {
      return RoleLevel.valueOf(roleName);
    }

    public int getLevel()
    {
      return this.level;
    }
  }

  @Override
  public boolean equals(Object obj)
  {
    if (obj == null)
    {
      return false;
    }
    else if (!(obj instanceof Person))
    {
      return false;
    }
    else
    {
      Person p = (Person) obj;
      if (p.getId().equals(getId()) &#038;&#038; p.getUsername().equals(getUsername()) &#038;&#038;
          p.getVersion().equals(getVersion()) &#038;&#038;
          p.getLastName().equals(getLastName()) &#038;&#038; p.getPassword().equals(getPassword())
          &#038;&#038; p.getFirstName().equals(getFirstName()) &#038;&#038; p.getRoleLevel() == getRoleLevel())
      {
        return true;
      }
    }
    return false;
  }

}
</pre>
<p>The DAO test PersonDAOTest</p>
<pre name="code" class='java'>
package de.schaeftlein.dev.spring.rest.dao;

import java.util.List;

import static junit.framework.Assert.*;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;

import de.schaeftlein.dev.spring.rest.domain.Person;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:spring-context.xml" })
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false)
public class PersonDaoTest {

  @Autowired
  PersonDao personDao;

  private Logger log = LoggerFactory.getLogger(PersonDaoTest.class);

  @Test
  public void testPerson() {
    String username = "pfisher";
    Person person = new Person("Paul", "Fisher", username, "password",
        Person.RoleLevel.ADMIN.getLevel());
    person.setVersion(1);
    personDao.savePerson(person);

    final List<Person> people = personDao.getPeople();
    assertEquals(1, people.size());
    assertEquals(person,people.get(0));

    Long personId = person.getId();
    Person savedPerson = personDao.getPerson(personId);
    assertEquals(username,savedPerson.getUsername());
  }

  @Test
  public void testVersion() {
    Person solomon = new Person("Solomon", "Duskis", "sduskis", "mypass",
        Person.RoleLevel.ADMIN.getLevel());
    // version 0
    personDao.savePerson(solomon);

    Integer version = solomon.getVersion();
    log.info("old version:"+solomon.getVersion());

    solomon = personDao.getPersonByUsername("sduskis");
    solomon.setPassword("password1");
    // version 1
    personDao.savePerson(solomon);

    log.info("new version:"+solomon.getVersion());

    assertTrue(!(version.equals(solomon.getVersion())));
  }
}
</pre>
<p>The Rest test RestClientTest</p>
<pre name="code" class='java'>
package de.schaeftlein.dev.spring.rest.itest.controller;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;

import java.util.Collections;
import java.util.Map;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.web.client.RestTemplate;

import de.schaeftlein.dev.spring.rest.domain.People;
import de.schaeftlein.dev.spring.rest.domain.Person;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:spring-context.xml"})
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false)
public class RestClientTest
{

  private static final String BASE_URL = "http://localhost:9090/spring3-rest-sample/people";

  private Logger log = LoggerFactory.getLogger(RestClientTest.class);

  @Autowired
  private RestTemplate restTemplate;

  @Test
  public void saveAndGet() throws Exception{
    // save
    Person input = new Person("jane","doe","jane.doe","pw",Person.RoleLevel.ADMIN.getLevel());
    assertNull(input.getId());
    Person output = restTemplate.postForObject(BASE_URL, input, Person.class, new Object[]{});
    assertNotNull("no person",output);
    assertNotNull(output.getId());
    assertEquals(input.getUsername(), output.getUsername());
    log.info("Saved jane.doe with id "+output.getId());
    // get all
    People people = restTemplate.getForObject(BASE_URL, People.class,new Object[]{});
    assertNotNull("no people",people);
    assertNotNull("no persons in people",people.getPerson());
    assertTrue("empty persons in people",!people.getPerson().isEmpty());
    assertEquals("no one person in people",input.getUsername(),people.getPerson().get(0).getUsername());
    log.info("Peple size "+people.getPerson().size());
    // get id
    Map<String, String> vars = Collections.singletonMap("id", output.getId()+"");
    Person idPerson = restTemplate.getForObject(BASE_URL+"/person/{id}", Person.class,vars);
    assertNotNull("no person",idPerson);
    assertNotNull(idPerson.getId());
    assertEquals(input.getUsername(), idPerson.getUsername());
    log.info("Get person by id <"+output.getId()+"> : "+idPerson.getUsername());
  }

}
</pre>
<p><strong>The configuration files</strong></p>
<p>The Spring annotation.xml</p>
<pre name="code" class='xml'>
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
	<!--
		Instruct Spring to perform declarative transaction management
		automatically on annotated classes.
	-->
	<tx:annotation-driven />
	<!--
		Activates various annotations to be detected in bean classes: Spring's
		@Required and @Autowired, as well as JSR 250's @PostConstruct,
		@PreDestroy and @Resource (if available) and JPA's @PersistenceContext
		and @PersistenceUnit (if available).
	-->
	<context:annotation-config />

	<!--
		Instruct Spring to retrieve and apply @AspectJ aspects which are
		defined as beans in this context (such as the UsageLogAspect below).
	-->
	<aop:aspectj-autoproxy />
</beans>
</pre>
<p>The JDBC settings jdbc.properties</p>
<pre name="code" class='xml'>
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/test
jdbc.username=test
jdbc.password=test
jdbc.initialPoolSize=5
jdbc.maxPoolSize=100
jdbc.minPoolSize=5
jdbc.maxStatementsPerConnection=25
jdbc.maxStatements=50
jpa.databasePlatform=org.hibernate.dialect.MySQL5InnoDBDialect
jpa.showSql=true
jdbc.schema=test
jdbc.dataTypeFactory=org.dbunit.ext.mysql.MySqlDataTypeFactory
jdbc.autoCommitOnClose=true
jdbc.autoCommit=true
hibernate.release_mode=after_transaction
hibernate.hbm2ddl=create
hibernate.auto_close_session=true
hibernate.current_session_context_class=thread
hibernate.flush_before_completion=true
</pre>
<p>The JAXB marshalling.xml</p>
<pre name="code" class='xml'>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
  xmlns:p="http://www.springframework.org/schema/p"
  xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
  xmlns:aop="http://www.springframework.org/schema/aop"
  xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-3.0.xsd

http://www.springframework.org/schema/tx

http://www.springframework.org/schema/tx/spring-tx-3.0.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-3.0.xsd

http://www.springframework.org/schema/jdbc

		   http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">

  <bean id="marshallingHttpMessageConverter"
    class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter"
    p:marshaller-ref="jaxb2Marshaller" p:unmarshaller-ref="jaxb2Marshaller" />

  <bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
        <value>de.schaeftlein.dev.spring.rest.domain.Person</value>
        <value>de.schaeftlein.dev.spring.rest.domain.People</value>
      </list>
    </property>
  </bean>

</beans>
</pre>
<p>The AOP based transactionAdvices.xml</p>
<pre name="code" class='xml'>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-3.0.xsd

http://www.springframework.org/schema/tx

http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

  <aop:config>
    <aop:pointcut id="serviceMethods"
            expression="execution(* dao.*Dao*.*(..))"/>
    <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethods"/>
  </aop:config>

  <tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
      <tx:method name="save*" propagation="REQUIRED"/>
      <tx:method name="get*" propagation="SUPPORTS" read-only="true"/>
    </tx:attributes>
  </tx:advice>

</beans>
</pre>
<p>The spring-dispatcher.xml</p>
<pre name="code" class='xml'>
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
  xmlns:p="http://www.springframework.org/schema/p"
  xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
  xmlns:aop="http://www.springframework.org/schema/aop"
  xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-3.0.xsd

http://www.springframework.org/schema/tx

http://www.springframework.org/schema/tx/spring-tx-3.0.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-3.0.xsd

http://www.springframework.org/schema/jdbc

		   http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">

  <import resource="transactionAdvices.xml" />
  <import resource="annotation.xml" />
  <import resource="marshalling.xml" />

  <bean
    class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />

  <bean
    class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
        <ref bean="marshallingHttpMessageConverter"/>
      </list>
    </property>
 </bean>

  <context:component-scan base-package="de.schaeftlein.dev.spring.rest.controller" />
</beans>
</pre>
<p>The spring-context.xml</p>
<pre name="code" class='xml'>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
	xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"
	xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-3.0.xsd

http://www.springframework.org/schema/tx

http://www.springframework.org/schema/tx/spring-tx-3.0.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-3.0.xsd

http://www.springframework.org/schema/jdbc

	http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">

	<import resource="transactionAdvices.xml" />
	<import resource="annotation.xml" />
	<import resource="marshalling.xml" />

   <context:component-scan base-package="de.schaeftlein.dev.spring.rest" />

	<context:component-scan base-package="com.smartpants.artwork" />

    <bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
<property name="messageConverters" ref="marshallingHttpMessageConverter"/>
    </bean>

	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass">
			<value>${jdbc.driverClassName}</value>
		</property>
<property name="jdbcUrl">
			<value>${jdbc.url}</value>
		</property>
<property name="user">
			<value>${jdbc.username}</value>
		</property>
<property name="password">
			<value>${jdbc.password}</value>
		</property>
<property name="autoCommitOnClose">
			<value>${jdbc.autoCommitOnClose}</value>
		</property>
<property name="initialPoolSize">
			<value>${jdbc.initialPoolSize}</value>
		</property>
<property name="maxPoolSize">
			<value>${jdbc.maxPoolSize}</value>
		</property>
<property name="minPoolSize">
			<value>${jdbc.minPoolSize}</value>
		</property>
<property name="maxStatementsPerConnection">
			<value>${jdbc.maxStatementsPerConnection}</value>
		</property>
<property name="maxStatements">
			<value>${jdbc.maxStatements}</value>
		</property>
	</bean>

	<bean id="propertyConfigurer"
		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
		p:location="classpath:jdbc.properties" />

	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
		p:dataSource-ref="dataSource" p:lobHandler-ref="defaultLobHandler"
		p:packagesToScan="de.schaeftlein.dev.spring.rest.domain">
<property name="hibernateProperties">
<props>
<prop key="hibernate.connection.url">${jdbc.url}</prop>
<prop key="hibernate.connection.driver_class">${jdbc.driverClassName}</prop>
<prop key="hibernate.connection.password">${jdbc.username} </prop>
<prop key="hibernate.connection.username">${jdbc.password}</prop>
<prop key="hibernate.connection.autocommit">${jdbc.autoCommit}</prop>
<prop key="hibernate.connection.release_mode">${hibernate.release_mode}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl}</prop>
<prop key="hibernate.transaction.auto_close_session">${hibernate.auto_close_session}</prop>
<prop key="hibernate.current_session_context_class">${hibernate.current_session_context_class}</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">false</prop>
<prop key="hibernate.bytecode.use_reflection_optimizer">false</prop>
<prop key="hibernate.bytecode.provider">javassist</prop>
<prop key="hibernate.transaction.flush_before_completion">${hibernate.flush_before_completion}</prop>
			</props>
		</property>
	</bean>

	<bean id="defaultLobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" />

	<bean id="transactionManager"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager"
		p:sessionFactory-ref="sessionFactory" />   

</beans>
</pre>
<p>The web.xml</p>
<pre name="code" class='xml'>
<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
  version="2.4">

  <display-name>spring3-rest-sample</display-name>
  <description>Spring 3 Rest sample</description>
  <distributable />

  <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-context.xml</param-value>
  </context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener
    </listener-class>
  </listener>

  <servlet>
    <servlet-name>springDispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-dispatcher.xml</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
  </servlet>

  <!--
    - Dispatcher servlet mapping for the web user interface
  -->
  <servlet-mapping>
    <servlet-name>springDispatcher</servlet-name>
    <url-pattern>/*</url-pattern>
  </servlet-mapping>

</web-app>
</pre>
<p>The Maven pom.xml</p>
<pre name="code" class='xml'>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>de.schaeftlein.dev.spring.rest</groupId>
	<artifactId>spring3-rest-sample</artifactId>
<packaging>war</packaging>
	<version>1.0-SNAPSHOT</version>
	<name>spring3-rest-sample Maven Webapp</name>
	<description>A sample project for showing how to write JUnit Test against Spring 3 Rest Services</description>
    <developers>
     <developer>
       <name>Ralf Schäftlein</name>
       <url>http://ralf.schaeftlein.com</url>
     </developer>
    </developers>
    <inceptionYear>2010</inceptionYear>
    <issueManagement>
      <system>bugzilla</system>
      <url>http://ubuntu-vm.localdomain/cgi-bin/bugzilla3/index.cgi</url>
    </issueManagement>
    <url>http://ralf.schaeftlein.de/2010/03/05/junit-tests-for-spring-3-rest-spring-3-rest-services</url>

	<reporting>
<plugins>
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-report-plugin</artifactId>
				<version>2.5</version>
			</plugin>
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-checkstyle-plugin</artifactId>
				<version>2.5</version>
			</plugin>
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-javadoc-plugin</artifactId>
				<version>2.6.1</version>
			</plugin>
<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>cobertura-maven-plugin</artifactId>
				<version>2.3</version>
			</plugin>
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-pmd-plugin</artifactId>
				<version>2.4</version>
				<configuration>
					<sourceEncoding>utf-8</sourceEncoding>
					<targetJdk>1.6</targetJdk>
				</configuration>
			</plugin>
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jxr-plugin</artifactId>
				<version>2.1</version>
				<configuration>
<inputEncoding>UTF-8</inputEncoding>
					<outputEncoding>UTF-8</outputEncoding>
				</configuration>
			</plugin>
<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>taglist-maven-plugin</artifactId>
				<version>2.4</version>
			</plugin>
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-changes-plugin</artifactId>
				<version>2.3</version>
				<reportSets>
					<reportSet>
						<reports>
							<report>changes-report</report>
						</reports>
					</reportSet>
				</reportSets>
			</plugin>
		</plugins>
	</reporting>
	<distributionManagement>
		<repository>
			<id>internal</id>
			<url>
				dav:http://ubuntu-vm.localdomain:8081/artifactory/internal
			</url>
		</repository>
		<snapshotRepository>
			<id>snapshots</id>
			<url>
				dav:http://ubuntu-vm.localdomain:8081/artifactory/snapshots
			</url>
		</snapshotRepository>
	</distributionManagement>
	<scm>
		<connection>
           scm:svn:http://ubuntu-vm.localdomain/svn/
       </connection>
		<developerConnection>
           scm:svn:http://ubuntu-vm.localdomain/svn/
       </developerConnection>
		<url>http://ubuntu-vm.localdomain/svn/</url>
	</scm>
	<ciManagement>
		<system>Hudson</system>
		<url>http://ubuntu-vm.localdomain/hudson/job/spring3-rest-sample</url>
	</ciManagement>
	<build>
		<finalName>spring3-rest-sample</finalName>
<plugins>
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-report-plugin</artifactId>
				<version>2.5</version>
			</plugin>
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-deploy-plugin</artifactId>
				<version>2.5</version>
			</plugin>
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>2.5</version>
				<configuration>
					<skip>true</skip>
				</configuration>
				<executions>
					<execution>
						<id>surefire-test</id>
<phase>test</phase>
						<goals>
							<goal>test</goal>
						</goals>
						<configuration>
							<skip>false</skip>
							<excludes>
								<exclude>**/itest/**</exclude>
							</excludes>
						</configuration>
					</execution>

					<execution>
						<id>surefire-itest</id>
<phase>integration-test</phase>
						<goals>
							<goal>test</goal>
						</goals>
						<configuration>
							<skip>false</skip>
							<includes>
								<include>**/itest/**</include>
							</includes>
						</configuration>
					</execution>
				</executions>
			</plugin>
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-pmd-plugin</artifactId>
				<version>2.4</version>
				<configuration>
					<sourceEncoding>utf-8</sourceEncoding>
					<targetJdk>1.6</targetJdk>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>check</goal>
							<goal>cpd-check</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>cobertura-maven-plugin</artifactId>
				<version>2.3</version>
				<configuration>
<formats>
<format>html</format>
<format>xml</format>
					</formats>
				</configuration>
			</plugin>
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jxr-plugin</artifactId>
				<version>2.1</version>
			</plugin>
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-checkstyle-plugin</artifactId>
				<version>2.5</version>
			</plugin>
<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.1</version>
				<configuration>
					<source>1.6</source>
					<target>1.6</target>
				</configuration>
			</plugin>
<plugin>
				<groupId>org.mortbay.jetty</groupId>
				<artifactId>maven-jetty-plugin</artifactId>
				<version>6.1.22</version>
				<configuration>
					<scanIntervalSeconds>10</scanIntervalSeconds>
					<stopKey>foo</stopKey>
					<stopPort>9999</stopPort>
					<contextPath>/${artifactId}</contextPath>
					<connectors>
						<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>9090</port>
							<maxIdleTime>60000</maxIdleTime>
						</connector>
					</connectors>
				</configuration>
				<executions>
					<execution>
						<id>start-jetty</id>
<phase>pre-integration-test</phase>
						<goals>
							<goal>run</goal>
						</goals>
						<configuration>
							<scanIntervalSeconds>0</scanIntervalSeconds>
							<daemon>true</daemon>
						</configuration>
					</execution>
					<execution>
						<id>stop-jetty</id>
<phase>post-integration-test</phase>
						<goals>
							<goal>stop</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-eclipse-plugin</artifactId>
				<version>2.8</version>
				<configuration>
					<downloadSources>true</downloadSources>
					<downloadJavadocs>true</downloadJavadocs>
					<wtpversion>2.0</wtpversion>
				</configuration>
			</plugin>
			<!--
				If you build jars the classpath of the referenced libraries will be
				added in the manifest.
			-->
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<version>2.3</version>
				<configuration>
					<archive>
						<manifest>
							<addClasspath>true</addClasspath>
						</manifest>
					</archive>
				</configuration>
			</plugin>
			<!-- if you build jars a source file will be built as well -->
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-source-plugin</artifactId>
				<version>2.1.1</version>
				<executions>
					<execution>
						<id>attach-sources</id>
<phase>verify</phase>
						<goals>
							<goal>jar</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-scm-plugin</artifactId>
				<version>1.3</version>
				<configuration>
					<username>${svn_username}</username>
<password>${svn_password}</password>
				</configuration>
			</plugin>
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-war-plugin</artifactId>
				<version>2.1-beta-1</version>
				<configuration>
					<warSourceDirectory>src/main/webapp</warSourceDirectory>
					<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
					<!-- we must exclude the svn folders -->
<packagingExcludes>
						<![CDATA[**/.svn,**/.svn/**,**/_svn,**/_svn/**]]&gt;
					</packagingExcludes>
					<archive>
						<manifest>
							<addClasspath>true</addClasspath>
							<classpathPrefix>lib/</classpathPrefix>
						</manifest>
					</archive>
				</configuration>
			</plugin>
		</plugins>
		<!-- we must exclude the svn folders -->
		<resources>
			<resource>
				<directory>src/main/resources</directory>
				<excludes>
					<exclude>**/.svn</exclude>
					<exclude>**/.svn/**</exclude>
					<exclude>**/_svn</exclude>
					<exclude>_svn</exclude>
					<exclude>**/_svn/**</exclude>
				</excludes>
			</resource>
		</resources>
		<testResources>
			<testResource>
				<directory>src/test/resources</directory>
				<excludes>
					<exclude>**/.svn</exclude>
					<exclude>**/.svn/**</exclude>
					<exclude>**/_svn</exclude>
					<exclude>_svn</exclude>
					<exclude>**/_svn/**</exclude>
				</excludes>
			</testResource>
		</testResources>
	</build>
<properties>
		<spring.framework.version>3.0.1.RELEASE</spring.framework.version>
		<org.slf4j.version>1.5.2</org.slf4j.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>

	<dependencies>
		<!--  AOP -->
		<dependency>
			<groupId>org.aspectj</groupId>
			<artifactId>aspectjweaver</artifactId>
			<version>1.6.2</version>
		</dependency>
		<dependency>
			<groupId>org.aspectj</groupId>
			<artifactId>aspectjrt</artifactId>
			<version>1.6.2</version>
		</dependency>
		<!-- Spring  -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-beans</artifactId>
			<version>${spring.framework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context-support</artifactId>
			<version>${spring.framework.version}</version>
			<exclusions>
				<exclusion>
					<groupId>quartz</groupId>
					<artifactId>quartz</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>${spring.framework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-aspects</artifactId>
			<version>${spring.framework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-jdbc</artifactId>
			<version>${spring.framework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-test</artifactId>
			<version>${spring.framework.version}</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-orm</artifactId>
			<version>${spring.framework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-oxm</artifactId>
			<version>${spring.framework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-tx</artifactId>
			<version>${spring.framework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
			<version>${spring.framework.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</artifactId>
			<version>${spring.framework.version}</version>
		</dependency>

		<!-- Hibernate -->
		<dependency>
			<groupId>cglib</groupId>
			<artifactId>cglib-nodep</artifactId>
			<version>2.1_3</version>
		</dependency>
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-annotations</artifactId>
			<version>3.2.0.ga</version>
		</dependency>
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate</artifactId>
			<version>3.2.6.ga</version>
		</dependency>
		<dependency>
			<groupId>javax.persistence</groupId>
			<artifactId>persistence-api</artifactId>
			<version>1.0</version>
		</dependency>
		<dependency>
			<groupId>javassist</groupId>
			<artifactId>javassist</artifactId>
			<version>3.11.0.GA</version>
		</dependency>

		<!-- Database -->
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>5.1.12</version>
			<type>jar</type>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>c3p0</groupId>
			<artifactId>c3p0</artifactId>
			<version>0.9.1.2</version>
			<type>jar</type>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>commons-dbcp</groupId>
			<artifactId>commons-dbcp</artifactId>
			<version>1.4</version>
		</dependency>
		<dependency>
			<groupId>commons-collections</groupId>
			<artifactId>commons-collections</artifactId>
			<version>3.2.1</version>
		</dependency>
		<dependency>
			<groupId>javax.transaction</groupId>
			<artifactId>jta</artifactId>
			<version>1.1</version>
		</dependency>

		<!-- JAXB -->
		<dependency>
			<groupId>javax.xml.bind</groupId>
			<artifactId>jaxb-api</artifactId>
			<version>2.0</version>
		</dependency>

		<!-- JUnit -->
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.8.1</version>
			<scope>test</scope>
		</dependency>
		<!--  logging -->
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
			<version>${org.slf4j.version}</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-simple</artifactId>
			<version>${org.slf4j.version}</version>
		</dependency>
		<!-- integration test -->
		<dependency>
			<groupId>org.mortbay.jetty</groupId>
			<artifactId>maven-jetty-plugin</artifactId>
			<version>6.1.15</version>
			<scope>test</scope>
		</dependency>

	</dependencies>
</project>
</pre>
<p><strong>Sample Content for Poster</strong></p>
<p>The person.xml</p>
<pre name="code" class='xml'>
<?xml version="1.0" encoding="UTF-8"?>
<person>
    <firstName>Jane</firstName>
    <lastName>Doe</lastName>
    <username>jane.doe</username>
<password>bar</password>
    <roleLevel>2</roleLevel>
</person>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ralf.schaeftlein.de/2010/03/05/junit-tests-for-spring-3-rest-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ide for testing JDK 7 features (Milestone 5: Build b76)</title>
		<link>http://ralf.schaeftlein.de/2009/11/23/ide-for-testing-jdk-1-7-features/</link>
		<comments>http://ralf.schaeftlein.de/2009/11/23/ide-for-testing-jdk-1-7-features/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 15:55:16 +0000</pubDate>
		<dc:creator>ralf</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[jdk 1.7]]></category>
		<category><![CDATA[netbeans]]></category>

		<guid isPermaLink="false">http://ralf.schaeftlein.de/?p=169</guid>
		<description><![CDATA[Sun has published milestone 5 (b76) of the upcoming Java JDK 7. JDK 7 release is currently scheduled for September 2010. My standard IDE is eclipse but the current production version 3.5 SR 1 support only Java up to JDK 6. I tried the new eclipse e4 1.0 milestone 2 (status: technical preview) which has [...]]]></description>
			<content:encoded><![CDATA[<p>Sun has published <a href="http://download.java.net/jdk7/m5/">milestone 5</a> (b76) of the upcoming Java JDK 7. JDK 7 release is currently <a href="http://mail.openjdk.java.net/pipermail/jdk7-dev/2009-November/001054.html">scheduled</a> for September 2010. My standard IDE is eclipse but the current production version <a href="http://www.eclipse.org/downloads/">3.5 SR 1</a> support only Java up to JDK 6. I tried the new <a href="http://download.eclipse.org/e4/downloads/drops/S-1.0M2-200911201200/index.html">eclipse e4 1.0 milestone 2</a> (status: technical preview) which has JDK support up to JDK 7. You can define a JDK 7 as new JRE and create a new Java project with that JRE and compiler compliance level JDK 1.7. According to <a href="http://blogs.sun.com/darcy/entry/project_coin_milestone_5_netbeans">Joseph Darcy</a> from SUN is a <a href="http://bertram.netbeans.org/hudson/job/jdk7/">developer build</a> of Netbeans available with support for JDK 7. I tested with code from <a href="http://www.certpal.com/blogs/2009/11/coding-with-jdk7/">CertPal</a> which includes several features of JDK 7. Eclipse e4 still complain about compiler errors but the developer build of netbeans can compile and run the sample code. Check in netbeans under tools -> Java platform the availability of JDK 7 and create a new java project. Set in the java project under properties the source/binary format to jdk 1.7 (sources tab) and choose as java platform JDK 1.7 (libraries tab). On OpenJDK is a <a href="http://openjdk.java.net//projects/jdk7/milestones/">overview</a> of the current implemented features of JDK 7 in the M5 version. Mark Reinhold from sun <a href="http://blogs.sun.com/mr/entry/jdk7_m5">blogs</a> as well about the new features. A more complete list of features which was formerly planned shows <a href="http://tech.puredanger.com/java7">Alex Miller</a> in his blog.</p>
]]></content:encoded>
			<wfw:commentRss>http://ralf.schaeftlein.de/2009/11/23/ide-for-testing-jdk-1-7-features/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring 3.0 RC 2 and JSR-330 (Dependency Injection for Java)</title>
		<link>http://ralf.schaeftlein.de/2009/11/19/spring-3-0-rc-2-and-jsr-330-dependency-injection-for-java/</link>
		<comments>http://ralf.schaeftlein.de/2009/11/19/spring-3-0-rc-2-and-jsr-330-dependency-injection-for-java/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 18:03:59 +0000</pubDate>
		<dc:creator>ralf</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[guice]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://ralf.schaeftlein.de/?p=159</guid>
		<description><![CDATA[SpringSource has published release candidate 2 of the upcoming 3.0 release of their Spring Framework. New Feature is the compliance with JSR-330 (&#8220;Dependency Injection for Java&#8221;). The JSR was developed together by Google (for their Guice Framework and SpringSource (for their Spring Framework) and is finally approved since 14.10.2009.
A little example shows how to develop [...]]]></description>
			<content:encoded><![CDATA[<p>SpringSource has <a href="http://blog.springsource.com/2009/11/13/spring-framework-3-0-rc2-released/">published</a> release candidate 2 of the upcoming 3.0 release of their Spring Framework. New Feature is the compliance with <a href="http://jcp.org/en/jsr/detail?id=330">JSR-330</a> (&#8220;Dependency Injection for Java&#8221;). The JSR was developed together by Google (for their <a href="http://code.google.com/p/google-guice/">Guice</a> Framework and SpringSource (for their <a href="http://www.springsource.org/documentation">Spring Framework</a>) and is finally approved since 14.10.2009.</p>
<p>A little example shows how to develop services with interfaces and implementations without dependencies to Spring Framework or Google Guice: </p>
<p>
The Maven pom.xml</p>
<pre name="code" class='xml'>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>de.schaeftlein.dev</groupId>
	<artifactId>jsr330-sample</artifactId>
<packaging>jar</packaging>
	<name>jsr330-sample</name>
	<version>0.0.1-SNAPSHOT</version>
	<description>Sample App with Spring 3.0 RC 2 and JSR330</description>
<properties>
		<springVersion>3.0.0.RC2</springVersion>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>${springVersion}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-beans</artifactId>
			<version>${springVersion}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>${springVersion}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-asm</artifactId>
			<version>${springVersion}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-expression</artifactId>
			<version>${springVersion}</version>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.7</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>javax.inject</groupId>
			<artifactId>javax.inject</artifactId>
			<version>1</version>
		</dependency>
	</dependencies>
	<build>
		<finalName>jsr330-sample</finalName>
		<sourceDirectory>src/main/java</sourceDirectory>
		<testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>

		<!-- we must exclude the svn folders -->
		<resources>
			<resource>
				<directory>src/main/resources</directory>
				<excludes>
					<exclude>**/.svn</exclude>
					<exclude>**/.svn/**</exclude>
					<exclude>**/_svn</exclude>
					<exclude>_svn</exclude>
					<exclude>**/_svn/**</exclude>
				</excludes>
			</resource>
		</resources>
		<testResources>
			<testResource>
				<directory>src/test/resources</directory>
				<excludes>
					<exclude>**/.svn</exclude>
					<exclude>**/.svn/**</exclude>
					<exclude>**/_svn</exclude>
					<exclude>_svn</exclude>
					<exclude>**/_svn/**</exclude>
				</excludes>
			</testResource>
		</testResources>
<plugins>
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.6</source>
					<target>1.6</target>
				</configuration>
			</plugin>
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-eclipse-plugin</artifactId>
				<configuration>
					<downloadJavadocs>true</downloadJavadocs>
					<downloadSources>true</downloadSources>
					<excludes>
						<exclude>_svn</exclude>
						<exclude>.svn</exclude>
					</excludes>
				</configuration>
			</plugin>
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<configuration>
					<archive>
						<manifest>
							<addClasspath>true</addClasspath>
						</manifest>
					</archive>
				</configuration>
			</plugin>
			<!-- if you build jars a source file will be built as well -->
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-source-plugin</artifactId>
				<executions>
					<execution>
						<id>attach-sources</id>
<phase>verify</phase>
						<goals>
							<goal>jar</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>
</pre>
<p>
a simple encode/decode interface<br />
<P></p>
<pre name="code" class='java'>
package de.schaeftlein.dev.spring;

public interface Encryption
{
  String encode(String value);
  String decode(String value);
}
</pre>
<p>
a simple implementation for Encryption</p>
<p><pre name="code" class='java'>
package de.schaeftlein.dev.spring;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

import javax.inject.Named;

@Named // service name is the name of the class
public class URLEncoderEncyrption implements Encryption
{

  @Override
  public String decode(String value)
  {
    try
    {
      return URLDecoder.decode(value, "UTF-8");
    }
    catch (UnsupportedEncodingException e)
    {
      return null; // never happen
    }
  }

  @Override
  public String encode(String value)
  {
    try
    {
      return URLEncoder.encode(value, "UTF-8");
    }
    catch (UnsupportedEncodingException e)
    {
      return null; // never happen
    }
  }

}
</pre>
<p>
a more secure implementation for Encryption</p>
<p><pre name="code" class='java'>
package de.schaeftlein.dev.spring;

import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import javax.inject.Named;

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

import com.sun.org.apache.xml.internal.security.utils.Base64;

@Named("secure") // named service bean
public class Base64Encyption implements Encryption
{
  private sun.misc.BASE64Encoder base64encoder;
  private SecretKey key;

  public Base64Encyption()
  {
    try
    {
      DESKeySpec keySpec = new DESKeySpec("Your secret Key phrase".getBytes("UTF8"));
      SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
      key = keyFactory.generateSecret(keySpec);
      base64encoder = new BASE64Encoder();
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
  }

  @Override
  public String decode(String input)
  {
    try
    {
      Cipher cipher = Cipher.getInstance("DES"); // cipher is not thread safe
      cipher.init(Cipher.DECRYPT_MODE, key);
      byte[] bOut = cipher.doFinal(Base64.decode(input.getBytes("UTF-8")));
      return new String(bOut, "UTF-8");
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
    return null;
  }

  @Override
  public String encode(String plainTextPassword)
  {
    try
    {
      byte[] cleartext = plainTextPassword.getBytes("UTF8");

      Cipher cipher = Cipher.getInstance("DES"); // cipher is not thread safe
      cipher.init(Cipher.ENCRYPT_MODE, key);
      return base64encoder.encode(cipher.doFinal(cleartext));
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
    return null;
  }

}
</pre>
<p>
a small interface for a service</p>
<p><pre name="code" class='java'>
package de.schaeftlein.dev.spring;

public interface SecureUtil
{
  void compareEncryption(String input);
}
</pre>
<p>
a implementation for our service</p>
<p><pre name="code" class='java'>
package de.schaeftlein.dev.spring;

import javax.inject.Inject;
import javax.inject.Named;

@Named("SecureUtil")
public class SecureUtilImpl implements SecureUtil
{
  @Inject // automatically set by DI framework
  @Named("secure") // get the namend bean
  private Encryption secureEncryption;

  @Inject // automatically set by DI framework
  @Named("URLEncoderEncyrption") // get the bean by its classname
  private Encryption unsecureEncryption;

  public void compareEncryption(String input){

    String encodedSecure = secureEncryption.encode(input);
    System.out.println("Secure encoded: "+encodedSecure);
    String encodeUnsecure = unsecureEncryption.encode(input);
    System.out.println("Unsecure encoded: "+encodeUnsecure);
    System.out.println("Secure decoded: "+secureEncryption.decode(encodedSecure));
    System.out.println("Unsecure decoded: "+unsecureEncryption.decode(encodeUnsecure));
  }
}
</pre>
<p>
finally a main class for testing</p>
<p><pre name="code" class='java'>
package de.schaeftlein.dev.spring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class Main
{

  /**
   * main method
   */
  public static void main(String[] args)
  {
    ApplicationContext ctx = new AnnotationConfigApplicationContext(Main.class.getPackage().getName()); // new way to get Application context without applicationContext.xml available
    SecureUtil util = ctx.getBean("SecureUtil", SecureUtil.class); // get bean with new generics method
    util.compareEncryption("an sample input string 1234567890");
  }

}
</pre>
<p>
output of our Main class</p>
<p><pre name="code" class='java'>
19.11.2009 18:56:03 org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@c1b531: startup date [Thu Nov 19 18:56:03 CET 2009]; root of context hierarchy
19.11.2009 18:56:03 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor <init>
INFO: JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
19.11.2009 18:56:03 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@a83b8a: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,secure,SecureUtil,URLEncoderEncyrption]; root of factory hierarchy
Secure encoded: QDQvd4uK14YNUQ4uoqhqsZEMDDxUqJAMyisvZr2wsA2GyMC5tSEIiw==
Unsecure encoded: an+sample+input+string+1234567890
Secure decoded: an sample input string 1234567890
Unsecure decoded: an sample input string 1234567890
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ralf.schaeftlein.de/2009/11/19/spring-3-0-rc-2-and-jsr-330-dependency-injection-for-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chrome OS 0.4.237 beta under vmware server 2.x</title>
		<link>http://ralf.schaeftlein.de/2009/11/17/chrome-os-0-4-237-beta-under-vmware-server-2-x/</link>
		<comments>http://ralf.schaeftlein.de/2009/11/17/chrome-os-0-4-237-beta-under-vmware-server-2-x/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 12:12:56 +0000</pubDate>
		<dc:creator>ralf</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[os]]></category>
		<category><![CDATA[chromeos]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://ralf.schaeftlein.de/?p=145</guid>
		<description><![CDATA[A beta version of Chrome OS is available as VMX/VMDK image for vmware or virtualbox and live cd. Chrome OS is a OpenSuSe based operating system around the Google Chrome browser. 
Steps to test VM image of chrome os beta

Download VMDK image
Extract tar.gz File to standard folder of vmware
Start vmware server
Choose from &#8220;Virtual machine&#8221; menu [...]]]></description>
			<content:encoded><![CDATA[<p>A beta version of Chrome OS is <a href="http://getchrome.eu/download.php">available</a> as VMX/VMDK image for vmware or virtualbox and live cd. Chrome OS is a OpenSuSe based operating system around the Google <a href="http://www.google.com/chrome">Chrome</a> browser. </p>
<p>Steps to test VM image of chrome os beta</p>
<ol>
<li>Download VMDK image</li>
<li>Extract tar.gz File to standard folder of vmware</li>
<li>Start vmware server</li>
<li>Choose from &#8220;Virtual machine&#8221; menu &#8220;add Virtual machine to inventory&#8221;</li>
<li>Choose VMX file inside extracted image of chrome os</li>
<li>Upgrade Virtual machine to newest &#8220;hardware&#8221; by choosing link on right side from the vm summary page</li>
<li>Remove Network Connection from VM and Add new one with &#8220;Add Hardware&#8221; and type &#8220;Network Adapter&#8221; with &#8220;Nat&#8221; mode</li>
<li>Boot VM and cornfirm warning about IDE geometry and scsi controller</li>
<li>Click on &#8220;Make Goggle chrome default browser&#8221; and confirm dialog</li>
<li>Click on computer button (down left side) and click under status on network connection</li>
<li>Enter root password: <strong>root</strong></li>
<li>confirm warning about network manager with ok</li>
<li>Choose under &#8220;Global Options&#8221; network setup method &#8220;traditional method with ifup&#8221;</li>
<li>Go to &#8220;Overview&#8221; tab and click on &#8220;edit&#8221; button below</li>
<li>click on &#8220;next&#8221; button</li>
<li>go back to &#8220;global options&#8221; and change back to &#8220;user controlled with networkmanager&#8221;</li>
<li>Reboot machine by clicking on computer and shutdown with type reboot</li>
<li>After reboot you can surf with google chrome without any problem</li>
</ol>
<p><img src="http://ralf.schaeftlein.de/wp-content/uploads/2009/11/chrome_os1-300x241.jpg" alt="chrome_os" title="chrome_os" width="300" height="241" class="aligncenter size-medium wp-image-152" /></p>
]]></content:encoded>
			<wfw:commentRss>http://ralf.schaeftlein.de/2009/11/17/chrome-os-0-4-237-beta-under-vmware-server-2-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert VMWare 2.x Image to VirtualBox 3.x (seamless mode)</title>
		<link>http://ralf.schaeftlein.de/2009/11/15/convert-vmware-2-x-image-to-virtualbox-3-x-seamless-mode/</link>
		<comments>http://ralf.schaeftlein.de/2009/11/15/convert-vmware-2-x-image-to-virtualbox-3-x-seamless-mode/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 15:54:20 +0000</pubDate>
		<dc:creator>ralf</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[virtualbox]]></category>
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://ralf.schaeftlein.de/?p=120</guid>
		<description><![CDATA[Windows 7 Home Premium has no XP Mode Feature like in Pro or Ultimate Edition to run an Windows XP virtual machine seamless. Home Premium can be upgraded by Anytime Upgrade within Windows to Professional or Ultimate (90$* or 140$*). You need at least Professional Version for XP Mode. So i looked for alternatives. Under [...]]]></description>
			<content:encoded><![CDATA[<p>Windows 7 Home Premium has no <a href="http://www.microsoft.com/windows/virtual-pc/">XP Mode</a> Feature like in Pro or Ultimate Edition to run an Windows XP virtual machine seamless. Home Premium can be upgraded by Anytime Upgrade within Windows to Professional or Ultimate (<a href="http://windowsteamblog.com/blogs/windows7/archive/2009/07/31/windows-anytime-upgrade-and-family-pack-pricing.aspx">90$* or 140$*</a>). You need at least Professional Version for XP Mode. So i looked for alternatives. Under Windows XP was <a href="http://www.vmware.com/de/products/server/">VMWare server 2.x</a> my first choice without seamless mode. Seamless Mode made VM windows be available in host OS as &#8220;normal&#8221; windows without the rest of the VM OS. One Alternative is <a href="http://www.vmware.com/de/products/ws/">VMWare Workstation 7</a> with seamless mode (176€*). Paralells has currently an <a href="http://www.parallels.com/de/products/xptowin7migration/">beta version</a> available with Coherence (seamless) feature. <a href="http://www.virtualbox.org/">Virtualbox</a> as open source alternative has seamless mode too. You need only to install the guest additions of virtualbox, reboot after installation and call from menu &#8220;seamless mode&#8221;. </p>
<p>So i give Virtualbox a try and installed the current <a href="http://www.virtualbox.org/wiki/Downloads">3.0.10</a> version under Windows 7. VirtualBox can work with VMware VMDK Hard disks out of the box. </p>
<p>Steps to convert from VMware to Virtualbox:</p>
<ol>
<li>Start VMware image under VMware</li>
<li>Uninstall VMware Tools inside VM</li>
<li>Shutdown VM</li>
<li>Open DOS command shell in VM folder</li>
<li>set path variable to include VMWare server folder: set path=<you path>;%PATH%</li>
<li>convert splitted VM hard disk to single file: vmware-vdiskmanager -r source_multiples.vmdk -t 2 single_file.vmdk (use &#8221; to surround file name if file name contains spaces)</li>
<li>copy new single_file.vmdk and single_file-flat.vmdk  to <virtualbox vm folder>\harddisks on host os with virtualbox</li>
<li>Start VirtualBox under host OS</li>
<li>Open in file menu &#8220;Virtual media manager&#8221;</li>
<li>Go to &#8220;Hard Disks&#8221; tab</li>
<li>Click on Add Button and choose single_file.vmdk</li>
<li>Close dialog with OK button</li>
<li>Click on &#8220;New&#8221; button to create a new VM</li>
<li>Click on &#8220;Next&#8221; button</li>
<li>Enter name for new VM  and choose operation system including version (in my example Win_vista&#8221; as name, &#8220;Microsoft Windows&#8221; as OS and &#8220;Windows Vista&#8221; as version)</li>
<li>Set memory to a suitable value (on my machine i prefer 512MB for good enough performance)</li>
<li>On the next page choose &#8220;Use existing hard disk&#8221; and select from Drop down the old VMware hard disk image</li>
<li>Click on Finish</li>
<li>Open Settings of new VM to correct problems with different hard ware in VMware and VirtualBox</li>
<li>Go to System => Motherboard and &#8220;enable IO APIC&#8221;</li>
<li>a had an scsci lsi logic controller under VMware: Go to &#8220;Hard Disks&#8221; and &#8220;Enable Additional Controller&#8221; including selection of &#8220;SCSI (Lsilogic)&#8221;s
<li>Start new VM</li>
<li>Install Virtualbox guest additions from vm window menu under &#8220;Devices&#8221;</li>
<li>reboot vm</li>
<li>Start for example a IE windows inside vm and call from &#8220;Machine&#8221; menu  &#8220;seamless mode&#8221;
</ol>
<p>Currently that doesn&#8217;t seems to work with windows vista. Another VM in virtualbox with windows XP Professional works as expected in seamless mode.</p>
<p>Keep in mind that such a migration with Windows Vista as guest os needs another activation because of changed multiple hardware components. </p>
<p>Another possibility is to install the unofficial Virtual PC 6.1 for windows 7 from the knowledge base (<a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=2b6d5c18-1441-47ea-8309-2545b08e11dd&#038;DisplayLang=de">32bit</a> / <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=2b6d5c18-1441-47ea-8309-2545b08e11dd&#038;DisplayLang=de">64bit</a>). As described <a href="http://www.drwindows.de/windows-anleitungen-und-faq/15606-windows-7-xp-modus-fuer-home-versionen.html">here</a> you see in the windows 7 start menu the entries of the installed programs under the xp vm to start them directly in seamless mode. Comparing to the windows 7 XP mode their is the requirement for a separate windows xp license for a windows home or starter host os. Windows 7 professional or ultimate include such a license for a virtual windows xp on the same machine. Virtual PC needs a Virtualization hardware support like intel VT-X or AMD-V. The installation of Virtual PC fails if the processor and mainboard don&#8217;t fit to this requirement.</p>
<p>Startmenu entry of Virtual PC</p>
<p><img src="http://ralf.schaeftlein.de/wp-content/uploads/2009/11/virtual_pc1.jpg" alt="Startmenue Virtual PC" title="Startmenue Virtual PC" width="467" height="226" class="alignnone size-full wp-image-138" /></p>
<p>Start installed Apps inside XP VM from Windows 7</p>
<p><img src="http://ralf.schaeftlein.de/wp-content/uploads/2009/11/virtual_pc2.jpg" alt="Start Apps inside XP VM from Windows 7" title="Start Apps inside XP VM from Windows 7" width="551" height="181" class="alignnone size-full wp-image-139" /></p>
<p>Seamless started XP VM Application under Windows 7</p>
<p><img src="http://ralf.schaeftlein.de/wp-content/uploads/2009/11/virtual_pc3-150x150.jpg" alt="Seamless started App" title="Seamless started App" width="150" height="150" class="alignnone size-thumbnail wp-image-141" /></p>
<p><strong>*Price are only snapshots from the manufacturer websites without any guarantee and only provided to compare the possibilities.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://ralf.schaeftlein.de/2009/11/15/convert-vmware-2-x-image-to-virtualbox-3-x-seamless-mode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ANT -version still shows 1.6.5 with installed version 1.7.x&#8230;</title>
		<link>http://ralf.schaeftlein.de/2009/10/15/ant-version-still-shows-1-6-5-with-installed-version-1-7-x/</link>
		<comments>http://ralf.schaeftlein.de/2009/10/15/ant-version-still-shows-1-6-5-with-installed-version-1-7-x/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 12:31:45 +0000</pubDate>
		<dc:creator>ralf</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://ralf.schaeftlein.de/?p=116</guid>
		<description><![CDATA[Upgrading ant was in the past no big deal. Just download the binary archive, extract it and adopt the ANT_HOME environment variable. ANT_HOME is set to the extracted folder and PATH contains a entry %ANT_HOME%\bin. So PATH  does not need to change during an ant update. I&#8217;m recently updated from ANT 1.6.5 to 1.7.1. [...]]]></description>
			<content:encoded><![CDATA[<p>Upgrading ant was in the past no big deal. Just download the binary archive, extract it and adopt the ANT_HOME environment variable. ANT_HOME is set to the extracted folder and PATH contains a entry %ANT_HOME%\bin. So PATH  does not need to change during an ant update. I&#8217;m recently updated from ANT 1.6.5 to 1.7.1. and was a bit suprised by the output of ant -version. It still shows 1.6.5 as version. I checked the environment variables but everything was fine. The problem is that ANT batch files look in different folders according to the <a href="http://ant.apache.org/manual/running.html#libs">manual</a>. Prior to the ANT_HOME\lib folder will be the files in USER_HOME\.ant\lib be added to the classpath. This user home folder was on my machine still filled up with the jars from the 1.6.5 release. After deleting the contents show ant now the correct version. I understand the purpose of having additional libs available for own used tasks but the result behavior was annoying.   </p>
]]></content:encoded>
			<wfw:commentRss>http://ralf.schaeftlein.de/2009/10/15/ant-version-still-shows-1-6-5-with-installed-version-1-7-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get rid of annoying SHIFT-R and SHIFT-A hints on images</title>
		<link>http://ralf.schaeftlein.de/2009/07/30/get-rid-of-annoying-shift-r-and-shift-a-hints-on-images/</link>
		<comments>http://ralf.schaeftlein.de/2009/07/30/get-rid-of-annoying-shift-r-and-shift-a-hints-on-images/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 19:48:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[internet]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[t-mobile]]></category>
		<category><![CDATA[umts]]></category>
		<category><![CDATA[vodafone]]></category>

		<guid isPermaLink="false">http://ralf.schaeftlein.de/?p=113</guid>
		<description><![CDATA[Either Vodafone and T-Mobile use hidden picture compressions and remove alt text inside web pages when you surf with a UMTS stick. The traffic goes through a transparent proxy with that &#8220;feature&#8221;. Pictures inside browsers have less quality. Most annoying for me is that if you browse on geocaching.com for Geocaches on a map. You [...]]]></description>
			<content:encoded><![CDATA[<p>Either Vodafone and T-Mobile use hidden picture compressions and remove alt text inside web pages when you surf with a UMTS stick. The traffic goes through a transparent proxy with that &#8220;feature&#8221;. Pictures inside browsers have less quality. Most annoying for me is that if you browse on <a href="http://www.geocaching.com">geocaching.com</a> for Geocaches on a map. You see normally the name of the cache if your mouse goes over the cache icon on the map. With a mobile internet connection you see a hint that &#8220;Shift-R improves quality of that picture and SHIFT-A improves the quality of all picture on that page&#8221;. A solution for this is a firefox plugin called: &#8220;<a href="https://addons.mozilla.org/en-US/firefox/addon/967">Modify Headers</a>&#8220;.  Go to the extras menu and open &#8220;Modify Headers&#8221; entry. Enter a new rule and in the first field (Name) &#8220;Cache-Control&#8221; and in the second field &#8220;no-cache&#8221; (Value). Save the rule and enable them. Restart the browser. Now reopen with firefox a page with pictures. Quality as with normal internet connections and no more annoying hints to improve quality. In geocaching.com maps will now the name of the cache presented as expected.  </p>
]]></content:encoded>
			<wfw:commentRss>http://ralf.schaeftlein.de/2009/07/30/get-rid-of-annoying-shift-r-and-shift-a-hints-on-images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Migrating Microsoft Virtual Server/PC image to VMware Server</title>
		<link>http://ralf.schaeftlein.de/2009/07/01/migrating-microsoft-virtual-serverpc-image-to-vmware-server/</link>
		<comments>http://ralf.schaeftlein.de/2009/07/01/migrating-microsoft-virtual-serverpc-image-to-vmware-server/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 05:12:15 +0000</pubDate>
		<dc:creator>ralf</dc:creator>
				<category><![CDATA[os]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[ldap]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[virtualbox]]></category>
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://ralf.schaeftlein.de/?p=109</guid>
		<description><![CDATA[Microsoft has for free the Virtual Server or Virtual PC 2007 SP 1 as virtualization software. I wanted to test Microsoft Windows 2003 R2 Server. On the Virtual Appliance Marketplace at VMware is only a VHD from Microsoft available. A VHD is the Microsoft vm image type. I installed the Microsoft Virtual Server and had [...]]]></description>
			<content:encoded><![CDATA[<p>Microsoft has for free the <a href="http://www.microsoft.com/downloads/details.aspx?familyid=BC49C7C8-4840-4E67-8DC4-1E6E218ACCE4&#038;displaylang=en">Virtual Server</a> or <a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&#038;FamilyID=28c97d22-6eb8-4a09-a7f7-f6c7a1f000b5">Virtual PC 2007 SP 1</a> as virtualization software. I wanted to test Microsoft Windows 2003 R2 Server. On the Virtual Appliance Marketplace at VMware is only a <a href="http://www.vmware.com/appliances/directory/649">VHD</a> from Microsoft available. A VHD is the Microsoft vm image type. I installed the Microsoft Virtual Server and had no luck to start the vhd image successfully. Virtual PC 2007 works instead. I can start the VM and configure this vm server as active directory, DNS and WINS server like described in this <a href="http://www.msxforum.de/modules/smartfaq/faq.php?faqid=119">howto</a>. The networking functionality in Microsoft Virtual Server/PC is a pain in my ass. For active directory and dns server is a fixed ip configured inside the vm. No clue on which ip i can reach my vm from the host system. Sun <a href="http://www.virtualbox.org/">virtualbox</a> works in that aspect more like expected. You can switch between NAT and hostonly mode. With the host only networking mode has the VM a fixed ip inside the host system. So far so good. I tested this with a ubuntu 9.04 server as guest os inside virtualbox. For updates you need to shutdown, reconfigure to use NAT and start the vm again. In NAT mode is the vm only accessible via the virtualbox window. You have to define each port <a href="http://tombuntu.com/index.php/2008/12/17/configure-port-forwarding-to-a-virtualbox-guest-os/">manually</a> if you want to access the NAT vm from outside the virtualbox. Typically i use such a vm ubuntu server as subversion, maven artifactory, &#8230; server for development. <a href="http://www.vmware.com/products/server/">VMware server 2.x</a> works for me like expected. NAT networking to have internet access from the guest os and full access on all ports from the hostsystem. The guest os see a DHCP networking interface and the host os has a fixed ip to access the vm. So how do i get the 30 days trial edition from Microsoft Windows 2003 server get to run inside VMware server? After setting up the server inside Virtual PC you had to remove the Virtual Machine additions via the menu. This additions are not available as software package inside the software overview in windows 2003 server. Now shutdown the guest os and close virtual pc. With the <a href="http://info.vmware.com/content/VMware_Converter">VMWare vCenter Converter 3.0.3 (Starter Edition)</a> you can convert the VHD to a VMX image for VMWare Server or Player. Select in the last step of the wizard to remove all checkpoints inside the guest os, to install VMWare tools and to setup the networking interface (NAT on one instead of two nic). The VHD image has 1,5 GB and needs on my laptop round about 1h to convert. After that i can start VMWare server and register this new guest os image. The converter has set the type correct to MS Windows 2003 server 32bit. A little bit annoying is that my bluetooth connected mouse works perfect inside Virtual PC but not out of the box inside the VMWare window <img src='http://ralf.schaeftlein.de/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' />  So i grabbed my old usb mouse to have a running mouse. With the Sysinternals <a href="http://technet.microsoft.com/de-de/sysinternals/bb963907.aspx">ADExplorer</a> i can examine my new active directory from my host os. Inside eclipse 3.5 is <a href="http://directory.apache.org/studio/">Apache Directory Studio</a> a good choice to to access the AD via LDAP. </p>
]]></content:encoded>
			<wfw:commentRss>http://ralf.schaeftlein.de/2009/07/01/migrating-microsoft-virtual-serverpc-image-to-vmware-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First experiences with windows 7 rc</title>
		<link>http://ralf.schaeftlein.de/2009/05/26/first-experiences-with-software-under-windows-7/</link>
		<comments>http://ralf.schaeftlein.de/2009/05/26/first-experiences-with-software-under-windows-7/#comments</comments>
		<pubDate>Tue, 26 May 2009 19:59:13 +0000</pubDate>
		<dc:creator>ralf</dc:creator>
				<category><![CDATA[Home]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[windows 7 rc]]></category>

		<guid isPermaLink="false">http://ralf.schaeftlein.de/?p=99</guid>
		<description><![CDATA[The good news is that most of the common used software works. So far i install only the necessary software for such a netbook. No video editing, development tools, ide,&#8230; 
Software which works

Winscp
Putty
Firefox 3
Office 2003
Notepad++
Thunderbird 2
7-zip
Acrobat Reader
Irfanview
VLC
Openoffice 3.1
Flash under Firefox

Flash under IE8 work only with a trick. The direct download or installation from adobe.com does [...]]]></description>
			<content:encoded><![CDATA[<p>The good news is that most of the common used software works. So far i install only the necessary software for such a netbook. No video editing, development tools, ide,&#8230; </p>
<p><strong>Software which works</strong></p>
<ul>
<li><a href="http://winscp.net/eng/download.php">Winscp</a></li>
<li><a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">Putty</a></li>
<li>Firefox 3</li>
<li>Office 2003</li>
<li><a href="http://sourceforge.net/project/showfiles.php?group_id=95717&#038;package_id=102072">Notepad++</a></li>
<li>Thunderbird 2</li>
<li><a href="http://www.7-zip.org/">7-zip</a></li>
<li>Acrobat Reader</li>
<li><a href="http://www.irfanview.com/">Irfanview</a></li>
<li><a href="http://www.videolan.org/vlc/download-windows.html">VLC</a></li>
<li><a href="http://download.openoffice.org/index.html">Openoffice</a> 3.1</li>
<li><a href="http://get.adobe.com/de/flashplayer/otherversions/">Flash</a> under Firefox</li>
</ul>
<p>Flash under IE8 work only with a trick. The direct download or installation from adobe.com does not work. Via PCWelt is the install exe as well <a href="http://www.pcwelt.de/downloads/browser_netz/internet-tools/65302/adobe_flash_player/">available</a>. Save the file and start the installation. Et voila.</p>
<p>The Samsung has no built in bluetooth device. I bought a ultra small usb <a href="http://www.trust-site.com/products/product.aspx?artnr=16008">Trust bluetooth 2.1 adapter</a>. Windows 7 RC recognize most but not all functionality. The broadcom <a href="http://www.broadcom.com/support/bluetooth/update.php">driver</a> for Vista works perfect. After that i can install the <a href="http://europe.nokia.com/pcsuite">Nokia PC Suite</a> 7.1 and access my Nokia N95 successfully.</p>
]]></content:encoded>
			<wfw:commentRss>http://ralf.schaeftlein.de/2009/05/26/first-experiences-with-software-under-windows-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows 7 RC on Samsung NC10</title>
		<link>http://ralf.schaeftlein.de/2009/05/25/windows-7-rc-on-samsung-nc10/</link>
		<comments>http://ralf.schaeftlein.de/2009/05/25/windows-7-rc-on-samsung-nc10/#comments</comments>
		<pubDate>Mon, 25 May 2009 05:53:01 +0000</pubDate>
		<dc:creator>ralf</dc:creator>
				<category><![CDATA[Home]]></category>
		<category><![CDATA[netbook]]></category>
		<category><![CDATA[samsung nc 10]]></category>
		<category><![CDATA[windows 7 rc]]></category>

		<guid isPermaLink="false">http://ralf.schaeftlein.de/?p=91</guid>
		<description><![CDATA[The Samsung netbook shipped with pre installed Windows XP and 1GB RAM. After upgrading to 2GB RAM and good tests of Windows 7 RC under Virtualbox and VMware i feel safe to install Windows 7 RC. I made under the running XP all available updates including bios firmware. My RAM dealer told me about a [...]]]></description>
			<content:encoded><![CDATA[<p>The Samsung netbook shipped with pre installed Windows XP and 1GB RAM. After upgrading to 2GB RAM and good tests of Windows 7 RC under Virtualbox and VMware i feel safe to install <a href="http://www.microsoft.com/germany/windows/windows-7/download.aspx">Windows 7 RC</a>. I made under the running XP all available updates including bios firmware. My RAM dealer told me about a other customer with non bootable netbook after upgrading under windows 7. You need a USB Stick to extract the iso to it and boot from it like described <a href="http://www.necron.mcseboard.de/2009/05/07/installation-von-windows-7-rc-auf-dem-nc10/">here</a>. Reboot the netbook and press F2 to enter the BIOS for changing the boot order. Push the &#8220;USB HDD&#8221; over the internal HDD and press F10 for &#8220;save and exit&#8221;. Insert the stick and enter the setup of windows 7 RC. The installation works perfect and nearly all hardware works out of the box. Windows update updates the lan,wlan and graphics driver. My netbook has a built in UTMS modem which is not recognized out of the box. Under XP are two possibility to establish HSPDA connections with the internal UMTS modem: Vodafone Dashboard or the Samsung Connectionmanager. I tried from samsung.de the XP version with no luck. The polish Samsung website has a newer working <a href="http://www.prometeo.de/2009/05/windows-7-rc-mit-samsung-nc10-umts-treiber/">version</a>. Another problem was the touchpad. Windows recognize only a PS/2 mouse&#8230; The vista driver from the synaptic download <a href="http://www.synaptics.com/support/drivers">site</a> works well. Good first place to look is the &#8220;troubleshoot compatibility&#8221; entry in context menu of each executeable. Set their the requirement to use Admin rights and Vista or XP (in that order) compatibility. The connectionmanager works only with Vista OS and Admin rights settings. WLAN at home was no problem. No jumps or quirks has to be done to establish a WPA2 AES connection.</p>
<p>I use AVG Antivir Free edition as antivirus solution. The newly maintenance center offers online a page with working products. Microsoft links directly to AVG Antivirus. AVG Antivir Free works as well with the limitation that windows is not informed about the state of virus definitions. You can disable this additional check inside the maintenance center to avoid further warnings about a maybe outdated antivirus solution. I tried inside Virtualbox Kapersky as trial which has a perfect integration. </p>
<p>Windows 7 RC compared to Vista is much faster. Even on a netbook will the Aero extension work. Other programs or windows get a glass l&#038;f if you swith with the tab key through the runnning programs. The taskbar shows the running IE 8 including the possibility to navigate directly to the open tabs. Download progress is shown as a green filling taskbar icon. </p>
<p>Most software seems to run like Office 2003, Notepad++, 7-Zip or firefox. </p>
<p>Overall is the Samsung NC10 a good choice as netbook with the non glare display and the long running battery with 3-4h capicity.</p>
]]></content:encoded>
			<wfw:commentRss>http://ralf.schaeftlein.de/2009/05/25/windows-7-rc-on-samsung-nc10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
