Wednesday, October 19, 2011

Gradle remote debug for java

Type:
export GRADLE_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y"


Run your gradle commands as normal and hook up on port 4000 to remote debug your app.

E.g. ./gradlew jettyRun

Monday, June 6, 2011

Map library for gwt

I recently have been working with a hobby project where I want to show a map and create an overlay(path) on the map. I also want to change the overlay of the map in runtime. To do this I´ve discovered these options, but only found one of them to be working for my purposes:

The Official Google gwt-google-apis maps version

the good
  • It works
  • Its the official thing, meaning that most of the functionality in google maps is supported
  • probably works on any version of the gwt
the bad
  • Its version 1.1 of the maps api, the latest version is 3. So you get an old look and feel on the map
  • You need an api key
  • Displaying several maps at once seems to be a problem

gwt-google-maps-v3

the good
  • works very well
  • version 3
the bad:
  • not official, not everything works
  • DOES NOT WORK ON LATEST GWT version!!!
the good
  • simple to use
  • version 3
  • works on any known gwt version
the bad
  • advanced functionality is not implemented yet

For me, the winner is gwt-maps3. It has the features I need(markers, polygon, polyline etc) and it works with the latest gwt version.

Friday, May 6, 2011

Mocking jndi for junit tests

SimpleNamingContextBuilder was the perfect match for me when i wanted to mock some jndi-references for my appctx in my junit-tests

@BeforeClass
    public static void mockJndi() throws IllegalStateException, NamingException {
        SimpleNamingContextBuilder builder = new SimpleNamingContextBuilder();
        builder.bind("java.naming.factory.initial", new org.jnp.interfaces.NamingContextFactory());
        builder.bind("ConnectionFactory", new QueueConnectionFactoryBean());
        builder.bind("queue/someFileQueue", new ActiveMQQueue());
        builder.activate();
    }.

Thanks to http://formatmysourcecode.blogspot.com/ :)

Monday, February 14, 2011

HttpMediaTypeNotAcceptableException

Using spring mvc and the @ResponseBody annotation might give you the HttpMediaTypeNotAcceptableException if you set the "Accept" header to "application/json". To solve this, add jackson-jaxrs to your classpath.  Nothing else needs to be done, spring does it's magic.

In your test , slap on a @Autowired on your AnnotationMethodHandlerAdapter.

Sunday, February 13, 2011

Maven + appengine

This memo is about using maven with your google appengine project.

Prerequisites:
Maven 3.0x
Command line interface
Know how to edit your pom

Howto:
  1. mvn archetype:generate choose gae-jsp and enter your project group/artifactid
  2. cd
  3. edit your pom.xml file to define at least the 1.4.2 version of google appengine, found under the properties tag. 1.4.2
  4. type mvn install to check that everything is ok
  5. type mvn gae:unpack to download and install the gae runtime into your local repository
  6. Edit the src/main/webapp/index.jsp, remove all jsp tags.
  7. type mvn gae:run and open localhost:8080
Congrats, you are now ready to start your GAE project with maven. I suggest
  1. mvn eclipse:eclipse and import the project into eclipse.
  2. Add spring, spring-mvc and spring-jdo or spring-jpa to your projects pom-file.

Update: updated version from 1.4.0 to 1.4.2