Foren

DefaultLandingPageAction Hook - class not found Exception

thumbnail
Gnaniyar Zubair, geändert vor 12 Jahren.

DefaultLandingPageAction Hook - class not found Exception

Liferay Master Beiträge: 722 Beitrittsdatum: 19.12.07 Neueste Beiträge
Hi,

I've developed event hook for DefaultLandingPageAction with my CustomDefaultPageAction through hooks plugin in Liferay 6. But I am getting CLASS NOT FOUND EXCEPTION for this class PrefsPropsUtil

[b]import com.liferay.portal.util.PrefsPropsUtil;[/b]


which is loaded from portal-impl. It is fixed when i change that path to portal-kernel path

[b]import com.liferay.portal.kernel.util.PrefsPropsUtil[/b];


Actually, other classes mentioned below which are loaded from portal-impl , are not throwing any exception.

[b]import com.liferay.portal.util.PortalUtil;  
import com.liferay.portal.util.WebKeys[/b];


issue with only PrefsPropsUtil. Can anybody throw some lights on this?

Thanks

Gnaniyar Zubair
thumbnail
Ravi Kumar Gupta, geändert vor 12 Jahren.

RE: DefaultLandingPageAction Hook - class not found Exception

Liferay Legend Beiträge: 1302 Beitrittsdatum: 24.06.09 Neueste Beiträge
Thats strange.. I just created one and its working fine..


import com.liferay.portal.kernel.events.Action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.liferay.portal.kernel.events.ActionException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.struts.LastPath;
import com.liferay.portal.kernel.util.PrefsPropsUtil;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.util.PortalUtil;

public class MyCustomPostAction extends Action {
	/* (non-Java-doc)
	 * @see com.liferay.portal.kernel.events.Action#Action()
	 */
	public MyCustomPostAction() {
		super();
	}

	/* (non-Java-doc)
	 * @see com.liferay.portal.kernel.events.Action#run(HttpServletRequest request, HttpServletResponse response)
	 */
	public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException {
		long companyId = PortalUtil.getCompanyId(request);

		String path = null;
		try {
			path = PrefsPropsUtil.getString(
				companyId, PropsKeys.DEFAULT_LANDING_PAGE_PATH);
			System.out.println("I am doing something..");
		} catch (SystemException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		if (_log.isInfoEnabled()) {
			_log.info(
				PropsKeys.DEFAULT_LANDING_PAGE_PATH + StringPool.EQUAL + path);
		}

		if (Validator.isNotNull(path)) {
			LastPath lastPath = new LastPath(StringPool.BLANK, path);

			HttpSession session = request.getSession();

			session.setAttribute(WebKeys.LAST_PATH, lastPath);
		}
	}
	private static Log _log = LogFactoryUtil.getLog(
			MyCustomPostAction.class);
}
thumbnail
Ravi Kumar Gupta, geändert vor 12 Jahren.

RE: DefaultLandingPageAction Hook - class not found Exception

Liferay Legend Beiträge: 1302 Beitrittsdatum: 24.06.09 Neueste Beiträge
And yes,

By default when I copied the content eclipse imported classes from portal-impl for which I got the error while compiling.. I had to modify the imports and its working fine now.. consider deleting temp, work folders..emoticon
pspyra pspyra, geändert vor 10 Jahren.

RE: DefaultLandingPageAction Hook - class not found Exception

New Member Beiträge: 6 Beitrittsdatum: 31.07.13 Neueste Beiträge
Hey,

I'm using liferay 6.1.1-ce-ga2 bundled with Tomcat 7.0.27.
I've got similar problem, but in my case the error points to com.liferay.portal.util.OpenIdUtil class.
java.lang.NoClassDefFoundError: com/liferay/portal/util/OpenIdUtil
I'm trying to override the com.liferay.portlet.login.action.OpenIdAction as it's described here:
https://www.liferay.com/web/mika.koivisto/blog/-/blogs/overriding-and-adding-struts-actions-from-hook-plugins

For the test purpose I just copied all protected methods from the liferay's source code of OpenIdAction.java and put them to my class which extends BaseStrutsPortletAction.
I put the break point in sendOpenIdRequest method and the exception (java.lang.NoClassDefFoundError: com/liferay/portal/util/OpenIdUtil) is thrown when the java tries to invoke this line:
if (!OpenIdUtil.isEnabled(themeDisplay.getCompanyId()))

When I comment this line, then liferay throws the exception
java.lang.NoClassDefFoundError: com/liferay/portlet/ActionResponseImpl

during execution of this line
ActionResponseImpl actionResponseImpl = (ActionResponseImpl)actionResponse;

The problem does not arise during the deployment, only in run time, when I try to login with OpenId.
I want to override OpenIdAction, because I need to add some extra openId attributes (by default liferay asks only for email, firstName and lastName).
Is it possible to override this action or do I have to write ext-plugin, which I'm extremly trying to avoid.
thumbnail
Mika Koivisto, geändert vor 9 Jahren.

RE: DefaultLandingPageAction Hook - class not found Exception

Liferay Legend Beiträge: 1519 Beitrittsdatum: 07.08.06 Neueste Beiträge
You are trying to use classes that are not available to plugins. That is why you are getting those NoClassDefFoundErrors.