4.2.2012

spring roo + app engine => even friends (part 1)

Filed under: cloud,Google — nax @ 23:03

Platform as a service really taking of lately (ups – last 3 years 😉 and I’ve decided that it is time for me to start messing around and try what is actually user experience and what frameworks to use.

I started with simple idea – lets write an app. And because I travel a lot and I travel with friends, I decided to create another expense tracking app, but this time specialized to solve post trip sorting-out-bills-split-headache.

First I watched a few tutorial videos like this one and installed maven (from Ubuntu repository) and roo (downloaded latest zip file – v1.2.0.RC1 [rev dcaa483]).


cd ~/src/roo-projects/
mkdir evenfriends
roo

This gives you roo console. Now lets create some data model:

project --topLevelPackage cz.nax.evenfriends
jpa setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY

entity jpa --class ~.domain.Currency --testAutomatically
field string --fieldName code --notNull --sizeMax 3
field string --fieldName rateToDolar --notNull

entity jpa --class ~.domain.Traveler --testAutomatically
field string --fieldName name --notNull
field reference --fieldName homeCurrency --type ~.domain.Currency

entity jpa --class ~.domain.Bill --testAutomatically
field string --fieldName description --notNull
field reference --fieldName payedBy --type ~.domain.Traveler
field number --fieldName amount --type java.lang.Float
field reference --fieldName currency --type ~.domain.Currency
field set --fieldName consumedBy --type ~.domain.Traveler

entity jpa --class ~.domain.Trip --testAutomatically
field string --fieldName name --notNull
field date --fieldName fromDate --type java.util.Date
field date --fieldName toDate --type java.util.Date
field set --fieldName bills --type ~.domain.Bill
web mvc setup
web mvc all --package cz.nax.evenfriends.domain

test integration
perform test

Then I got error when I tried to run perform eclipse

[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
roo>
Missing:
----------
1) com.sun:tools:jar:1.4.2
roo>
Try downloading the file manually from the project website.
roo>
Then, install it using the command:
mvn install:install-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.4.2 -Dpackaging=jar -Dfile=/path/to/file
roo>
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.4.2 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
roo>
Path to dependency:
1) org.codehaus.mojo:aspectj-maven-plugin:maven-plugin:1.2
2) com.sun:tools:jar:1.4.2
----------
1 required artifact is missing.
for artifact:
org.codehaus.mojo:aspectj-maven-plugin:maven-plugin:1.2
from the specified remote repositories:
spring-maven-milestone (http://maven.springframework.org/milestone),
central (http://repo1.maven.org/maven2),
spring-roo-repository (http://spring-roo-repository.springsource.org/release),
codehaus.org (http://snapshots.repository.codehaus.org),
spring-maven-release (http://maven.springframework.org/release)

I downloaded file from here and executed recommended file:

mvn install:install-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.4.2 -Dpackaging=jar -Dfile=/space/usr/springsource/spring-roo-1.1.5.RELEASE/sts-cache-bEven/aspectjtools-1.6.12.M2.jar
mvn install:install-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.4.2 -Dpackaging=jar -Dfile=/usr/lib/jvm/jdk1.6.0_20/lib/tools.jar

didn’t help.

I search a bit and found the post that talking about problems with version of jdk (or mixing it up with jre).


~/src/workspace/bEven$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 2010-08-02 09:49 /usr/bin/java -> /etc/alternatives/java
~/src/workspace/bEven$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 40 2010-08-02 09:49 /etc/alternatives/java -> /usr/lib/jvm/java-6-openjdk/jre/bin/java
~/src/workspace/bEven$ cd /etc/alternatives/
/etc/alternatives$ sudo ln -s /usr/lib/jvm/jdk1.6.0_20/bin/java java
/etc/alternatives$ sudo ln -s /usr/lib/jvm/jdk1.6.0_20/bin/javaws

and it really helped!

roo> perform test
... downloaded some dependencies ...
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 36, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 minutes 52 seconds
[INFO] Finished at: Sun Jan 29 19:52:43 CET 2012
[INFO] Final Memory: 33M/228M
[INFO] ------------------------------------------------------------------------
roo> perform eclipse
... downloaded some dependencies ...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 minutes 41 seconds
[INFO] Finished at: Sun Jan 29 19:57:22 CET 2012
[INFO] Final Memory: 25M/188M
[INFO] ------------------------------------------------------------------------

I continued in command line (bash):


mvn tomcat:run
mvn selenium:selenese

then I returned to roo and wrote

perform eclipse

and now I can run springsource IDE.

I used integrated google app engine deploy plugin, but unfortunately I am getting:

Error: Server Error

The server encountered an error and could not complete your request.
If the problem persists, please report your problem and mention this error message and the query that caused it.

I can see in logs following errors:

Could not instantiate listener org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
at com.google.appengine.runtime.Request.process-931dad6b90a83fb7(Request.java)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at org.mortbay.jetty.handler.ContextHandler.loadClass(ContextHandler.java:1101)
at org.mortbay.jetty.webapp.WebXmlConfiguration.initListener(WebXmlConfiguration.java:630)
at org.mortbay.jetty.webapp.WebXmlConfiguration.initWebXmlElement(WebXmlConfiguration.java:368)
at org.mortbay.jetty.webapp.WebXmlConfiguration.initialize(WebXmlConfiguration.java:289)
at org.mortbay.jetty.webapp.WebXmlConfiguration.configure(WebXmlConfiguration.java:222)
at org.mortbay.jetty.webapp.WebXmlConfiguration.configureWebApp(WebXmlConfiguration.java:180)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1247)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:449)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:455)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:695)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:333)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:325)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:453)
at java.lang.Thread.run(Thread.java:679)
java.lang.ClassNotFoundException: org.springframework.web.filter.CharacterEncodingFilter
at com.google.appengine.runtime.Request.process-931dad6b90a83fb7(Request.java)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at org.mortbay.util.Loader.loadClass(Loader.java:91)
at org.mortbay.util.Loader.loadClass(Loader.java:71)
at org.mortbay.jetty.servlet.Holder.doStart(Holder.java:73)
at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:81)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:662)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:449)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:455)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:695)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:333)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:325)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:453)
at java.lang.Thread.run(Thread.java:679)
Failed startup of context com.google.apphosting.utils.jetty.RuntimeAppEngineWebAppContext@84f566{/,/base/data/home/apps/s~evenfriends/1.356450658059803861}
javax.servlet.UnavailableException: org.springframework.web.filter.CharacterEncodingFilter
at org.mortbay.jetty.servlet.Holder.doStart(Holder.java:79)
at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:81)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:662)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:202)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:171)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:123)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:422)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:449)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:455)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:695)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:333)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:325)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:453)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
at java.lang.Thread.run(Thread.java:679)
Uncaught exception from servlet
javax.servlet.UnavailableException: Initialization failed.
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:211)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:171)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:123)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:422)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:449)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:455)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:695)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:333)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:325)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:453)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
at java.lang.Thread.run(Thread.java:679)

Comments are closed.

Powered by WordPress