Note that there are some explanatory texts on larger screens.

plurals
  1. POError with the .class location when building a WAR for a Play! framework application
    text
    copied!<p>I'm working on a 1.2 Play! framework application, and I have a problem when deploying it as a WAR on a Tomcat 6.</p> <p>One page of my application displays a list of information. These information are retrieved from a <code>.yml</code> file. So I have a controller that generate a <code>Iterable&lt;Object&gt;</code> from this <code>.yml</code> file, like that:</p> <pre><code>public static void myFunction() { Constructor constructor = new Constructor(MyClass.class); // org.yaml.snakeyaml.constructor.Constructor constructor.addTypeDescription(new TypeDescription(MyClass.class)); Yaml yaml = new Yaml(constructor); Iterable&lt;Object&gt; listOfInfo = yaml.loadAll(Application.class.getResourceAsStream("/my-file.yml")); render("Application/my-page.html", listOfInfo); } </code></pre> <p>The important point is that <code>MyClass</code> is located in the <code>app/my/company/my-app/</code> package (<code>my.company.my-app.MyClass</code>).</p> <p>When I run my application using <code>play run</code>, there is no problem.</p> <p>Now, I build the WAR package (using <code>play war -o some/dir --zip</code>), and I install this generated WAR on a Tomcat (6.0). Once the server is started, and try to access the corresponding page, I get the following error:</p> <pre><code>@683lh76fn Internal Server Error (500) Template execution error (In /app/views/Application/my-page.html around line 9) Execution error occured in template /app/views/Application/my-page.html. Exception raised was ConstructorException : null; Can't construct a java object f or tag:yaml.org,2002:my.company.my-app.MyClass; exception=Class not found: my.company.my-app.MyClass. play.exceptions.TemplateExecutionException: null; Can't construct a java object for tag:yaml.org,2002:my.company.my-app.MyClass; exception =Class not found: my.company.my-app.MyClass at play.templates.BaseTemplate.throwException(BaseTemplate.java:84) at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:252) at play.templates.Template.render(Template.java:26) at play.templates.GroovyTemplate.render(GroovyTemplate.java:184) at play.mvc.results.RenderTemplate.&lt;init&gt;(RenderTemplate.java:24) at play.mvc.Controller.renderTemplate(Controller.java:659) at play.mvc.Controller.renderTemplate(Controller.java:639) at play.mvc.Controller.render(Controller.java:694) at controllers.Application.myFunction(Application.java:311) </code></pre> <p>If I have a look in the exploded war, I see that <code>my.company.my-app.MyClass</code> is located in the directory <code>WEB-INF/application/precompiled/java/my/company/my-app/</code> directory.</p> <p>If I move this directory into <code>WEB-INF/classes</code>, then I don't get this error anymore.</p> <p>Why does this error occurs? What are my options to make it work (without modifying manually the WAR)?</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