Fórum

Asset Rendering Error

Daniel G, modificado 6 Anos atrás.

Asset Rendering Error

Regular Member Postagens: 141 Data de Entrada: 14/03/17 Postagens Recentes
Hi everyone.

I'm facing some issues when I'm trying to render an asset for my custom entity and enable it for supporting workflows..

I had this issue:
ERROR [http-nio-8080-exec-7][AssetDisplayTag:195] null
java.lang.NullPointerException

when I navigate into a task in My workflow Tasks. I follow the steps of the documentation (https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/rendering-an-asset) and I don't know why it doesn't work. I can access to the task and it shows what I indicated the summary method, but it should redirect to the pages indicated in the getJspPath method.



I think that the error can be in the include method or in the JspPath, but I did it in the same way that the documentation.

Does anyone have any idea?


Thanks for the help!
thumbnail
David H Nebinger, modificado 6 Anos atrás.

RE: Asset Rendering Error

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
Yeah, that's another one of those lovely catch blocks Liferay has in there that totally swallows the actual error and only gives you the stupid "null" message from the NPE.

You get no stack trace, no detail at all about where the null actually originates (whether in this method or in the include() handling.

Your only path is to do some debugging; set a breakpoint in the method and step through to identify why the NPE is getting thrown and where. Likely it will point to an issue with missing tag attributes, but that is just a real haphazard guess without any real details.






Come meet me at the 2017 LSNA!
Daniel G, modificado 6 Anos atrás.

RE: Asset Rendering Error

Regular Member Postagens: 141 Data de Entrada: 14/03/17 Postagens Recentes
Hi David.

First of all, thanks for your help.

I was digging into my code and I can find out some things.

The method include, when executes super.include, it seems to work fine. That method calls getJspPath method, and then is when it breaks.

in getJSpPath method, I return this: /asset/full_content.jsp for all the templates. And this is where the error appears, I think. But the path is correctly.

I was reading the documentation again and again looking for mistakes that I could have made, but I didn't find anything. I checked my service methods but I think that the problem is not there.

What are you mean when you say "issue with missing tag attributes"? do you have any idea about what can i do for founding the mistake?

Thanks again!
Daniel G, modificado 6 Anos atrás.

RE: Asset Rendering Error (Resposta)

Regular Member Postagens: 141 Data de Entrada: 14/03/17 Postagens Recentes
Finally I found the mistake. The error was in the asset renderer, what made that the redirection to jsp page was failing.

Thanks for the help!
thumbnail
David H Nebinger, modificado 6 Anos atrás.

RE: Asset Rendering Error

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
FWIW, I did submit a bug and a corresponding PR to change all of these bad exception logging blocks. It's made it through some interim hurdles, but I don't know that it will get in in time for the GA4 cut.









Come meet me at the 2017 LSNA!
JEETESH KUMAR, modificado 6 Anos atrás.

RE: Asset Rendering Error

New Member Mensagem: 1 Data de Entrada: 27/09/17 Postagens Recentes
sir
i have met with same error
10:02:46,767 ERROR [http-nio-8080-exec-1][AssetDisplayTag:195] null
java.io.FileNotFoundException: /o/portal-workflow-task-web/Inspection-agency/Asset/ASSETCONTENT.jsp.


below is the code

package org.egov.wdra.feedback.asset;

import com.liferay.asset.kernel.model.AssetRendererFactory;
import com.liferay.asset.kernel.model.BaseJSPAssetRenderer;
import com.liferay.portal.kernel.language.LanguageUtil;
import com.liferay.portal.kernel.portlet.LiferayPortletRequest;
import com.liferay.portal.kernel.portlet.LiferayPortletResponse;
import com.liferay.portal.kernel.theme.ThemeDisplay;
import com.liferay.portal.kernel.util.HtmlUtil;
import com.liferay.portal.kernel.util.ResourceBundleLoader;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.util.WebKeys;

import java.util.Locale;
import java.util.ResourceBundle;

import javax.portlet.PortletRequest;
import javax.portlet.PortletResponse;
import javax.portlet.PortletURL;
import javax.portlet.WindowState;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.wdra.model.feedback;

public class FormAssetRendrer extends BaseJSPAssetRenderer<feedback> {

private final feedback _feedback;
private final ResourceBundleLoader _resourceBundleLoader;

public FormAssetRendrer(
feedback inspectionAgency, ResourceBundleLoader resourceBundleLoader) {

System.out.println("TANMAY");
_feedback = inspectionAgency;
_resourceBundleLoader = resourceBundleLoader;
}


@Override
public feedback getAssetObject() {
return _feedback;
}

@Override
public String getClassName() {
return feedback.class.getName();
}

@Override
public long getClassPK() {
return _feedback.getFedid();
}

@Override
public long getGroupId() {
return _feedback.getGroupId();
}

public String getType() {
return FeedbackAssetRendrerFactory.TYPE;
}

public String getPortletId() {
AssetRendererFactory<feedback> assetRendererFactory =
getAssetRendererFactory();

return assetRendererFactory.getPortletId();
}

@Override
public int getStatus() {
return _feedback.getStatus();
}

@Override
public String getSummary(
PortletRequest portletRequest, PortletResponse portletResponse) {
System.out.println(">>>>>>>>> getSummary called >>>>>>>");
/*int abstractLength = AssetUtil.ASSET_ENTRY_ABSTRACT_LENGTH;

if (portletRequest != null) {
abstractLength = GetterUtil.getInteger(
portletRequest.getAttribute(
WebKeys.ASSET_ENTRY_ABSTRACT_LENGTH),
AssetUtil.ASSET_ENTRY_ABSTRACT_LENGTH);
}*/

String summary =
"["+_feedback.getPrimaryKey()+"] "+ _feedback.getFullname();

if (Validator.isNull(summary)) {
summary = HtmlUtil.stripHtml(
StringUtil.shorten(String.valueOf(_feedback.getPrimaryKey()), 20));
}

return summary;
}

/**
* the resource bundle loader you configured in the constructor to
* load your module’s resource bundle and return the display title
* for your asset
*/
@Override
public String getTitle(Locale locale) {
System.out.println(">>>>>>>>> getTitle called >>>>>>>");
ResourceBundle resourceBundle =
_resourceBundleLoader.loadResourceBundle(
LanguageUtil.getLanguageId(locale));


// return WarehouseLocalServiceUtil.getDisplayTitle(resourceBundle, _warehouse);
return _feedback.getFullname();
}


@Override
public long getUserId() {
return _feedback.getUserId();
}


@Override
public String getUserName() {
// return _inspectionAgency.getCreated_By();
return null;
}


@Override
public String getUuid() {
return null;
}

/*@Override
public String getJspPath(HttpServletRequest request, String template) {
System.out.println(">>>>>>>>> gxvxvxvxvxvxvetJspPath called >>>>>>>");
return "
}*/


@Override
public String getJspPath(HttpServletRequest request, String template) {
System.out.println(">>>>>>>>> getJspPath called >>>>>>>"+template);
System.out.println(">>>>>>>>> Context Path>>>>>>>"+request.getContextPath());


if (template.equals(TEMPLATE_ABSTRACT)) {
System.out.println(">>>>>>>>> if >>>>>>>");
return request.getContextPath() + "/Inspection-agency/Asset/ASSETCONTENT.jsp";

}else {
System.out.println(">>>>>>>>> ELSE >>>>>>>");
return "/form/Inspection-agency/Asset/ASSETCONTENT.jsp";


}

}






@Override
public boolean include(
HttpServletRequest request, HttpServletResponse response,
String template)
throws Exception {
System.out.println(">>>>>>>>> include called >>>>>>>");
request.setAttribute("_feedbackId", _feedback.getFedid());

ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);


request.setAttribute("isWorkflowMode", Boolean.TRUE.toString());
return super.include(request, response, template);
}



@Override
public String getURLView(
LiferayPortletResponse liferayPortletResponse,
WindowState windowState)
throws Exception {

AssetRendererFactory<feedback> assetRendererFactory =
getAssetRendererFactory();

PortletURL portletURL = assetRendererFactory.getURLView(
liferayPortletResponse, windowState);

portletURL.setParameter("mvcRenderCommandName", "/view_entry");
portletURL.setParameter("_feedbackId", String.valueOf(_feedback.getFedid()));
portletURL.setWindowState(windowState);

return portletURL.toString();
}

@Override
public String getURLViewInContext(
LiferayPortletRequest liferayPortletRequest,
LiferayPortletResponse liferayPortletResponse,
String noSuchEntryRedirect) {

return getURLViewInContext(
liferayPortletRequest, noSuchEntryRedirect, "/inspection-agency/asset/find_entry",
"_feedbackid", _feedback.getFedid());
}
}
Please Help.
Daniel G, modificado 6 Anos atrás.

RE: Asset Rendering Error

Regular Member Postagens: 141 Data de Entrada: 14/03/17 Postagens Recentes
Hi.

It seems like an error with the path of ASSETCONTENT.jsp

What is the path of that file?


Kind Regards
Yoga Aldian Putra, modificado 6 Anos atrás.

RE: Asset Rendering Error

New Member Postagens: 3 Data de Entrada: 17/05/17 Postagens Recentes
Daniel G:
Finally I found the mistake. The error was in the asset renderer, what made that the redirection to jsp page was failing.

Thanks for the help!

Hi Daniel, would you tell me your detail step to fix this error? i have the same problem with you, (getJspPath).

Thanks before
Daniel G, modificado 6 Anos atrás.

RE: Asset Rendering Error

Regular Member Postagens: 141 Data de Entrada: 14/03/17 Postagens Recentes
Hi.

In the method I only indicate the path of the redirection. What is exactly your problem?



@Override
	 public String getJspPath(HttpServletRequest request, String template) {
		
		if (template.equals(TEMPLATE_ABSTRACT) ||
				template.equals(TEMPLATE_FULL_CONTENT)) {
		
			
				return "/viewForm.jsp";
		}
				else {
					
					return null;
				}
	 
	 }



kind regards
Yoga Aldian Putra, modificado 6 Anos atrás.

RE: Asset Rendering Error

New Member Postagens: 3 Data de Entrada: 17/05/17 Postagens Recentes
Daniel G:
Hi.

In the method I only indicate the path of the redirection. What is exactly your problem?



@Override
	 public String getJspPath(HttpServletRequest request, String template) {
		
		if (template.equals(TEMPLATE_ABSTRACT) ||
				template.equals(TEMPLATE_FULL_CONTENT)) {
		
			
				return "/viewForm.jsp";
		}
				else {
					
					return null;
				}
	 
	 }



kind regards



Thanks for your reply Daniel, i've got this error message even I've followed your suggestion, here's the error message:


[AssetDisplayTag:197] Unable to include asset renderer template
java.lang.NullPointerException


i'm new at liferay, and i want use workflow for my custom entity, and i found this nice article and try to follow the instruction
"http://www.javasavvy.com/liferay-dxp-custom-entity-kaleo-workflow-tutorial/"

the workflow process runs well and i can approve the incoming notification. The error only appear when i click the notification.


Regards,
Yoga
thumbnail
David H Nebinger, modificado 6 Anos atrás.

RE: Asset Rendering Error

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
If you have an NPE, you aren't setting a value that is expected to be non-null.

Use the stack trace to figure out what is null and the point from your code which triggers the NPE.
Daniel G, modificado 5 Anos atrás.

RE: Asset Rendering Error

Regular Member Postagens: 141 Data de Entrada: 14/03/17 Postagens Recentes
Hi

I think that the error is not in the asset renderer. It might be in the way that you are calling it. Maybe if you add logs to everything in the java class you can find exactly where is the problem.

Kind regards
thumbnail
Vishal Srivastava, modificado 4 Anos atrás.

RE: Asset Rendering Error

Junior Member Postagens: 26 Data de Entrada: 07/07/14 Postagens Recentes
Can you please share the fix as i have the same issue.Thanks in advance!