Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use Spring Roo domain model in a regular web app
    text
    copied!<p>I have built a little model using Roo. There are 6 objects in the model that have various relationships - it was neat, it took like 20 minutes! Now that I have it, I want to create Spring MVC project and use the domain model - but I want to keep the web project totally separate from the Roo project (I don't understand Spring MVC to use the scaffolding in Roo yet).</p> <p>So I've created the dependency in the pom.xml of the web project and I can build and deploy the web project using 'mvn tomcat:run'. However, when the web tries to use the Spring Roo objects I get exceptions like this:</p> <pre><code>java.lang.IllegalStateException: Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?) at com.loquatic.clcmops.consignortool.entities.Consignor_Roo_Jpa_ActiveRecord.entityManager_aroundBody0(Consignor_Roo_Jpa_ActiveRecord.aj:19) at com.loquatic.clcmops.consignortool.entities.Consignor_Roo_Jpa_ActiveRecord.ajc$interMethod$com_loquatic_clcmops_consignortool_entities_Consignor_Roo_Jpa_ActiveRecord$com_loquatic_clcmops_consignortool_entities_Consignor$entityManager(Consignor_Roo_Jpa_ActiveRecord.aj:1) at com.loquatic.clcmops.consignortool.entities.Consignor.entityManager(Consignor.java:1) </code></pre> <p>I have done this in a standalone project for a project where I had a class that had a main() method and I had to add a line of code to get the context loaded correctly (this basically: <a href="https://stackoverflow.com/questions/3284496/how-to-use-junit-tests-with-spring-roo-problems-with-entitymanager">How to use JUnit tests with Spring Roo? (Problems with EntityManager)</a> ). This being Spring MVC I sort of assumed it was happening automagically - I am obviously mistaken.</p> <p>So do I need to do something in the web project to get the context loaded for the Roo jar file? Or do I need to change something in the roo jar file project? Do I need annotate a controller with something to make this happy? </p> <p>I've tried adding the following to the pom.xml in the web project:</p> <pre><code> &lt;dependency&gt; &lt;groupId&gt;org.springframework&lt;/groupId&gt; &lt;artifactId&gt;spring-aop&lt;/artifactId&gt; &lt;version&gt;${org.springframework-version}&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework&lt;/groupId&gt; &lt;artifactId&gt;spring-aspects&lt;/artifactId&gt; &lt;version&gt;${org.springframework-version}&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>and</p> <pre><code> &lt;dependency&gt; &lt;groupId&gt;org.aspectj&lt;/groupId&gt; &lt;artifactId&gt;aspectjrt&lt;/artifactId&gt; &lt;version&gt;${org.aspectj-version}&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.aspectj&lt;/groupId&gt; &lt;artifactId&gt;aspectjweaver&lt;/artifactId&gt; &lt;version&gt;${org.aspectj-version}&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>But that hasn't changed anything - and this is some serious guess work, too. </p> <p>Anyone have any pointers? How are you supposed to use a Spring domain model in another project that isn't necessarily a Roo project?</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload