<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>org.hibernate.MappingException: Unknown entity: &lt;namespace&gt;.FooImpl</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=110826259" />
  <subtitle>org.hibernate.MappingException: Unknown entity: &lt;namespace&gt;.FooImpl</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=110826259</id>
  <updated>2026-04-04T22:30:58Z</updated>
  <dc:date>2026-04-04T22:30:58Z</dc:date>
  <entry>
    <title>RE: org.hibernate.MappingException: Unknown entity: &lt;namespace&gt;.FooImpl</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111170636" />
    <author>
      <name>Christopher Virtucio</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111170636</id>
    <updated>2018-10-08T19:31:53Z</updated>
    <published>2018-10-08T19:31:53Z</published>
    <summary type="html">&lt;blockquote&gt;
  &lt;div class="quote-title"&gt;John O'Flaherty:&lt;/div&gt;
  &lt;div class="quote"&gt;
    &lt;div class="quote-content"&gt;
      &lt;p&gt;Hi, did you ever manage to track this error down ? &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;We had &amp;lt;hbmFileName/&amp;gt; configured to portlet-hbm.xml (the
  pre-DXP naming convention). We filed a LESA ticket and basically, we
  needed to change that value to module-hbm.xml. They don't mention this
  in the documentation; they expect you to infer this from their
  samples. And apparently they've changed the naming convention again in
  7.1: it's now port&lt;strong&gt;al&lt;/strong&gt;-hbm.xml (hooray.. more obscure changes).&lt;/p&gt;
&lt;p&gt;So the lesson here is, Liferay's documentation just isn't enough.. go
  through their source code, and make sure your implementations match
  their samples 1:1.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;</summary>
    <dc:creator>Christopher Virtucio</dc:creator>
    <dc:date>2018-10-08T19:31:53Z</dc:date>
  </entry>
  <entry>
    <title>RE: org.hibernate.MappingException: Unknown entity: &lt;namespace&gt;.FooImpl</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111120922" />
    <author>
      <name>John O'Flaherty</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111120922</id>
    <updated>2018-10-03T11:00:14Z</updated>
    <published>2018-10-03T11:00:14Z</published>
    <summary type="html">&lt;p&gt;Hi, did you ever manage to track this error down ? &lt;/p&gt;</summary>
    <dc:creator>John O'Flaherty</dc:creator>
    <dc:date>2018-10-03T11:00:14Z</dc:date>
  </entry>
  <entry>
    <title>RE: org.hibernate.MappingException: Unknown entity: &lt;namespace&gt;.FooImpl</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110844601" />
    <author>
      <name>Christopher Virtucio</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110844601</id>
    <updated>2018-08-30T13:11:39Z</updated>
    <published>2018-08-30T13:11:39Z</published>
    <summary type="html">&lt;blockquote&gt;
  &lt;div class="quote-title"&gt;Minhchau Dang:&lt;/div&gt;
  &lt;div class="quote"&gt;
    &lt;div class="quote-content"&gt;
      &lt;blockquote&gt;
        &lt;div class="quote-title"&gt;Christopher Virtucio:&lt;/div&gt;
        &lt;div class="quote"&gt;
          &lt;div class="quote-content"&gt;
            &lt;p&gt;Tried using the FooPersistence.findByUserId( long userId
              ) method (probably created by the service builder in my
              last run?) instead of using my Finder class. I got a
              different exception this time:&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;
      &lt;p&gt;Strange. If even the Persistence isn't able to figure out what
        to do with the Hibernate mapping file, that says something is
        wrong with the thread context classloader, so something
        somewhere is classloader hopping. Does it work if you swap the
        thread context classloader to the FinderImpl classloader?&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;I set the thread context classLoader in the LocalService's
  findByUserId method to that of the FinderImpl, but it still threw the
  same exception. The same was true when I set it to the Persistence's classLoader.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;However, when the classLoader is set to the FinderImpl, calling the
  FinderImpl's find method no longer throws the Unknown Entity
  exception. And it also results in an empty list, which is not supposed
  to be the case since records in the table exist for the given userId
  that I'm passing (my dynamicQuery has the restriction of
  Restrictions.eq( &amp;quot;userId&amp;quot;, userId )). Calling the method
  &lt;em&gt;without&lt;/em&gt; the restriction also results in an empty list.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;</summary>
    <dc:creator>Christopher Virtucio</dc:creator>
    <dc:date>2018-08-30T13:11:39Z</dc:date>
  </entry>
  <entry>
    <title>RE: org.hibernate.MappingException: Unknown entity: &lt;namespace&gt;.FooImpl</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110838802" />
    <author>
      <name>Minhchau Dang</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110838802</id>
    <updated>2018-08-30T01:12:20Z</updated>
    <published>2018-08-30T01:12:20Z</published>
    <summary type="html">&lt;blockquote&gt;
  &lt;div class="quote-title"&gt;Christopher Virtucio:&lt;/div&gt;
  &lt;div class="quote"&gt;
    &lt;div class="quote-content"&gt;
      &lt;p&gt;Tried using the FooPersistence.findByUserId( long userId )
        method (probably created by the service builder in my last run?)
        instead of using my Finder class. I got a different exception
        this time:&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;Strange. If even the Persistence isn't able to figure out what to do
  with the Hibernate mapping file, that says something is wrong with the
  thread context classloader, so something somewhere is classloader
  hopping. Does it work if you swap the thread context classloader to
  the FinderImpl classloader?&lt;/p&gt;</summary>
    <dc:creator>Minhchau Dang</dc:creator>
    <dc:date>2018-08-30T01:12:20Z</dc:date>
  </entry>
  <entry>
    <title>RE: org.hibernate.MappingException: Unknown entity: &lt;namespace&gt;.FooImpl</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110832659" />
    <author>
      <name>Christopher Virtucio</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110832659</id>
    <updated>2018-08-29T13:53:23Z</updated>
    <published>2018-08-29T13:53:23Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;blockquote&gt;
  &lt;div class="quote-title"&gt;Minhchau Dang:&lt;/div&gt;
  &lt;div class="quote"&gt;
    &lt;div class="quote-content"&gt;
      &lt;blockquote&gt;
        &lt;div class="quote-title"&gt;Christopher Virtucio:&lt;/div&gt;
        &lt;div class="quote"&gt;
          &lt;div class="quote-content"&gt;
            &lt;pre&gt;
org.hibernate.MappingException: Unknown entity: &amp;lt;namespace&amp;gt;.FooImpl&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;
      &lt;p&gt;The only things I can think of that would result in that
        exception are either a missing mapping file (so the mapping file
        does not get included in the service module), or the wrong
        classloader is used when calling the service (since the
        classloader governs the mapping file that gets used).&lt;/p&gt;
      &lt;p&gt;Assuming you're not doing any classloader switching, does the
        compiled .jar have a &lt;a href="https://github.com/liferay/liferay-blade-samples/blob/7.1/maven/apps/service-builder/basic/basic-service/src/main/resources/META-INF/module-hbm.xml"&gt;module-hbm.xml&lt;/a&gt;
        file in it?&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The hbm file is in the jar.&lt;/p&gt;
&lt;p&gt;As for the classLoader, I tried the following:&lt;/p&gt;
&lt;p&gt;1) passing just Foo.class to the DynamicQueryFactoryUtil.forClass() method&lt;/p&gt;
&lt;p&gt;2) passing Foo.class and the FinderImpl's classLoader to the
  DynamicQueryFactoryUtil.forClass() method&lt;/p&gt;
&lt;p&gt;3) using the FooLocalServiceUtil.dynamicQuery() method (which uses
  its own classLoader under the hood) to create the query, instead of DynamicQueryFactoryUtil.forClass()&lt;/p&gt;
&lt;p&gt;None of these worked. I even stepped through the code in the debugger
  to verify that the right classLoader was being used, and that the
  FooImpl class was being retrieved from that classLoader. It's during
  the call to FooLocalServiceUtiil.dynamicQuery( DynamicQuery
  dynamicQuery ) that the exception is thrown.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;EDIT:&lt;/p&gt;
&lt;p&gt;Tried using the FooPersistence.findByUserId( long userId ) method
  (probably created by the service builder in my last run?) instead of
  using my Finder class. I got a different exception this time:&lt;/p&gt;
&lt;p&gt;
  &lt;code&gt;com.liferay.portal.kernel.exception.SystemException:
    com.liferay.portal.kernel.dao.orm.ORMException:
    org.hibernate.QueryException: in expected: foo [SELECT foo FROM Foo
    foo WHERE foo.userId = ?]&lt;/code&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Christopher Virtucio</dc:creator>
    <dc:date>2018-08-29T13:53:23Z</dc:date>
  </entry>
  <entry>
    <title>RE: org.hibernate.MappingException: Unknown entity: &lt;namespace&gt;.FooImpl</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110827261" />
    <author>
      <name>Minhchau Dang</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110827261</id>
    <updated>2018-08-29T00:33:40Z</updated>
    <published>2018-08-29T00:33:40Z</published>
    <summary type="html">&lt;blockquote&gt;
  &lt;div class="quote-title"&gt;Christopher Virtucio:&lt;/div&gt;
  &lt;div class="quote"&gt;
    &lt;div class="quote-content"&gt;
      &lt;pre&gt;
org.hibernate.MappingException: Unknown entity: &amp;lt;namespace&amp;gt;.FooImpl&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;The only things I can think of that would result in that exception
  are either a missing mapping file (so the mapping file does not get
  included in the service module), or the wrong classloader is used when
  calling the service (since the classloader governs the mapping file
  that gets used).&lt;/p&gt;
&lt;p&gt;Assuming you're not doing any classloader switching, does the
  compiled .jar have a &lt;a
  href="https://github.com/liferay/liferay-blade-samples/blob/7.1/maven/apps/service-builder/basic/basic-service/src/main/resources/META-INF/module-hbm.xml"&gt;module-hbm.xml&lt;/a&gt;
  file in it?&lt;/p&gt;</summary>
    <dc:creator>Minhchau Dang</dc:creator>
    <dc:date>2018-08-29T00:33:40Z</dc:date>
  </entry>
  <entry>
    <title>org.hibernate.MappingException: Unknown entity: &lt;namespace&gt;.FooImpl</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110826258" />
    <author>
      <name>Christopher Virtucio</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110826258</id>
    <updated>2018-08-28T22:01:02Z</updated>
    <published>2018-08-28T22:01:02Z</published>
    <summary type="html">&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;I created a finder class with a finder method, that gets called by a
  LocalService, following this documentation: &lt;a
  href="https://dev.liferay.com/es/develop/tutorials/-/knowledge_base/7-1/defining-service-entity-finder-methods."&gt;https://dev.liferay.com/es/develop/tutorials/-/knowledge_base/7-1/defining-service-entity-finder-methods.&lt;/a&gt;
  However, calling the methods results in the exception stated in this
  thread's title. I've gone through several archived threads like &lt;a
  href="https://community.liferay.com/de/forums/-/message_boards/message/7073038"&gt;this&lt;/a&gt;
  one, but the solutions mentioned don't solve the problem.
  Specifically, I've tried leveraging the LocalServiceUtil's
  dynamicQuery API instead of the DynamicQueryFactory, and it still
  results in the MappingException.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Any ideas on a good path I can take?&lt;/p&gt;</summary>
    <dc:creator>Christopher Virtucio</dc:creator>
    <dc:date>2018-08-28T22:01:02Z</dc:date>
  </entry>
</feed>
