Fórum

NoClassDefFoundError: PortletProps

Laura Squarepants, modificado 13 Anos atrás.

NoClassDefFoundError: PortletProps

New Member Postagens: 7 Data de Entrada: 10/11/10 Postagens Recentes
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, modificado 13 Anos atrás.

RE: NoClassDefFoundError: PortletProps

Liferay Legend Postagens: 1191 Data de Entrada: 10/03/10 Postagens Recentes
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, modificado 13 Anos atrás.

RE: NoClassDefFoundError: PortletProps

New Member Mensagem: 1 Data de Entrada: 12/11/10 Postagens Recentes
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, modificado 13 Anos atrás.

RE: NoClassDefFoundError: PortletProps

New Member Postagens: 2 Data de Entrada: 13/12/10 Postagens Recentes
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, modificado 13 Anos atrás.

RE: NoClassDefFoundError: PortletProps

New Member Mensagem: 1 Data de Entrada: 03/02/11 Postagens Recentes
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, modificado 13 Anos atrás.

RE: NoClassDefFoundError: PortletProps

Regular Member Postagens: 160 Data de Entrada: 16/12/10 Postagens Recentes
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, modificado 7 Anos atrás.

RE: NoClassDefFoundError: PortletProps

Expert Postagens: 358 Data de Entrada: 17/11/10 Postagens Recentes
Thanks Carlos ! It works like a charm emoticon