RE: Unable find model model.impl.TestImpl java.lang.ClassNotFoundException:

thumbnail
Kiran Yalavali, modified 7 Years ago. Regular Member Posts: 175 Join Date: 10/15/14 Recent Posts

Hi All,

currently I'm working on Liferay dxp EE 

How to Resolve this issue  [DynamicQueryFactoryImpl:103] Unable find model model.impl.TestImpl
java.lang.ClassNotFoundException: model.impl.TestImpl 

But In liferay dxp i'm using below dynamic query

DynamicQuery dynn = TestLocalServiceUtil.dynamicQuery();

 

Please advice me it's very helpful.

 

Kiran.

 

 

thumbnail
David H Nebinger, modified 7 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts

If you are using DXP, you should not be using the static util class.

 

Change over to the TestLocalService and have it injected using OSGi's @Reference annotation.

thumbnail
Kiran Yalavali, modified 7 Years ago. Regular Member Posts: 175 Join Date: 10/15/14 Recent Posts

Thanks david for your quick response,

these issue was resolved following below code for change in Liferay DXP.

In liferay 6.2   DynamicQuery dynamic =DynamicQueryFactoryUtil.forClass(Test.class);

In liferay DXP   DynamicQuery dynamic = TestLocalServiceUtil.dynamicQuery();

 

Thanks,

Kiran.

 

thumbnail
David H Nebinger, modified 7 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts

Right, but for DXP you should not use TestLocalServiceUtil.

Instead, your class should have the @Component annotation, then somewhere inside you'd have like:

@Reference<br> private TestLocalService _testLocalService;

Then your actual Liferay DXP code becomes:

DynamicQuery dynamic = _testLocalService.dynamicQuery();

Also, as  a side note, in 6.2 you could also (and should also) have used TestLocalService.dynamicQuery() as it avoids the class loader issues.