ASM this library is major p.i.t.a cause releases aren't backwards compatible, and is done for the performance improvements. Spring doesn't plan to upgrade as from this post and this post but instead will reference a packaged version of asm, due to release with Spring 3.0 M3 . This is all part of the cost of working with milestones.
Google app engine / java uses Data Nucleus to enhance class files for persistence and relies on asm 3.1. Currently I am using the maven-datanucleus-plugin to enhance my class files. With maven I couldn't figure out how to include both libraries. The solution was to define the asm 2.3.2 libraries with scope runtime, and change ant-macros.xml file to not failonerror to false. I haven't tested on gae/j itself and just hosted mode, and this seemed to work. Also I had to define the datanucleus-core dependency as runtime scope as well, because the plugin requires 1.1.2, and gae only works with 1.1.1 now.
Showing posts with label maven. Show all posts
Showing posts with label maven. Show all posts
Wednesday, April 29, 2009
Tuesday, April 21, 2009
GWT, Spring 3.0 MVC, and REST on Google App Engine / Java - Part 1
When googleing how to integrate GWT and Spring/Spring mvc, the most popular answer is to use the GWT- Widget/Server Library. The solutions are wrapping pojos as an RPC service or for better performance taking a spring controller and adding RPC functionality by extension.
With the intoduction of REST features in Spring MVC 3.0, this should make integration between GWT and Spring more natural. This is how to get it all working together on Google App Engine / Java.
First use Spring 3.0 M2. To include this in maven
Add the milestone repository
SpringSource Enterprise Bundle Repository - External Bundle Milestones
http://repository.springsource.com/maven/bundles/milestone
Note: ensure your using asm 2.2.3
Now in the web application you need to create the REST support with MVC. The most important feature added is the ContentNegotiatingViewResolver, this will determine which view to present from Accept header or extension, and from media type can resolve appropriate view. Probably the more important type will be for JSON support. In the blog post from Spring about REST in Spring 3 they hint at the JacksonJsonView and its inclusion in WebFlow or Spring Js, and at the time of this posting, unavailable. Anyways.. I really don't care to add web flow, or spring js to my project when using GWT. The project json-lib-ext-spring : details provides a json view that works seamlessly. Ensure that you exclude all spring libraries in your maven dependency.
In you spring configuration , it will look like this now..
In the GreetJsonView just :
import net.sf.json.spring.web.servlet.view.JsonView;
public class GreetJsonView extends JsonView {
}
In the future it should be as easy and changing the class that you extend when spring releases a proper JSON view.
@Controller
@RequestMapping("/greet")
public class GreetController {
@RequestMapping(value = "greet", method = RequestMethod.GET)
public String list(ModelMap modelMap) {
modelMap.put("hello","REST rocks");
return "greet";
}
}
Now when you go to /path/greet it will display the jsp or if you go to /path/greet.json it will return the json string.
For additional details on how to get Spring MVC started and configured -
The most helpful is the pet clinic demo for Spring 3 M2 found in the subversion repository.
AtomView and REST Support
Example program called Spring Finance
Thats it for part 1, in my next post, I will show how to get GWT working with your spring mvc back end through REST calls, and putting it all together to get it working nicely on GAE/J
With the intoduction of REST features in Spring MVC 3.0, this should make integration between GWT and Spring more natural. This is how to get it all working together on Google App Engine / Java.
First use Spring 3.0 M2. To include this in maven
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.spring-library</artifactId>
<type>libd</type>
<version>3.0.0.M2</version>
</dependency>
Add the milestone repository
SpringSource Enterprise Bundle Repository - External Bundle Milestones
http://repository.springsource.com/maven/bundles/milestone
Note: ensure your using asm 2.2.3
Now in the web application you need to create the REST support with MVC. The most important feature added is the ContentNegotiatingViewResolver, this will determine which view to present from Accept header or extension, and from media type can resolve appropriate view. Probably the more important type will be for JSON support. In the blog post from Spring about REST in Spring 3 they hint at the JacksonJsonView and its inclusion in WebFlow or Spring Js, and at the time of this posting, unavailable. Anyways.. I really don't care to add web flow, or spring js to my project when using GWT. The project json-lib-ext-spring : details provides a json view that works seamlessly. Ensure that you exclude all spring libraries in your maven dependency.
In you spring configuration , it will look like this now..
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="mediaTypes">
<map>
<entry key="html" value="text/html"/>
<entry key="json" value="application/json"/>
</map>
</property>
<property name="viewResolvers">
<list>
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
</list>
</property>
</bean>
<bean id="greet" class="path.to.GreetJsonView"/>
In the GreetJsonView just :
import net.sf.json.spring.web.servlet.view.JsonView;
public class GreetJsonView extends JsonView {
}
In the future it should be as easy and changing the class that you extend when spring releases a proper JSON view.
@Controller
@RequestMapping("/greet")
public class GreetController {
@RequestMapping(value = "greet", method = RequestMethod.GET)
public String list(ModelMap modelMap) {
modelMap.put("hello","REST rocks");
return "greet";
}
}
Now when you go to /path/greet it will display the jsp or if you go to /path/greet.json it will return the json string.
For additional details on how to get Spring MVC started and configured -
The most helpful is the pet clinic demo for Spring 3 M2 found in the subversion repository.
AtomView and REST Support
Example program called Spring Finance
Thats it for part 1, in my next post, I will show how to get GWT working with your spring mvc back end through REST calls, and putting it all together to get it working nicely on GAE/J
Labels:
gae/j,
google app engine,
gwt,
maven,
REST,
spring,
spring 3.0,
spring mvc
Monday, April 13, 2009
Google App Engine / Java and Maven
When first creating a project with the elipse google plugin, your presented with a project with gwt and gae/j ( google app engine / java) support. The first question I asked is how to get this all working with maven. The best archetype I have found is here gae-mvn-archetype. Instructions as followed:
1 create GAE/J project from maven archetype, artifactId is the app id.
> mvn archetype:generate -DarchetypeCatalog=http://www.mvnsearch.org/maven2
maven2
2 Build project
> mvn package
3 Test
> dev_appserver target\app-name
4 Deploy
> appcfg update target\app-name
But better to go here for specific details Maven for Google Appengine
Two things I've found from first use. First I was receiving ResourceDoesNotExistException: Unable to locate resource in repository. To get around this, in your settings.xml, usually found in /Users/.m2 .. there's a node called interactiveMode. Just comment this line out. As to the exact details I haven't looked into it yet. Second the META-INF directory is created in the resources directory. I would move this to the webapps, directory so the files jdoconfig.xml and persistence.xml are included in final build. Now in the google groups in the posting found here GAE/J Maven Support there's an alternative that doesn't rely on ant or google app engine SDK. I've tried this one out as well but found it to be not as easy to follow or use. I guess its a matter of what happens in the future on support and features, as to which one will be the better choice.
GWT support:
There were two maven plugins I found for this found here : gwt-maven google code and here : Google Web toolkit plugin. Long story short, the contributors from the google code hosted project will now be contributing to the Gwt plugin found on codehaus.org. So using this plugin Google Web toolkit plugin, should be good. The issues I've found is most of the documentation found on the site, refer to version 1.1. Using their plugin repository there was no 1.1 at the time of this post only 1.0 is found on there plugin repository So the solution is to use there sandbox repository found here Sandbox repository. Here you will be able to find the 1.1 release of GWT maven plugin.
1 create GAE/J project from maven archetype, artifactId is the app id.
> mvn archetype:generate -DarchetypeCatalog=http://www.mvnsearch.org/maven2
maven2
2 Build project
> mvn package
3 Test
> dev_appserver target\app-name
4 Deploy
> appcfg update target\app-name
But better to go here for specific details Maven for Google Appengine
Two things I've found from first use. First I was receiving ResourceDoesNotExistException: Unable to locate resource in repository. To get around this, in your settings.xml, usually found in /Users/.m2 .. there's a node called interactiveMode. Just comment this line out. As to the exact details I haven't looked into it yet. Second the META-INF directory is created in the resources directory. I would move this to the webapps, directory so the files jdoconfig.xml and persistence.xml are included in final build. Now in the google groups in the posting found here GAE/J Maven Support there's an alternative that doesn't rely on ant or google app engine SDK. I've tried this one out as well but found it to be not as easy to follow or use. I guess its a matter of what happens in the future on support and features, as to which one will be the better choice.
GWT support:
There were two maven plugins I found for this found here : gwt-maven google code and here : Google Web toolkit plugin. Long story short, the contributors from the google code hosted project will now be contributing to the Gwt plugin found on codehaus.org. So using this plugin Google Web toolkit plugin, should be good. The issues I've found is most of the documentation found on the site, refer to version 1.1. Using their plugin repository there was no 1.1 at the time of this post only 1.0 is found on there plugin repository So the solution is to use there sandbox repository found here Sandbox repository. Here you will be able to find the 1.1 release of GWT maven plugin.
Labels:
gae/j,
google app engine,
google webtoolkit,
gwt,
java,
maven
Thursday, September 4, 2008
Flex Libraries - SWC and Maven
Handling these dependencies in maven, is just like any other library or jar. For example I'm using mate in my project ,
mvn install:install-file -DgroupId=com.asfusion.mate -DartifactId=mate -Dversion=0.7.8 -Dpackaging=swc -Dfile=<file path>Mate_07_8.swc
and now just add the dependency in your pom file ,
for more information refer to this post Adding Libraries to Compilation by velos from the flex-mojos blog
mvn install:install-file -DgroupId=com.asfusion.mate -DartifactId=mate -Dversion=0.7.8 -Dpackaging=swc -Dfile=<file path>Mate_07_8.swc
and now just add the dependency in your pom file ,
<dependency>
<groupId>com.asfusion.mate</groupId>
<artifactId>mate</artifactId>
<version>0.7.8</version>
<type>swc</type>
</dependency>
for more information refer to this post Adding Libraries to Compilation by velos from the flex-mojos blog
Wednesday, August 27, 2008
Flex and Java and Me - Getting Started
The technology stack I'm going to use is flex, actionscript 3 .. using pure mvc, mate, or caingorm ( this requires another writeup) for the front end. Back end will be using java - spring , hibernate. So now that the easy stuff is out of the way, I'm going to setup the frame for the project using maven to manage dependencies, and builds. I went through this tutorial Flex, Spring and BlazeDS full Stack, and it was very good to get a good start running on the build and management tools. I will build and expand on this tutorial, to organize and manage everything easier.
Adobe released Flex Builder Linux. Im using alpha 4 currently. Start with getting eclise 3.3 as I issues with ganymede 3.4 and Flex Builder alpha 3, but may have been resolved with alpha 4. Also I'm using Q for Eclipse plugin.
Refer back to the original tutorial I followed for most examples.
So to start first thing to do is create a root project. This is where all modules will be placed under. In eclipse or maven directly create a project archetype quick-start.
1. delete the "src" directory, its not necessary.
2. Edit pom.xml change packaging to "pom" instead of "jar"
3. create a maven module for your flex for example projname-ria.
Creating a Flex Module
Create a maven module under the root project. The archetype is the maven-archetype-flex.
To have maven handle the adobe flex dependencies and to compile, I am currently using the - flex mojos - project. Some really excellent work is being done on this project. Refer to my writeup here - flex-mojo - getting started
Creating - Java
Next I wil create a core module - maven-archetype-quickstart and a web module - maven-archetype-webapp. The only thing I would consider is creating a commons project. If you intend on creating library reusable classes, then its probably good to create it as a separate project. Refactor later.
Now for dependencies, add Spring 2.5.5 , and hibernate 3.2.6.ga as these are pretty much the middle tier and persistence tier frameworks we will be working with.
Now pretty much follow the tutorial for the configuration module, and the plugins to put everything together. The only other catch is in the mxml files refer to the full namespace
and in the article they just refer to /2006/mxml and you will get compile errors.
Adobe released Flex Builder Linux. Im using alpha 4 currently. Start with getting eclise 3.3 as I issues with ganymede 3.4 and Flex Builder alpha 3, but may have been resolved with alpha 4. Also I'm using Q for Eclipse plugin.
Refer back to the original tutorial I followed for most examples.
So to start first thing to do is create a root project. This is where all modules will be placed under. In eclipse or maven directly create a project archetype quick-start.
1. delete the "src" directory, its not necessary.
2. Edit pom.xml change packaging to "pom" instead of "jar"
3. create a maven module for your flex for example projname-ria.
Creating a Flex Module
Create a maven module under the root project. The archetype is the maven-archetype-flex.
To have maven handle the adobe flex dependencies and to compile, I am currently using the - flex mojos - project. Some really excellent work is being done on this project. Refer to my writeup here - flex-mojo - getting started
Creating - Java
Next I wil create a core module - maven-archetype-quickstart and a web module - maven-archetype-webapp. The only thing I would consider is creating a commons project. If you intend on creating library reusable classes, then its probably good to create it as a separate project. Refactor later.
Now for dependencies, add Spring 2.5.5 , and hibernate 3.2.6.ga as these are pretty much the middle tier and persistence tier frameworks we will be working with.
Now pretty much follow the tutorial for the configuration module, and the plugins to put everything together. The only other catch is in the mxml files refer to the full namespace
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
and in the article they just refer to /2006/mxml and you will get compile errors.
Subscribe to:
Posts (Atom)