ignored @FilterDefs annotations in package-info.java when deployed in .WAR ?

495 views
Skip to first unread message

Hugo Lima

unread,
Sep 20, 2011, 3:52:48 AM9/20/11
to play-framework
Hello,

I'm having problems with @FilterDefs annotations in package-info.java
when deployed in .war... the error it throws is:

"...
JPA error
A JPA error occurred (Unable to build EntityManagerFactory): no filter
condition found for filter xFilter in yClass ..."

When I have the @FilterDefs annotations in yClass it runs without
problems.

any hint please?


Thanks in advance

Johan Vosloo

unread,
Sep 20, 2011, 5:27:55 PM9/20/11
to play-fr...@googlegroups.com
I just came across the same issue I believe. It seems to be related to precompilation.
In my case I also have @FilterDefs annotations in package-info.java, but I'm not deploying a war file.
Instead, I started the app with "play start --%prod".
Today I thought I'd change my pattern to precompile 1st (play precompile) and then start like this:
play start -Dprecompiled=true --%prod

It seems that during the precompilation step something goes wrong. It seemingly compiles fine - but when you start the app, I get the same error as Hugo.
Anyone any thoughts on this?

Hugo Lima

unread,
Sep 21, 2011, 4:03:20 PM9/21/11
to play-framework
I have no problem when running from Play! built-in server, just when
deployed to Tomcat with war....


On Sep 20, 10:27 pm, Johan Vosloo <jvos...@gmail.com> wrote:
> I just came across the same issue I believe. It seems to be related to
> precompilation.
> In my case I also have @FilterDefs annotations in package-info.java, but I'm
> not deploying a war file.
> Instead, I started the app with "*play start --%prod*".
> Today I thought I'd change my pattern to precompile 1st (play precompile)
> and then start like this:
> *play start -Dprecompiled=true --%prod*
> *
> *

Johan Vosloo

unread,
Sep 22, 2011, 2:24:34 AM9/22/11
to play-fr...@googlegroups.com
Interesting! So if you run the play built-in server and you precompile before start everything works fine?
Hmmm... then I wonder where the issue lies.
Anyone of the Lunatech guys have any ideas?

Morten Kjetland

unread,
Sep 22, 2011, 3:59:13 AM9/22/11
to play-fr...@googlegroups.com
I'm not working at Lunatech, but If you create a ticket with reproduce-steps (eg: simple test app/code), then I might have a look at it :)

-morten


--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/JuxaMoKgmhgJ.

To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.

Hugo Lima

unread,
Sep 22, 2011, 9:10:23 AM9/22/11
to play-framework
no, it works even without precompilation.... in built-in server only.

JS

unread,
Nov 15, 2011, 5:29:30 PM11/15/11
to play-framework
Have you already found a solution for this?
I experience the same problem, which is quite serious.

Steps to reproduce:
1. Add a filter like in this example:
http://www.lunatech-research.com/archives/2011/03/04/play-framework-writing-multitenancy-application-hibernate-filters
2. Run command "play precompile"
3. Run command "play start -Dprecompiled=true --%prod"

Thanks in advance,

Jürgen

JS

unread,
Nov 15, 2011, 5:53:54 PM11/15/11
to play-framework
This is the resulting stacktrace:

Exception in thread "main" play.exceptions.JPAException: Unable to
build EntityManagerFactory
at play.db.jpa.JPAPlugin.onApplicationStart(JPAPlugin.java:
231)
at
play.plugins.PluginCollection.onApplicationStart(PluginCollection.java:
425)
at play.Play.start(Play.java:495)
at play.Play.init(Play.java:292)
at play.server.Server.main(Server.java:158)
Caused by: org.hibernate.AnnotationException: no filter condition
found for filter xFilter in yClass
at
org.hibernate.cfg.annotations.EntityBinder.bindEntity(EntityBinder.java:
340)
at
org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:
586)
at org.hibernate.cfg.Configuration
$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:
3977)
at org.hibernate.cfg.Configuration
$MetadataSourceQueue.processMetadata(Configuration.java:3931)
at
org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:
1368)
at
org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1345)
at
org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:
1477)
at
org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:
193)
at
org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:
1096)
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:
900)
at play.db.jpa.JPAPlugin.onApplicationStart(JPAPlugin.java:
229)
... 4 more

On Nov 15, 11:29 pm, JS <juergen.stu...@googlemail.com> wrote:
> Have you already found a solution for this?
> I experience the same problem, which is quite serious.
>
> Steps to reproduce:
> 1. Add a filter like in this example:http://www.lunatech-research.com/archives/2011/03/04/play-framework-w...

Johan Vosloo

unread,
Nov 16, 2011, 7:48:36 AM11/16/11
to play-fr...@googlegroups.com
I still haven't sorted it out and haven't really had time to create a small sample app that illustrates the issue.
Perhaps if you have time, create one and open a ticket, as per Morten's request

JS

unread,
Nov 25, 2011, 4:37:25 PM11/25/11
to play-framework
Thanks to Erik Bakker. He gave me the tip to place the @FilterDefs to
the first (or all) model classes that trie to load the Filter.
This works with "play start -Dprecompiled=true --%prod" as well as on
the apache tomcat.

Johan Vosloo

unread,
Nov 27, 2011, 4:56:11 PM11/27/11
to play-fr...@googlegroups.com
I did this (i.e. removed theFilterDef from package.info and  placed it in the model objects directly) and now it works!
Thanks for the tip.

Reply all
Reply to author
Forward
0 new messages