<?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>Custom module throw NoClassDefFoundError when runtime</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=119677783" />
  <subtitle>Custom module throw NoClassDefFoundError when runtime</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=119677783</id>
  <updated>2026-05-05T00:06:09Z</updated>
  <dc:date>2026-05-05T00:06:09Z</dc:date>
  <entry>
    <title>RE: Custom module throw NoClassDefFoundError when runtime</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119687110" />
    <author>
      <name>mika mika</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119687110</id>
    <updated>2020-08-03T04:03:52Z</updated>
    <published>2020-08-03T04:03:52Z</published>
    <summary type="html">Thank you,I clear gradle cache and re-update dependencies  and it resolved this problem </summary>
    <dc:creator>mika mika</dc:creator>
    <dc:date>2020-08-03T04:03:52Z</dc:date>
  </entry>
  <entry>
    <title>RE: Custom module throw NoClassDefFoundError when runtime</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119684554" />
    <author>
      <name>Olaf Kock</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119684554</id>
    <updated>2020-07-31T12:51:18Z</updated>
    <published>2020-07-31T12:51:18Z</published>
    <summary type="html">&lt;div class="quote-title"&gt;mika mika:&lt;/div&gt;&lt;blockquote&gt;&lt;br /&gt;Hi Olaf Kock&lt;br /&gt;Thank for replying. I detect version of com.liferay.dynamic.data.lists.api is 2.1.10&lt;br /&gt;But I don&amp;#39;t know reason why it&amp;#39;s always replace in dependencies with version 3.0.4&lt;br /&gt;First I use compileOnnly. it doesn&amp;#39;t work&lt;br /&gt;I also use @Preference for DDLRecordSetLocalService but it still throws error ClassNotFound&lt;br /&gt;After that, I use compileInclude or -includeresource to include Jar com.liferay.dynamic.data.lists.api-2.1.10.jar into module. It still not work and throws error &amp;#34; [com.liferay.dynamic.data.lists.exporter.DDLExporterFactory(2810)] The addDDLExporter method has thrown an exception. java.lang.IllegalArgumentException: argument type mismatch&amp;#34;&lt;br /&gt;&lt;br /&gt;do you have any suggest for that?&lt;/blockquote&gt;&lt;br /&gt;compileInclude on Liferay&amp;#39;s own jars is a recipe for disaster, and &lt;strong&gt;must be avoided at all cost&lt;/strong&gt;. There&amp;#39;s &lt;strong&gt;no way&lt;/strong&gt; to make it work. Apparently (according to your comment) your version comes with API in version 2.1.10, and you&amp;#39;re including 2.0.0 - so you&amp;#39;re introducing a conflict. No wonder that there&amp;#39;s an argument type mismatch. &lt;br /&gt;&lt;br /&gt;With regards to &amp;#34;changing&amp;#34; dependency numbers, note that you&amp;#39;re declaring the dependency on the bundle&amp;#39;s version, but bnd later rewrites this to the package&amp;#39;s version, and they have nothing (much) to do with each other. &lt;br /&gt;&lt;br /&gt;Did you go through OSGi Basics, as suggested? No need to repeat here what&amp;#39;s covered there.</summary>
    <dc:creator>Olaf Kock</dc:creator>
    <dc:date>2020-07-31T12:51:18Z</dc:date>
  </entry>
  <entry>
    <title>RE: Custom module throw NoClassDefFoundError when runtime</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119678849" />
    <author>
      <name>mika mika</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119678849</id>
    <updated>2020-07-31T08:25:44Z</updated>
    <published>2020-07-31T08:25:44Z</published>
    <summary type="html">Hi Olaf Kock&lt;br /&gt;Thank for replying. I detect version of com.liferay.dynamic.data.lists.api is 2.1.10&lt;br /&gt;But I don&amp;#39;t know reason why it&amp;#39;s always replace in dependencies with version 3.0.4&lt;br /&gt;First I use compileOnnly. it doesn&amp;#39;t work&lt;br /&gt;I also use @Preference for DDLRecordSetLocalService but it still throws error ClassNotFound&lt;br /&gt;After that, I use compileInclude or -includeresource to include Jar com.liferay.dynamic.data.lists.api-2.1.10.jar into module. It still not work and throws error &amp;#34; [com.liferay.dynamic.data.lists.exporter.DDLExporterFactory(2810)] The addDDLExporter method has thrown an exception. java.lang.IllegalArgumentException: argument type mismatch&amp;#34;&lt;br /&gt;&lt;br /&gt;do you have any suggest for that?</summary>
    <dc:creator>mika mika</dc:creator>
    <dc:date>2020-07-31T08:25:44Z</dc:date>
  </entry>
  <entry>
    <title>RE: Custom module throw NoClassDefFoundError when runtime</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119680091" />
    <author>
      <name>Olaf Kock</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119680091</id>
    <updated>2020-07-31T07:36:05Z</updated>
    <published>2020-07-31T07:36:05Z</published>
    <summary type="html">&lt;div class="quote-title"&gt;mika mika:&lt;/div&gt;&lt;blockquote&gt;&lt;br /&gt;HiI&amp;#39;m facing with a problem. When I create a custom rest module and add dependency like this&lt;br /&gt;&lt;strong&gt;&lt;em&gt;         compileOnly group: &amp;#34;com.liferay&amp;#34;, name: &amp;#34;com.liferay.dynamic.data.lists.api&amp;#34;, version: &amp;#34;2.0.0&amp;#34;&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;and call service&lt;br /&gt;&lt;em&gt;&lt;strong&gt;         DDLRecordSetLocalServiceUtil.getRecordSet(recordSetId);&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;But when I call service, it thrown&lt;br /&gt;         &amp;#34;&lt;strong&gt;Caused by: java.lang.NoClassDefFoundError: com/liferay/dynamic/data/lists/service/DDLRecordSetLocalServiceUtil&lt;/strong&gt;&amp;#34;&lt;br /&gt;More stranger, when I import POI :&lt;br /&gt;    &lt;strong&gt;&lt;em&gt;         compileOnly group: &amp;#39;org.apache.poi&amp;#39;, name: &amp;#39;poi-ooxml&amp;#39;, version: &amp;#39;3.17&amp;#39;&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;    &lt;strong&gt;&lt;em&gt;         compileOnly group: &amp;#39;org.apache.poi&amp;#39;, name: &amp;#39;poi&amp;#39;, version: &amp;#39;3.17&amp;#39;&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;And call service to create Excel File, It thrown  the same error above. But I still founded those Libs in {liferay.home}/{tomcat.home}/webapps/ROOT/WEB-INF/lib&lt;br /&gt;I use liferay-ce-7.0-ga7Can anyone help me? Thank for helping&lt;/blockquote&gt;DDL: Most likely, you picked the wrong version: At compile time, version 2.0.0 is available, but at runtime it might be 1.4.5 or anything (I&amp;#39;m making this up - you&amp;#39;d have to look up what&amp;#39;s actually contained in 7.0.6 GA7.&lt;br /&gt;Related: Don&amp;#39;t use the *LocalServiceUtil in the OSGi context, rather inject a @Reference to the localService directly into your @Component.&lt;br /&gt;Obligatory link: Consider going through &lt;a href="https://university.liferay.com/osgi-basics"&gt;OSGi Basics&lt;/a&gt;.&lt;br /&gt;For POI, similar: At compile time, it&amp;#39;s no problem to provide the libraries. However, in the OSGi world, it&amp;#39;s not sufficient to just drop stuff into WEB-INF/lib - you&amp;#39;ll rather have to make it available to the OSGi runtime.&lt;br /&gt;At least for a while (probably still today) POI wasn&amp;#39;t packaged as OSGi bundle, so you might end up needing compileInclude, fattening your own bundle by packaging POI alongside. There&amp;#39;s also a chapter on this in the OSGi Basics course. In general: If you can get along without compileInclude, that&amp;#39;s preferable, but sometimes it just does the job.</summary>
    <dc:creator>Olaf Kock</dc:creator>
    <dc:date>2020-07-31T07:36:05Z</dc:date>
  </entry>
  <entry>
    <title>Custom module throw NoClassDefFoundError when runtime</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119677782" />
    <author>
      <name>mika mika</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119677782</id>
    <updated>2020-07-31T04:21:02Z</updated>
    <published>2020-07-31T04:21:02Z</published>
    <summary type="html">HiI&amp;#39;m facing with a problem. When I create a custom rest module and add dependency like this&lt;br /&gt;&lt;strong&gt;&lt;em&gt;         compileOnly group: &amp;#34;com.liferay&amp;#34;, name: &amp;#34;com.liferay.dynamic.data.lists.api&amp;#34;, version: &amp;#34;2.0.0&amp;#34;&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;and call service&lt;br /&gt;&lt;em&gt;&lt;strong&gt;         DDLRecordSetLocalServiceUtil.getRecordSet(recordSetId);&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;But when I call service, it thrown&lt;br /&gt;         &amp;#34;&lt;strong&gt;Caused by: java.lang.NoClassDefFoundError: com/liferay/dynamic/data/lists/service/DDLRecordSetLocalServiceUtil&lt;/strong&gt;&amp;#34;&lt;br /&gt;More stranger, when I import POI :&lt;br /&gt;    &lt;strong&gt;&lt;em&gt;         compileOnly group: &amp;#39;org.apache.poi&amp;#39;, name: &amp;#39;poi-ooxml&amp;#39;, version: &amp;#39;3.17&amp;#39;&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;    &lt;strong&gt;&lt;em&gt;         compileOnly group: &amp;#39;org.apache.poi&amp;#39;, name: &amp;#39;poi&amp;#39;, version: &amp;#39;3.17&amp;#39;&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;And call service to create Excel File, It thrown  the same error above. But I still founded those Libs in {liferay.home}/{tomcat.home}/webapps/ROOT/WEB-INF/lib&lt;br /&gt;I use liferay-ce-7.0-ga7Can anyone help me? Thank for helping</summary>
    <dc:creator>mika mika</dc:creator>
    <dc:date>2020-07-31T04:21:02Z</dc:date>
  </entry>
</feed>
