1
votes

I found this cool post on DZone:

I wanted to give it a try. I followed the example step by step and it worked great for me. In less than 5 mins I had that web app described up and running.

I decided to create my own application just for fun. But it didn't work and I have not idea why it is. I am confident I did every thing in the exact same way but just using my own variable names. Here is every thing I did:

1- From my linux terminal, created a folder and navigated to it

mkdir whatsup
cd whatsup

2- I started the roo shell to start working(my ROO_HOME is configured correctly)

/roo.sh

   / __ \/ __ \/ __ \ 
  / /_/ / / / / / / / 
 / _, _/ /_/ / /_/ /  
/_/ |_|\____/\____/    1.2.1.RELEASE [rev 6eae723]


Welcome to Spring Roo. For assistance press TAB or type "hint" then hit ENTER.

3- I created the project definition

roo> project --topLevelPackage com.hack --projectName whats-up
Created ROOT/pom.xml
Created SRC_MAIN_RESOURCES
Created SRC_MAIN_RESOURCES/log4j.properties
Created SPRING_CONFIG_ROOT
Created SPRING_CONFIG_ROOT/applicationContext.xml

4- I enabled the persistence layer

roo> persistence setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY

Created SPRING_CONFIG_ROOT/database.properties Updated SPRING_CONFIG_ROOT/applicationContext.xml Created SRC_MAIN_RESOURCES/META-INF/persistence.xml Updated ROOT/pom.xml [added dependencies org.hsqldb:hsqldb:1.8.0.10, org.hibernate:hibernate-core:3.6.9.Final, org.hibernate:hibernate-entitymanager:3.6.9.Final, org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final, org.hibernate:hibernate-validator:4.2.0.Final, javax.validation:validation-api:1.0.0.GA, cglib:cglib-nodep:2.2.2, javax.transaction:jta:1.1, org.springframework:spring-jdbc:${spring.version}, org.springframework:spring-orm:${spring.version}, commons-pool:commons-pool:1.5.6, commons-dbcp:commons-dbcp:1.3]

5- I created my first entity

roo> entity jpa --class ~.domain.Message

Created SRC_MAIN_JAVA/com/hack/domain Created SRC_MAIN_JAVA/com/hack/domain/Message.java Created SRC_MAIN_JAVA/com/hack/domain/Message_Roo_Configurable.aj Created SRC_MAIN_JAVA/com/hack/domain/Message_Roo_ToString.aj Created SRC_MAIN_JAVA/com/hack/domain/Message_Roo_Jpa_ActiveRecord.aj Created SRC_MAIN_JAVA/com/hack/domain/Message_Roo_Jpa_Entity.aj

6- I added the fields to the entity

~.domain.Message roo> field number --fieldName votes --type java.lang.Integer --notNull

Updated SRC_MAIN_JAVA/com/hack/domain/Message.java Created SRC_MAIN_JAVA/com/hack/domain/Message_Roo_JavaBean.aj

7- Include the web layer to my project

~.domain.Message roo> web jsf setup --implementation APACHE_MYFACES --theme PEPPER_GRINDER

Created ROOT/src/main/webapp Created ROOT/src/main/webapp/index.html Created ROOT/src/main/webapp/viewExpired.xhtml Created ROOT/src/main/webapp/resources/images Created ROOT/src/main/webapp/resources/images/csv.png
Created com.hack.jsf.converter.MessageConverter Created ROOT/src/main/webapp/resources/images/de.png Created ROOT/src/main/webapp/resources/images/en.png Created ROOT/src/main/webapp/resources/images/es.png Created ROOT/src/main/webapp/resources/images/excel.png Created ROOT/src/main/webapp/resources/images/favicon.ico Created ROOT/src/main/webapp/resources/images/pdf.png Created ROOT/src/main/webapp/resources/images/roo_logo.png Created ROOT/src/main/webapp/resources/images/springsource-logo.png Created ROOT/src/main/webapp/resources/images/xml.png Created ROOT/src/main/webapp/resources/css Created ROOT/src/main/webapp/resources/css/standard.css Created ROOT/src/main/webapp/resources/js Created ROOT/src/main/webapp/resources/js/calendar.js Created ROOT/src/main/webapp/templates Created ROOT/src/main/webapp/templates/content.xhtml Created ROOT/src/main/webapp/templates/footer.xhtml Created ROOT/src/main/webapp/templates/header.xhtml Created ROOT/src/main/webapp/templates/layout.xhtml Created ROOT/src/main/webapp/templates/menu.xhtml Created ROOT/src/main/webapp/pages Created ROOT/src/main/webapp/pages/main.xhtml Updated ROOT/pom.xml [added dependencies org.apache.myfaces.core:myfaces-api:2.1.5, org.apache.myfaces.core:myfaces-impl:2.1.5, org.primefaces:primefaces:3.1, org.primefaces.themes:south-street:1.0.3, org.springframework:spring-web:${spring.version}, javax.el:el-api:2.2, commons-fileupload:commons-fileupload:1.2.2, commons-io:commons-io:2.1; added repository http://repository.primefaces.org; added dependency org.primefaces.themes:pepper-grinder:1.0.3; updated project type to war] Created SRC_MAIN_WEBAPP/WEB-INF Created SRC_MAIN_WEBAPP/WEB-INF/web.xml

8- I performed a package

~.domain.Message roo> web jsf all --package ~.jsf

Created ROOT/src/main/resources/com/hack/jsf/i18n Created ROOT/src/main/resources/com/hack/jsf/i18n/messages_de.properties Created ROOT/src/main/resources/com/hack/jsf/i18n/messages_en.properties Created ROOT/src/main/resources/com/hack/jsf/i18n/messages_es.properties Created SRC_MAIN_JAVA/com/hack/jsf Created SRC_MAIN_JAVA/com/hack/jsf/MessageBean.java Created SRC_MAIN_JAVA/com/hack/jsf/converter Created SRC_MAIN_JAVA/com/hack/jsf/converter/MessageConverter.java Created SRC_MAIN_WEBAPP/WEB-INF/faces-config.xml Created SRC_MAIN_JAVA/com/hack/jsf/ApplicationBean.java Created SRC_MAIN_JAVA/com/hack/jsf/util Created SRC_MAIN_JAVA/com/hack/jsf/util/LocaleBean.java Created SRC_MAIN_JAVA/com/hack/jsf/util/ViewExpiredExceptionExceptionHandlerFactory.java Created SRC_MAIN_JAVA/com/hack/jsf/util/ViewExpiredExceptionExceptionHandler.java Created SRC_MAIN_WEBAPP/pages/message.xhtml Created SRC_MAIN_JAVA/com/hack/jsf/ApplicationBean_Roo_ApplicationBean.aj Created SRC_MAIN_JAVA/com/hack/jsf/ApplicationBean_Roo_Configurable.aj Created SRC_MAIN_JAVA/com/hack/jsf/converter/MessageConverter_Roo_Converter.aj Created SRC_MAIN_JAVA/com/hack/jsf/converter/MessageConverter_Roo_Configurable.aj Created SRC_MAIN_JAVA/com/hack/jsf/MessageBean_Roo_Serializable.aj Created SRC_MAIN_JAVA/com/hack/jsf/MessageBean_Roo_Configurable.aj Created SRC_MAIN_JAVA/com/hack/jsf/MessageBean_Roo_ManagedBean.aj

9- Exited the roo shell

~.jsf roo> quit

10- At the linux terminal, from inside the project I did run the command suggested in the tutorial to execute in tomcat 7

~/hackday/whatsup$ mvn package org.codehaus.cargo:cargo-maven2-plugin:run -Dcargo.maven.containerId=tomcat7x -Dcargo.maven.containerUrl=http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.22/bin/apache-tomcat-7.0.22.zip

This was the output when trying to run:

[INFO] Scanning for projects... [INFO]
[INFO] ------------------------------------------------------------------------ [INFO] Building whats-up 0.1.0.BUILD-SNAPSHOT [INFO] ------------------------------------------------------------------------ Downloading: http://xxx.xx.xx.xx:8081/nexus/content/groups/public/org/primefaces/themes/pepper-grinder/1.0.3/pepper-grinder-1.0.3.pom Downloading: http://maven.springframework.org/release/org/primefaces/themes/pepper-grinder/1.0.3/pepper-grinder-1.0.3.pom Downloading: http://maven.springframework.org/milestone/org/primefaces/themes/pepper-grinder/1.0.3/pepper-grinder-1.0.3.pom Downloading: http://spring-roo-repository.springsource.org/release/org/primefaces/themes/pepper-grinder/1.0.3/pepper-grinder-1.0.3.pom Downloading: http://repository.primefaces.org/org/primefaces/themes/pepper-grinder/1.0.3/pepper-grinder-1.0.3.pom Downloaded: http://repository.primefaces.org/org/primefaces/themes/pepper-grinder/1.0.3/pepper-grinder-1.0.3.pom (636 B at 3.3 KB/sec) Downloading: http://xxx.xx.xx.xx:8081/nexus/content/groups/public/org/primefaces/themes/pepper-grinder/1.0.3/pepper-grinder-1.0.3.jar Downloading: http://maven.springframework.org/release/org/primefaces/themes/pepper-grinder/1.0.3/pepper-grinder-1.0.3.jar Downloading: http://maven.springframework.org/milestone/org/primefaces/themes/pepper-grinder/1.0.3/pepper-grinder-1.0.3.jar Downloading: http://spring-roo-repository.springsource.org/release/org/primefaces/themes/pepper-grinder/1.0.3/pepper-grinder-1.0.3.jar Downloading: http://repository.primefaces.org/org/primefaces/themes/pepper-grinder/1.0.3/pepper-grinder-1.0.3.jar Downloaded: http://repository.primefaces.org/org/primefaces/themes/pepper-grinder/1.0.3/pepper-grinder-1.0.3.jar (69 KB at 155.3 KB/sec) [INFO] [INFO] --- aspectj-maven-plugin:1.2:compile (default) @ whats-up --- [ERROR] The method findAllMessages() is undefined for the type Message [ERROR] Type mismatch: cannot convert from Message to Message [ERROR] Type mismatch: cannot convert from Message to Message [ERROR] The method getId() is undefined for the type String [ERROR] The method merge() is undefined for the type String [ERROR] The method persist() is undefined for the type String [WARNING] advice defined in org.springframework.orm.jpa.aspectj.JpaExceptionTranslatorAspect has not been applied [Xlint:adviceDidNotMatch] [WARNING] advice defined in org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl has not been applied [Xlint:adviceDidNotMatch] [WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch] [WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch] [WARNING] advice defined in org.springframework.scheduling.aspectj.AbstractAsyncExecutionAspect has not been applied [Xlint:adviceDidNotMatch] [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 15.525s [INFO] Finished at: Mon Jan 07 17:56:26 GMT 2013 [INFO] Final Memory: 6M/125M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.2:compile (default) on project whats-up: Compiler errors : [ERROR] error at allMessages = Message.findAllMessages(); [ERROR] ^^^^^^ [ERROR] /home/cleanuser/hackday/whatsup/src/main/java/com/hack/jsf/MessageBean_Roo_ManagedBean.aj:72:0::0 The method findAllMessages() is undefined for the type Message [ERROR] error at message = new Message(); [ERROR] [ERROR] /home/cleanuser/hackday/whatsup/src/main/java/com/hack/jsf/MessageBean_Roo_ManagedBean.aj:198:0::0 Type mismatch: cannot convert from Message to Message [ERROR] error at message = new Message(); [ERROR] ^^^^ [ERROR] /home/cleanuser/hackday/whatsup/src/main/java/com/hack/jsf/MessageBean_Roo_ManagedBean.aj:226:0::0 Type mismatch: cannot convert from Message to Message [ERROR] error at if (message.getId() != null) { [ERROR] [ERROR] /home/cleanuser/hackday/whatsup/src/main/java/com/hack/jsf/MessageBean_Roo_ManagedBean.aj:233:0::0 The method getId() is undefined for the type String [ERROR] error at message.merge(); [ERROR] [ERROR] /home/cleanuser/hackday/whatsup/src/main/java/com/hack/jsf/MessageBean_Roo_ManagedBean.aj:234:0::0 The method merge() is undefined for the type String [ERROR] error at message.persist(); [ERROR] [ERROR] /home/cleanuser/hackday/whatsup/src/main/java/com/hack/jsf/MessageBean_Roo_ManagedBean.aj:237:0::0 The method persist() is undefined for the type String [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

I don't know how to make it work. As you can see my steps are exact the same as the DZone tutorial I don't know what is different. The interesting thing is that their example works but mine does'nt.

Also I tried without luck: mvn clean install This will give me a BUILD SUCCESS but cannot make it run on the server mvn tomcat:run Same result as with the other command

If there is somebody around with experience using Spring Roo in combination with JSF, I appreciate some help.

1

1 Answers

2
votes

It looks as if "Message" clashes with some name used by the autogenerated code. Would you try it with, say, "MyMessage"?