Ok, was away for a while. I have walked through the tutorial with a fresh Spring modular project and a single POJO and the error still occurs. Summarizing: the problem is that the generated Controller files in the web directory: 1. are placed in the wrong package: nl.msw.test.core.webapp.controller in stead of nl.msw.test.webapp.controller (the package reference in the java-file itself is correct) 2. the reference to the POJO is nl.msw.test.model.Country in stead of nl.msw.test.core.model.Country
The steps I took to reproduce this are: 1. D:\Java\Projects\test\web>mvn archetype:create -DarchetypeGroupId=org.appfuse.ar chetypes -DarchetypeArtifactId=appfuse-modular-spring -DremoteRepositories=http: //static.appfuse.org/releases -DarchetypeVersion=2.0 -DgroupId=nl.msw.test -Dart ifactId=test 2. cd test 3. mvn 4. cd core 5. mvn install eclipse:eclipse 6. cd ../web 7. mvn install eclipse:eclipse 8. create POJO in nl.msw.test.core.model.Country +++++++++ package nl.msw.test.core.model; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; import org.appfuse.model.BaseObject; @Entity @Table(name="Countries") public class Country extends BaseObject { private Long countryId; private String country, countryCode; @Column public String getCountry() { return country; } public void setCountry(String country) { this.country = country; } @Column public String getCountryCode() { return countryCode; } public void setCountryCode(String countryCode) { this.countryCode = countryCode; } @Id @GeneratedValue(strategy = GenerationType.AUTO) public Long getCountryId() { return countryId; } public void setCountryId(Long id) { this.countryId = id; } @Override public boolean equals(Object arg0) { // TODO Auto-generated method stub return false; } @Override public int hashCode() { // TODO Auto-generated method stub return 0; } @Override public String toString() { // TODO Auto-generated method stub return null; } } +++++++++ 9. added reference in hibernate.cfg.xml <mapping class="nl.msw.test.core.model.Country"/> 10. Added entries in applicationContext.xml <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configLocation"> <value>classpath:hibernate.cfg.xml</value> </property> <property name="hibernateProperties"> <ref bean="hibernateProperties" /> </property> <property name="dataSource"> <ref bean="MyDataSource" /> </property> <property name="configurationClass"> <value>org.hibernate.cfg.AnnotationConfiguration</value> </property> </bean> <bean id="hibernateProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="properties"> <props> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.c3p0.minPoolSize">5</prop> <prop key="hibernate.c3p0.maxPoolSize">20</prop> <prop key="hibernate.c3p0.timeout">600</prop> <prop key="hibernate.c3p0.max_statement">50</prop> <prop key="hibernate.c3p0.testConnectionOnCheckout"> false </prop> </props> </property> </bean> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:jdbc.properties</value> <value>classpath:mail.properties</value> </list> </property> </bean> <bean id="MyDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="${jdbc.driverClassName}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> </bean> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> 11. mvn test-compile hibernate3:hbm2ddl 11. in core: mvn appfuse:gen 12. in core: mvn appfuse:install 13. in root: mvn install 14. in web: mvn appfuse:gen 15 in web: mvn appfuse:install => ERROR because of erronous references in controller files This is the resulting CountryController.java file in the nl.msw.test.core.webapp.controller directory ++++++++ package nl.msw.test.webapp.controller; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.appfuse.service.GenericManager; import nl.msw.test.model.Country; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.Controller; public class CountryController implements Controller { private GenericManager<Country, Long> countryManager; public void setCountryManager(GenericManager<Country, Long> countryManager) { this.countryManager = countryManager; } public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { return new ModelAndView().addObject(countryManager.getAll()); } } ++++++++++ Can you confirm if this is a bug or a mistake on my part? Another thing I found was that when you use mvn apfuse:remove on an entity it actually also removes the POJO file in addition to all the entries in the various configuration files. I find this undesirable behaviour. Kind regards, Marc mraible wrote: > > On 10/29/07, mschipperheyn <[EMAIL PROTECTED]> wrote: >> >> This issue is actually more cumbersome than I thought b/c it affects >> stuff in >> different directories and requires me to fix for each POJO before I run >> mvn >> appfuse:gen again. It does look like a 'real' issue. My setup is prety >> vanilla. >> >> So, summarizing: >> Running appfuse:gen from the web dir I get: >> * package path: xyz/core/model/<subdir if any>/webapp/controller > > I don't understand the problem here - where are core/model coming > from? They shouldn't be there, nor should there be a <subdir>. I'm > guessing this might be caused by using the fully-qualified class name > instead of the simple name. > >> * package name within controller file xyz.webapp.controller >> * package name within controllerForm file xyz.webapp.controller >> * Error message in validation.xml: there should not be a form entry when >> there are no child field entries > > Yes, it's possible this is a bug - we recommend adding at least one > not-null constraint to your POJO to fix it. > > Matt > >> >> Cheers, >> >> Marc >> >> Hope to see a response on this. >> >> Cheers, >> >> Marc >> >> >> mschipperheyn wrote: >> > >> > One more thing I'm noticing is the following error, may or may not have >> > something to do with me: >> > After running mvn instal in the root, then mvn appfuse:gen on Barrio, I >> > get this issue: >> > The created package is xyz.core.webapp.controller which should be >> > xyz.webapp.controller which is also the package name within the java >> file. >> > >> > Not sure if it's something to do with me or with appfuse. >> > >> > Cheers, >> > >> > Marc >> > >> > >> > mschipperheyn wrote: >> >> >> >> I ran mvn install on the cor dir and from the web dir (following the >> >> docs), not the top level. I'm trying that now. Yeh, some things are >> >> starting to work. Ok, so you need to run mvn install at the root dir >> and >> >> then do mvn appfuse:gen on the web dir. Ok, got some errors running >> mvn >> >> install in web dir after that, but that's prob something I did wrong. >> >> Thanks, Moving forward! >> >> >> >> You might want to update the documentation >> >> In a modular project, these commands must be run in the "core" and >> "web" >> >> modules. The plugin is smart enough to figure out when it >> should/should >> >> not generate stuff based on the packaging type (jar vs. war). If you >> want >> >> to generate specific code in a "war" project, you can use gen-core or >> >> gen-web. >> >> >> >> Should be >> >> n a modular project, you should run these commands in the core dir >> first, >> >> then run mvn install in the root of the project dir and then run these >> >> commands again in the web dir. The plugin is smart enough to figure >> out >> >> when it should/should not generate stuff based on the packaging type >> (jar >> >> vs. war). If you want to generate specific code in a "war" project, >> you >> >> can use gen-core or gen-web. >> >> >> >> Maybe I should have figured it all out by myself, but with all this >> >> generation going on, it's just very hard to see why things don't work >> >> sometimes. >> >> >> >> Thanks again, >> >> >> >> Marc >> >> >> >> >> >> Mike Horwitz wrote: >> >>> >> >>> Have you run mvn:install either from the top level or in your core >> >>> project? >> >>> >> >>> Mike >> >>> >> >>> On 10/29/07, mschipperheyn <[EMAIL PROTECTED]> wrote: >> >>>> >> >>>> >> >>>> Ok, noted some small issues: >> >>>> 1. the sample data doesn't take into account column lenght. If you >> have >> >>>> a >> >>>> column length of say 5, it will fail on mvn install >> >>>> 2. the sample data doesn't take references into account, you should >> gen >> >>>> the >> >>>> referenced POJOs first and then the POJOs with references to them. >> >>>> >> >>>> But that's all easily fixable by hand. Would be nice to be able to >> just >> >>>> enter a list of POJOs and have mvn figure out the order and all >> that. >> >>>> But >> >>>> now back to the problem >> >>>> >> >>>> So I now have my sample data set up. Done all the gens and installs. >> >>>> Still got that error running the same commands in the web dir. >> >>>> >> >>>> [INFO] >> >>>> >> ------------------------------------------------------------------------ >> >>>> [ERROR] FATAL ERROR >> >>>> [INFO] >> >>>> >> ------------------------------------------------------------------------ >> >>>> [INFO] Unable to load class declared as <mapping >> >>>> class="nl.msw.compraventa.core. >> >>>> model.Archive"/> in the configuration: >> >>>> [INFO] >> >>>> >> ------------------------------------------------------------------------ >> >>>> [INFO] Trace >> >>>> org.hibernate.MappingException: Unable to load class declared as >> >>>> <mapping >> >>>> class= >> >>>> "nl.msw.compraventa.core.model.Archive"/> in the configuration: >> >>>> >> >>>> Cheers, >> >>>> >> >>>> Marc >> >>>> >> >>>> >> >>>> mschipperheyn wrote: >> >>>> > >> >>>> > Right, ok. Hmm, getting a >> >>>> > Caused by: org.dbunit.DatabaseUnitException: >> >>>> > com.mysql.jdbc.exceptions.MySQLInte >> >>>> > grityConstraintViolationException: Cannot add or update a child >> row: >> >>>> a >> >>>> > foreign k >> >>>> > ey constraint fails (`compraventa/barrios`, CONSTRAINT >> >>>> > `FK4F5D3CCEB9857FF2` FORE >> >>>> > IGN KEY (`FK_CityId`) REFERENCES `cities` (`cityId`)) >> >>>> > >> >>>> > That's prob caused by the sample data -1 being inserted while >> there >> >>>> isn't >> >>>> > a City created yet. I'll try to appfuse:gen all those POJOs first >> to >> >>>> have >> >>>> > some coherent sample data. >> >>>> > >> >>>> > Cheers, >> >>>> > >> >>>> > Marc >> >>>> > >> >>>> > >> >>>> > >> >>>> > >> >>>> > >> >>>> > mraible wrote: >> >>>> >> >> >>>> >> In the core directory, you should run "mvn install", not "mvn >> >>>> >> appfuse:install". >> >>>> >> >> >>>> >> Matt >> >>>> >> >> >>>> >> On 10/29/07, mschipperheyn <[EMAIL PROTECTED]> wrote: >> >>>> >>> >> >>>> >>> Yes, completed without fail. However, I dont see any code >> generated >> >>>> in >> >>>> >>> the >> >>>> >>> core dir (I guess dont need that with universal stuff). Did see >> the >> >>>> >>> entries >> >>>> >>> in applicationContext.xml added. >> >>>> >>> >> >>>> >>> Marc >> >>>> >>> >> >>>> >>> D:\Java\Projects\CompraVenta\core>mvn appfuse:gen >> >>>> >>> [INFO] Scanning for projects... >> >>>> >>> [INFO] Searching repository for plugin with prefix: 'appfuse'. >> >>>> >>> [INFO] >> >>>> >>> >> >>>> >> ------------------------------------------------------------------------- >> >>>> >>> --- >> >>>> >>> [INFO] Building AppFuse Modular Application - Core >> >>>> >>> [INFO] task-segment: [appfuse:gen] >> >>>> >>> [INFO] >> >>>> >>> >> >>>> >> ------------------------------------------------------------------------- >> >>>> >>> --- >> >>>> >>> [INFO] Preparing appfuse:gen >> >>>> >>> [INFO] [aspectj:compile {execution: default}] >> >>>> >>> [INFO] [resources:resources] >> >>>> >>> [INFO] Using default encoding to copy filtered resources. >> >>>> >>> [INFO] [compiler:compile] >> >>>> >>> [INFO] Nothing to compile - all classes are up to date >> >>>> >>> [WARNING] POM for 'org.hibernate:jtidy:pom:r8-20060801:runtime' >> is >> >>>> >>> invalid. >> >>>> >>> It w >> >>>> >>> ill be ignored for artifact resolution. Reason: Parse error >> reading >> >>>> POM. >> >>>> >>> Reason: >> >>>> >>> TEXT must be immediately followed by END_TAG and not START_TAG >> >>>> >>> (position: >> >>>> >>> START >> >>>> >>> _TAG seen ...<licenses>\n\t\t\t<license>... @12:13) >> >>>> >>> [INFO] [appfuse:gen] >> >>>> >>> What is the name of your pojo (i.e. Person)?: Barrio >> >>>> >>> [INFO] Configuration XML file loaded: >> >>>> >>> D:\Java\Projects\CompraVenta\core\src\main >> >>>> >>> \resources\hibernate.cfg.xml >> >>>> >>> [INFO] Configuration XML file loaded: >> >>>> >>> D:\Java\Projects\CompraVenta\core\src\main >> >>>> >>> \resources\hibernate.cfg.xml >> >>>> >>> [INFO] src/main/resources/database.properties not found within >> the >> >>>> >>> project. >> >>>> >>> Tryi >> >>>> >>> ng absolute path. >> >>>> >>> [INFO] No hibernate properties file loaded. >> >>>> >>> [info] [AppFuse] Installing generated files (pattern: >> **/*.java)... >> >>>> >>> [info] [AppFuse] Installing sample data for DbUnit... >> >>>> >>> [info] [AppFuse] Installing Spring bean definitions... >> >>>> >>> [INFO] >> >>>> >>> >> >>>> >> ------------------------------------------------------------------------ >> >>>> >>> [INFO] BUILD SUCCESSFUL >> >>>> >>> [INFO] >> >>>> >>> >> >>>> >> ------------------------------------------------------------------------ >> >>>> >>> [INFO] Total time: 7 seconds >> >>>> >>> [INFO] Finished at: Mon Oct 29 17:09:08 CET 2007 >> >>>> >>> [INFO] Final Memory: 13M/23M >> >>>> >>> [INFO] >> >>>> >>> >> >>>> >> ------------------------------------------------------------------------ >> >>>> >>> >> >>>> >>> D:\Java\Projects\CompraVenta\core>mvn appfuse:install >> >>>> >>> [INFO] Scanning for projects... >> >>>> >>> [INFO] Searching repository for plugin with prefix: 'appfuse'. >> >>>> >>> [INFO] >> >>>> >>> >> >>>> >> ------------------------------------------------------------------------- >> >>>> >>> --- >> >>>> >>> [INFO] Building AppFuse Modular Application - Core >> >>>> >>> [INFO] task-segment: [appfuse:install] >> >>>> >>> [INFO] >> >>>> >>> >> >>>> >> ------------------------------------------------------------------------- >> >>>> >>> --- >> >>>> >>> [INFO] Preparing appfuse:install >> >>>> >>> [INFO] [aspectj:compile {execution: default}] >> >>>> >>> [INFO] [resources:resources] >> >>>> >>> [INFO] Using default encoding to copy filtered resources. >> >>>> >>> [INFO] [compiler:compile] >> >>>> >>> [INFO] Nothing to compile - all classes are up to date >> >>>> >>> [WARNING] POM for 'org.hibernate:jtidy:pom:r8-20060801:runtime' >> is >> >>>> >>> invalid. >> >>>> >>> It w >> >>>> >>> ill be ignored for artifact resolution. Reason: Parse error >> reading >> >>>> POM. >> >>>> >>> Reason: >> >>>> >>> TEXT must be immediately followed by END_TAG and not START_TAG >> >>>> >>> (position: >> >>>> >>> START >> >>>> >>> _TAG seen ...<licenses>\n\t\t\t<license>... @12:13) >> >>>> >>> [INFO] [appfuse:install] >> >>>> >>> What is the name of your pojo (i.e. Person)?: Barrio >> >>>> >>> [info] [AppFuse] Installing generated files (pattern: >> **/*.java)... >> >>>> >>> [info] [AppFuse] Installing sample data for DbUnit... >> >>>> >>> [info] [AppFuse] Installing Spring bean definitions... >> >>>> >>> [INFO] >> >>>> >>> >> >>>> >> ------------------------------------------------------------------------ >> >>>> >>> [INFO] BUILD SUCCESSFUL >> >>>> >>> [INFO] >> >>>> >>> >> >>>> >> ------------------------------------------------------------------------ >> >>>> >>> [INFO] Total time: 5 seconds >> >>>> >>> [INFO] Finished at: Mon Oct 29 17:09:27 CET 2007 >> >>>> >>> [INFO] Final Memory: 11M/23M >> >>>> >>> [INFO] >> >>>> >>> >> >>>> >> ------------------------------------------------------------------------ >> >>>> >>> -- >> >>>> >>> View this message in context: >> >>>> >>> >> >>>> >> http://www.nabble.com/app%3Agen--Unable-to-load-class-declared-as-mapping-class%3D%22xyz%22-in-the-configuration-tf4700458s2369.html#a13471891 >> >>>> >>> Sent from the AppFuse - User mailing list archive at Nabble.com. >> >>>> >>> >> >>>> >>> >> >>>> >> --------------------------------------------------------------------- >> >>>> >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >> >>>> >>> For additional commands, e-mail: [EMAIL PROTECTED] >> >>>> >>> >> >>>> >>> >> >>>> >> >> >>>> >> >> >>>> >> -- >> >>>> >> http://raibledesigns.com >> >>>> >> >> >>>> >> >> >>>> >> --------------------------------------------------------------------- >> >>>> >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> >>>> >> For additional commands, e-mail: [EMAIL PROTECTED] >> >>>> >> >> >>>> >> >> >>>> >> >> >>>> > >> >>>> > >> >>>> >> >>>> -- >> >>>> View this message in context: >> >>>> >> http://www.nabble.com/app%3Agen--Unable-to-load-class-declared-as-mapping-class%3D%22xyz%22-in-the-configuration-tf4700458s2369.html#a13474215 >> >>>> Sent from the AppFuse - User mailing list archive at Nabble.com. >> >>>> >> >>>> >> --------------------------------------------------------------------- >> >>>> To unsubscribe, e-mail: [EMAIL PROTECTED] >> >>>> For additional commands, e-mail: [EMAIL PROTECTED] >> >>>> >> >>>> >> >>> >> >>> >> >> >> >> >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/app%3Agen--Unable-to-load-class-declared-as-mapping-class%3D%22xyz%22-in-the-configuration-tf4700458s2369.html#a13475799 >> Sent from the AppFuse - User mailing list archive at Nabble.com. >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > > -- > http://raibledesigns.com > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/app%3Agen--Unable-to-load-class-declared-as-mapping-class%3D%22xyz%22-in-the-configuration-tf4700458s2369.html#a13594217 Sent from the AppFuse - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]