Forums de discussion

NoClassDefFoundError: PortletProps

Laura Squarepants, modifié il y a 13 années.

NoClassDefFoundError: PortletProps

New Member Publications: 7 Date d'inscription: 10/11/10 Publications récentes
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
jelmer kuperus, modifié il y a 13 années.

RE: NoClassDefFoundError: PortletProps

Liferay Legend Publications: 1191 Date d'inscription: 10/03/10 Publications récentes
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
Laszlo Tersztenyak, modifié il y a 13 années.

RE: NoClassDefFoundError: PortletProps

New Member Envoyer: 1 Date d'inscription: 12/11/10 Publications récentes
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
Sunetra Chavan, modifié il y a 13 années.

RE: NoClassDefFoundError: PortletProps

New Member Publications: 2 Date d'inscription: 13/12/10 Publications récentes
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
Carlos Devoto, modifié il y a 13 années.

RE: NoClassDefFoundError: PortletProps

New Member Envoyer: 1 Date d'inscription: 03/02/11 Publications récentes
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.
An Jay, modifié il y a 13 années.

RE: NoClassDefFoundError: PortletProps

Regular Member Publications: 160 Date d'inscription: 16/12/10 Publications récentes
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
Mayur Patel, modifié il y a 7 années.

RE: NoClassDefFoundError: PortletProps

Expert Publications: 358 Date d'inscription: 17/11/10 Publications récentes
Thanks Carlos ! It works like a charm emoticon