ALBERLAU blog

Blog about my personal experience in software development.

Thursday, January 24, 2008

 

Playing with Maven and AppFuse

Appfuse allows to build application skeletons quickly. First choose archetype, or combination of app frameworks, because of maven all dependencies, config files and samples will be installed with single line.

Below is my personal notes taken while experimenting with appfuse application framework. I'm choosing modular spring and jsf archetype.

Change to your projects root. Type : mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-modular-jsf -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.1 -DgroupId=com.mycompany.myproject -DartifactId=myproject


After this command, type cd myproject, edit pom.xml and change jdbc settings located at the end of the file. Then type mvn. Project build starts. At most cases you will get BUILD ERROR caused something like: Could not connect to SMTP host: localhost, port: 25. To fix situation it is easest way to get James from http://james.apache.org/ . You only need to download and start it. Start mvn again. Now i'm getting BUILD SUCCESSFUL.


Now type cd web and mvn jetty:run-war . Web application becomes available at http://localhost:8080/ . Press Ctrl+C to stop jetty.


Type cd ../core. Type mvn appfuse:gen-model . Model classes is generated from database tables.



There is a list of AppFuse Maven commands at this link: http://www.appfuse.org/display/APF/AppFuse+Maven+Plugin .


Trying to generate CRUD stuff for mvn appfuse:gen -Dentity=Message and getting java.lang.StringIndexOutOfBoundsException: String index out of range: 1. I resolved this problem by performing mvn in project root and mvn appfuse:gen -Dentity=Message both in core and web modules.

Getting "Error executing database operation: CLEAN_INSERT". Mostly this problem occures when there is a problems with example data or bean-table mapping. It is consequence of SQLException. First look at YOUR_PROJECT_ROOT\(webcore)\src\test\resources\sample-data.xml and try to fix example data. If all is ok, check your console after mvn run for SQL errors and then fix some bean in YOUR_PROJECT_ROOT\core\app\model\SomeBean.java .

The first thing in case of Windows is to change Maven repository path to something without spaces in path. Edit MAVEN_HOME/conf/settings and add or change c:/apache-maven-2.0.8/repo line. That should be done because sooner or later you'll get : Illegal character in path at index 18: file:/C:/Documents and Settings . I got this while executing mvn appfuse:gen-core . After changfing this you can move Maven repository located at C:/Documents and Settings/.m2 to a new location.

Second issue. I got java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/xfire-servlet.xml] . After googling i find out that i need to run mvn jetty:run-war instead of mvn jetty:run.

Now i'm dealing with javax.el.ELException: ELResolver cannot handle a null base Object with identifier 'errors' . I find out solution to use mvn -Dcargo.wait . Use -Dmaven.test.skip=true if tests fail and you don't want to fix them. Currently i have no idea what kind of thing is cargo. But it started tomcat instead of jetty. Also running in tomcat requires context path like this: http://localhost:8081/myproject-webapp-1.0-SNAPSHOT/mainMenu.html .

Getting javascript error when selecting to edit Branch. I generated branches using mvn appfuse:gen -Dentity=Name . The list is looking ok, but going to edit i getting "Object doesn't support this property or method". The main problem was that mvn appfuse:gen -Dentity=Name makes file named branchs.xhtml, but in all config files it generates branches.xhtml . Rename file to branches to fix the problem.


[INFO] Use of @OneToMany or @ManyToMany targeting an unmapped class: org.eparty.model.Branch.members[org.eparty.model.Member]

The above problem is caused by missing entries in hibernate.cfg.xml.



java.lang.NoClassDefFoundError: org/ep/webapp/filter/LocaleFilter (wrong name: org/appfuse/webapp/filter/LocaleFilter) or something like someYourPackage.yourClass (wrong name: org/appfuse/webapp/filter/SomeAppfuseClass) . I changed all these classes to appfuse classes.


mvn appfuse:full-source . Dont't do this. Or do after full backup of what you have. At least with 2.0.1 version. After making efforts to do making working application, this will break your code. It is better to grab appFuse core classes in to project. More info about that: http://appfuse.org/display/APF/AppFuse+Core+Classes .
Comments: Post a Comment

Subscribe to Post Comments [Atom]





<< Home

Archives

January 2008   February 2008   March 2009  

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]