2 Replies Latest reply on Jun 29, 2012 11:42 PM by David Forrest

    @NamedQuery in war file

    David Forrest Newbie

      I have a webapp that uses hibernate with @NamedQuery & @NamedQueries. On deployment, everything works fine, except when I use named queries where JBoss 7.1.1/Hibernate tells me that there are no named queries by that name. If I deploy the webapp unarchived, everything works 100%. Why is this, or is there something I am doing wrong?


      Feel free to ask if you need more information.

        • 1. Re: @NamedQuery in war file
          Scott Marlow Master

          Show us some more details.  Paste or attach your configuration file source (persistence.xml), the java source where you defined the NamedQuery/NamedQueries.  Also, get a list of the files in your war (do a "jar tf YourWebApp.war") and attach/paste that here as well.


          Then enable TRACE logging for org.hibernate and org.jboss.as.jpa (see troubleshooting guide here for details).  After deploying the application and getting the error, attach the AS7/standalone/log/server.log which might give us some ideas.


          Lastly, do you know which tool is being used to create the war file (perhaps the Java jar tool)? 



          1 of 1 people found this helpful
          • 2. Re: @NamedQuery in war file
            David Forrest Newbie

            Hey, sorry for the late response, I forgot all about posting my results since I solved it. Scott, thanks for the advice, the logs help me solve it before I thought about posting the results.


            We were searching for Entity classes at runtime during migration from an ancient PHP system. And since the ClassLoader could see the file system class files, searching worked fine. In JBoss, those classes don't exist. I then looked at the scheme for the file URI and got vfs: something. I found https://github.com/jbossas/jboss-vfs/, added it as a dependency, and wrote a solution with VFS & VirtualFile.


            Everything works fine now and we don't have to use any <mapped class=".." /> in our configuration file. If anyone is interested in the actual code, I'll see if I can get permission to release it.