質問

I have a portlet project that needs to do some Group querying. I've not created the project but it was made with the Eclipse Liferay SDK plugin.

I've added a DynamicQueryFactoryUtil.forClass(Group.class) but it fails in runtime. It complains about not finding GroupImpl.class, which is implementation for interface Group. My project dependencies doesn't include portlet-impl (it contains GroupImpl.class).

I'm not sure if I should:

  • include that jar into dependencies for compiling
  • include that jar into portlet jar

Or I'm doing something wrong and querying groups would be available right out of the box.

PS: I'm pretty newbie in Liferay things...

PS2: It's Liferay 6.1

役に立ちましたか?

解決

To enable Liferay to retrieve the right class, you need to provide a correct classloader to the initialization of your DynamicQuery, in this case the portal's classloader because that one has access to the model implementations:

 DynamicQueryFactoryUtil.forClass(Group.class, PortalClassLoaderUtil.getClassLoader())
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top