<?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>ClassCastException for using KBArticleLocalServiceUtil</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=120648091" />
  <subtitle>ClassCastException for using KBArticleLocalServiceUtil</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=120648091</id>
  <updated>2026-04-04T13:25:22Z</updated>
  <dc:date>2026-04-04T13:25:22Z</dc:date>
  <entry>
    <title>RE: RE: ClassCastException for using KBArticleLocalServiceUtil</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120657035" />
    <author>
      <name>Andrew Jardine</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120657035</id>
    <updated>2021-03-02T12:55:41Z</updated>
    <published>2021-03-02T12:55:41Z</published>
    <summary type="html">&lt;p&gt;Another one I think that causes this is, that has bitten me anyway,
  is when I have accidentally deployed the same module under two
  different names. Let's say for example I decided that I wanted to
  change the bundle symbolic name in the bnd. I can now deploy &amp;quot;a
  new&amp;quot; module but the contents of the module are the same as the
  old one. Both can be in the osgi/modules side by side with the same
  classes using the same canonical names. &lt;/p&gt;
&lt;p&gt;Any chance that you have done that by accident?&lt;/p&gt;</summary>
    <dc:creator>Andrew Jardine</dc:creator>
    <dc:date>2021-03-02T12:55:41Z</dc:date>
  </entry>
  <entry>
    <title>RE: ClassCastException for using KBArticleLocalServiceUtil</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120654530" />
    <author>
      <name>Andrew Jardine</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120654530</id>
    <updated>2021-03-01T17:16:42Z</updated>
    <published>2021-03-01T17:16:42Z</published>
    <summary type="html">&lt;p&gt;Just want to throw out a long shot here. I had a similar issue a few
  weeks back. In my build.gradle file I was using the new
  release.portal.api dependency. When I was importging my models I
  wasn't paying attention and I imported the model from the Headles API
  instead of the model from the service API.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Again, a long shot, but one more thing to cross off the list. Can you
  double check to make sure that your KBArticle is referencing the
  correct class?&lt;/p&gt;</summary>
    <dc:creator>Andrew Jardine</dc:creator>
    <dc:date>2021-03-01T17:16:42Z</dc:date>
  </entry>
  <entry>
    <title>RE: ClassCastException for using KBArticleLocalServiceUtil</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120653861" />
    <author>
      <name>Christoph Rabel</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120653861</id>
    <updated>2021-02-28T19:46:05Z</updated>
    <published>2021-02-28T19:46:05Z</published>
    <summary type="html">&lt;p&gt;Can you look inside the generated jar file of your module? To make
  sure, only your files are in there and no Liferay classes?&lt;/p&gt;
&lt;p&gt;Maybe it helps to change the dependency to compileOnly (instead of compile).&lt;/p&gt;
&lt;p&gt;Also, please check the osgi/* folders, maybe there are two versions
  of the knowledge base jar file deployed. e.g. one in the marketplace,
  one in the modules folder.&lt;/p&gt;</summary>
    <dc:creator>Christoph Rabel</dc:creator>
    <dc:date>2021-02-28T19:46:05Z</dc:date>
  </entry>
  <entry>
    <title>RE: ClassCastException for using KBArticleLocalServiceUtil</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120644453" />
    <author>
      <name>Nirav Prajapati</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120644453</id>
    <updated>2021-02-26T07:16:24Z</updated>
    <published>2021-02-25T23:40:31Z</published>
    <summary type="html">&lt;p&gt;Hi Chris,&lt;/p&gt;
&lt;p&gt;Yes, I have added compile dependency in build.gradle. I have not
  mentioned any specific version so it has taken automatically.&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;    compile group: 'com.liferay', name:
    'com.liferay.knowledge.base.api'&lt;br /&gt;    compile group:
    'com.liferay', name: 'com.liferay.knowledge.base.service'&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Even the same code and dependency are working with a different module (portlet).&lt;/p&gt;
&lt;p&gt;But getting exceptions while using KBArticle in service builder only.&lt;/p&gt;
&lt;p&gt;Multiple times I did clean restart the server with no luck...&lt;/p&gt;</summary>
    <dc:creator>Nirav Prajapati</dc:creator>
    <dc:date>2021-02-25T23:40:31Z</dc:date>
  </entry>
  <entry>
    <title>RE: ClassCastException for using KBArticleLocalServiceUtil</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120648378" />
    <author>
      <name>Christoph Rabel</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120648378</id>
    <updated>2021-02-25T18:26:09Z</updated>
    <published>2021-02-25T18:26:09Z</published>
    <summary type="html">&lt;p&gt;Did you per chance include the service into your module?&lt;/p&gt;
&lt;p&gt;e.g. in build.gradle by using compileInclude? The error means that
  there are two versions of the service available. Maybe check the
  deploy folder, delete the osgi/state folder and especially, check your module.&lt;/p&gt;</summary>
    <dc:creator>Christoph Rabel</dc:creator>
    <dc:date>2021-02-25T18:26:09Z</dc:date>
  </entry>
  <entry>
    <title>ClassCastException for using KBArticleLocalServiceUtil</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120648090" />
    <author>
      <name>Nirav Prajapati</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120648090</id>
    <updated>2021-02-25T12:26:50Z</updated>
    <published>2021-02-25T12:26:50Z</published>
    <summary type="html">&lt;p&gt;Hi Friends,&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;I am using Liferay 7.2&lt;/p&gt;
&lt;p&gt;I have used KBArticle into XXXLocalServiceImpl using the below code.&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;KBArticle kbArticle = KBArticleLocalServiceUtil.getKBArticle(12345, WorkflowConstants.STATUS_ANY);&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;But it's throwing an exception as,&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;
    &lt;strong&gt;java.lang.ClassCastException: com.sun.proxy.$Proxy595 cannot
      be cast to com.liferay.knowledge.base.service.KBArticleLocalService&lt;/strong&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Instead of KBArticleLocalServiceUtil, I have used the below code, but
  again getting the same exceptions.&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;    @Reference&lt;br /&gt;    private KBArticleLocalService _KbArticleLocalService;&lt;/p&gt;
  &lt;p&gt;    KBArticle kbArticle =
    _KbArticleLocalService.getKBArticle(12345, WorkflowConstants.STATUS_ANY);&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Please help me to resolve the issue.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Thanks in Advance&lt;/p&gt;</summary>
    <dc:creator>Nirav Prajapati</dc:creator>
    <dc:date>2021-02-25T12:26:50Z</dc:date>
  </entry>
</feed>
