掲示板

NoClassDefFoundError: PortletProps

13年前 に Laura Squarepants によって更新されました。

NoClassDefFoundError: PortletProps

New Member 投稿: 7 参加年月日: 10/11/10 最新の投稿
Hi,

I am trying to add asset functionality to a simple portlet developed in plugin-SDK.
I followed the instructions here.

After creating the classes and adding <asset-renderer-factory>com.liferay.portlet.your_portlet.YourObjectAssetRendererFactory</asset-renderer-factory> to my liferay-portlet.xml I get the following error:
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.liferay.util.portlet.PortletProps
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.liferay.portal.kernel.util.MethodHandler.invoke(MethodHandler.java:81)
	at com.liferay.portal.kernel.util.MethodHandler.invoke(MethodHandler.java:75)
	at com.liferay.portlet.PortletBagFactory.getPluginPropertyValue(PortletBagFactory.java:324)
	at com.liferay.portlet.PortletBagFactory.newAssetRendererFactoryInstances(PortletBagFactory.java:452)
	at com.liferay.portlet.PortletBagFactory.create(PortletBagFactory.java:196)
	at com.liferay.portal.deploy.hot.PortletHotDeployListener.initPortlet(PortletHotDeployListener.java:456)
	at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy(PortletHotDeployListener.java:253)
	at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:101)
	... 19 more


Can anybody help me and tell me what I am doing wrong?
thumbnail
13年前 に jelmer kuperus によって更新されました。

RE: NoClassDefFoundError: PortletProps

Liferay Legend 投稿: 1191 参加年月日: 10/03/10 最新の投稿
Are you referencing this class in your own code ? this class resides in util-java.jar, located in the ROOT web application, and as such is not on the classpath of your plugin
13年前 に Laszlo Tersztenyak によって更新されました。

RE: NoClassDefFoundError: PortletProps

New Member 投稿: 1 参加年月日: 10/11/12 最新の投稿
Hi Laura,

I had the same problem.

The solution was: register util-java.jar as portal-dependency-jars in liferay-plugin-package.properties of the portlet.

Rgds,
Laszlo
thumbnail
13年前 に Sunetra Chavan によって更新されました。

RE: NoClassDefFoundError: PortletProps

New Member 投稿: 2 参加年月日: 10/12/13 最新の投稿
Hi,

i have tried with util-java.jar as portal-dependency-jars in liferay-plugin-package.properties of the portlet. I am also facing the same issue while deploying the porlet.

In few liferay instace(6.0), its working fine. But in few instaces the issue still exists.

Is anyone can provide the solution on this.


Thanks in advance.

sunetra
thumbnail
13年前 に Carlos Devoto によって更新されました。

RE: NoClassDefFoundError: PortletProps

New Member 投稿: 1 参加年月日: 11/02/03 最新の投稿
I had the same issue with Liferay 6.0.5, and I was able to debug it using Eclipse. What I found was that I needed to place a "portlet.properties" file within my portlet classpath (i.e. within the /WEB-INF/classes directory). I tried it with a blank "portlet.properties" file, and the problem went away. Here is a brief recap of my findings:

1. The PortletProps class contains a static instance variable named _instance which is initialized to a new PortletProps() object when the class is loaded. As a result the PortletProps constructor is invoked at class load time.

2. The PortletProps constructor attempts to load a "portlet.properties" file from the portlet classpath via ConfigurationFactoryUtil.getConfiguration(PortletProps.class.getClassLoader(), "portlet").

3. Because the "portlet.properties" file does not exist, a NullPointerException is thrown by the ConfigurationImpl.getFileName(ClassLoader classLoader, String name) method. This uncaught exception bubbles back up and causes the PortletProps class to not be initialized.

4. All subsequent attempts to redeploy your portlet without rebooting the entire server will result in a NoClassDefFoundError being thrown for the PortletProps class.

It simply looks like a side-effect of poor exception handling.

[Edit] The creation of a "portlet.properties" file appears to solve the problem when I initially boot the server, but when I subsequently attempt to redeploy the portlet while the server is running, I get a NullPointerException from PortletProps.getKey(). This issue is described in http://74.124.201.3/browse/LPS-12163, and a fix is available.
13年前 に An Jay によって更新されました。

RE: NoClassDefFoundError: PortletProps

Regular Member 投稿: 160 参加年月日: 10/12/16 最新の投稿
HI

I am using hook to customize the directory portlet. I want my jsp to read a property file. Is it possible to do the same with PortletProps class.

I want my jsp to pick the properties file without hardcoding the file path in jsp.

can some one please help.
thumbnail
7年前 に Mayur Patel によって更新されました。

RE: NoClassDefFoundError: PortletProps

Expert 投稿: 358 参加年月日: 10/11/17 最新の投稿
Thanks Carlos ! It works like a charm emoticon