Friday, May 11, 2012

Adding Spring to the mix (GWT, Maven, Eclipse)

Great tutorial for adding Spring into the mix of my last post.

http://www.springbyexample.org/examples/simple-gwt-spring-webapp-reference.html

The tutorial doesn't cover everything though, make sure to take a look at the sample application

svn co http://svn.springbyexample.org/web/simple-gwt-webapp/tags/1.0/ simple-gwt-webapp

GWT + Maven + Eclipse = Pain

GWT was definitely not designed with Maven in mind, and getting it all to work within Eclipse is a nightmare. I have managed to get this mostly working, here is what I have so far.

Please install Eclipse with the m2eclipse and GWT plugins.

Start by using the GWT archetype, sadly, this will not produce a project that works, but at least gets you pointed in the right direction.

mvn archetype:generate \
 -DarchetypeRepository=repo1.maven.org \
 -DarchetypeGroupId=org.codehaus.mojo \
 -DarchetypeArtifactId=gwt-maven-plugin \
 -DarchetypeVersion=2.4.0

This will request some details, including a module name. Go ahead and enter in all the fields, but the first thing you will need to do is a search on the entire project in eclipse for literally ${module} and replace that with the actual name of your new module. You should at least find this problem in the org.eclipse.wst.common.component xml file.

You will also notice that the pom.xml file has some compilation issues. I have not figured out how to resolve other than commenting out the offending lines. This doesn't seem to hurt anything, but you will need to manually generate the Async interfaces.

Next up, you will need to create a Run Configuration, most easily done by right clicking your project -> run as -> (G) Web Application. This will throw some error about needing to include the module name in the arguments. So go find the Run Configuration that it created and tack on the end the full path to your endpoint (eg. com.myapp.MyEndPoint)

Now you should be able to get the server standing by following the run as step above again.

You will notice that there are still some funky warnings being spat out, which I have not totally figured out yet, but hopefully this will help someone out.

Thursday, May 10, 2012

m2eclipse: Add archetypes to create maven project

Ran into an issue where I could not use an archetype from within Eclipse. In order to do so, a new catalog will need to be created, then Eclipse simply needs to be told where it is.
  • Navigate to your .m2/repository in your console
  • Enter the command 'mvn archetype:crawl'
This will create the file archetype-catalog.xml

In Eclipse create a new Maven project, when you get to the screen with the catalog drop down box, click configure and add a Local Catalog pointing to the xml file created above. Ok out.

This catalog will now be added to the drop down box and can be selected.

Enjoy.

Monday, April 16, 2012

OGNL

Found a great library that allows for including dot notation in your applications. Very easy to use.

Object expression = Ognl.parseExpression(dateExpression);
Object value = Ognl.getValue(expression, root);

OGNL Homepage

Thursday, February 16, 2012

Constants in Spring Context

Found an easy way to include a constant declared in some random Java file into the context file.

http://www.unicon.net/node/601

<bean id="Context" class="javax.naming.InitialContext"> 
    <constructor-arg> 
        <util:map id="jmsProperties" map-class="java.util.Hashtable"> 
            <entry> 
                <key><util:constant static-field="javax.naming.Context.INITIAL_CONTEXT_FACTORY"/></key> 
                <value>org.apache.activemq.jndi.ActiveMQInitialContextFactory</value> 
            </entry> 
            <entry> 
                <key><util:constant static-field="javax.naming.Context.PROVIDER_URL"/></key> 
                <value>tcp://localhost:61616</value> 
            </entry> 
        </util:map> 
    </constructor-arg> 
</bean>

Thursday, February 9, 2012

Installing the Aptana plugin in Eclipse makes Quick Diff colors unreadable

When I install this plugin my Quick Diff colors change, making it near impossible to read an SVN compare.

I have found that there are a couple potential fixes, or combinations thereof:

1. Go to Preferences -> General -> Editors -> Text Editors -> Quick Diff.
  • Changes ->  H:80 S:240 L:240 R:221 G:225 B:221
  • Additions ->  H:80 S:240 L:240 R:221 G:225 B:221
  • Deletions ->  H:0 S:240 L:232 R:255 G:238 B:238
2. Go to Aptana Studio -> Themes. Ensure Eclipse is chosen from the drop down box.

Thursday, January 19, 2012

Maven Test Dependency

With the maven-jar-plugin's goal test-jar, it is possible to create testing dependencies.

When doing this it is important to include the dependency twice, once normally (main code) and again with <type>test-jar<type>. So long as the dependency is built first, maven will find the test code.

Note: Eclipse doesn't seem to care which if both dependencies are there, causing some confusion, but when you go to run mvn from the cli, it will care.

http://maven.apache.org/guides/mini/guide-attached-tests.html