Search code examples
javaormapache-cayenne

CayenneModeler not generating Cayenne.xml


I am learning Apache Cayenne, so I am new to it.

I am following the official guide http://cayenne.apache.org/docs/3.0/tutorial.html.

I am doing exactly the same as the guide says, but when I save the project, it's generating 2 xml files, instead of 3, and when I run the java app (using the classes generated) following error appears:

Exception in thread "main" org.apache.cayenne.ConfigurationException: [v.3.0RC2 Feb 03 2010 13:38:54] Error during Configuration initialization. [v.3.0RC2 Feb 03 2010 13:38:54] [org.apache.cayenne.conf.DefaultConfiguration] : Domain configuration file "cayenne.xml" is not found.
    at org.apache.cayenne.conf.Configuration.initializeSharedConfiguration(Configuration.java:168)
    at org.apache.cayenne.conf.Configuration.initializeSharedConfiguration(Configuration.java:141)
    at org.apache.cayenne.conf.Configuration.initializeSharedConfiguration(Configuration.java:121)
    at org.apache.cayenne.conf.Configuration.getSharedConfiguration(Configuration.java:91)
    at org.apache.cayenne.access.DataContext.createDataContext(DataContext.java:143)
    at org.example.cayenne.Main.main(Main.java:21)
Caused by: org.apache.cayenne.ConfigurationException: [v.3.0RC2 Feb 03 2010 13:38:54] [org.apache.cayenne.conf.DefaultConfiguration] : Domain configuration file "cayenne.xml" is not found.
    at org.apache.cayenne.conf.DefaultConfiguration.initialize(DefaultConfiguration.java:141)
    at org.apache.cayenne.conf.Configuration.initializeSharedConfiguration(Configuration.java:159)
    ... 5 more

I don't know what happened


Solution

  • I think I know what's going on. If you look at the exception, your stack trace indicates Cayenne version being v.3.0RC2. This is a version of the runtime. 2 files (one of which is called something like "cayenne-project.xml"), were generated by the Modeler version 3.1. You need to ensure that both the Modeler and the runtime are of the same release.

    3.1 Tutorial seems to be correct in respect to the actual files in the project:

    http://cayenne.apache.org/docs/3.1/tutorial/ch02.html#create-new-project