I have two plugin portlets. First has service builder with all entities. Second portlet is using service's jar file to execute Dynamic query.
I am using first's service jar in my second plugin portlet to interact with database. But in this jar file there is not any Impl class. Thats why i am getting error Impl Class not found. Below is for reference:
DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(XXX.class,
PortletClassLoaderUtil.getClassLoader());
try {
XXXLocalServiceUtil.dynamicQuery(dynamicQuery);
} catch (SystemException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Error: [DynamicQueryFactoryImpl:96] Unable find model com.compass.model.impl.XXXImpl java.lang.ClassNotFoundException: com.compass.model.impl.XXXImpl
Nomal Functions are working fine of service builder
just don't use the DynamicQueryFactoryUtil but the XXXLocalServiceUtil this way
DynamicQuery dynamicQuery = XXXLocalServiceUtil.dynamicQuery()
try {
XXXLocalServiceUtil.dynamicQuery(dynamicQuery);
} catch (SystemException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
If you want to use the factory you have to use the interface model not the impl of the entity so if you have an entity FooImpl sue the Foo.class and use the classloder of you service plugin portlet
Classloader cl =(ClassLoader) PortletBeanLocatorUtil.locate("services-portlet", "portletClassLoader");
DynamicQueryFactoryUtil.forClass(XXX.class, cl);