Page 1 of 1

cms /about_us throws exception

Posted: Mon Nov 26, 2012 12:14 pm
by om.singh
I have build my own app using the demo application. But when the cms pages its always throwing an exception as below.

2012-11-26 17:03:20.354:WARN:oejs.ServletHandler:/about_us
[artifact:mvn] org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "media['primary']" (catalog/partials/productListItem:5)
[artifact:mvn] at org.thymeleaf.spring3.expression.SpelVariableExpressionEvaluator.evaluate(SpelVariableExpressionEvaluator.java:118)
[artifact:mvn] at org.thymeleaf.standard.expression.SelectionVariableExpression.executeSelectionVariable(SelectionVariableExpression.java:106)
[artifact:mvn] at org.thymeleaf.standard.expression.SimpleExpression.executeSimple(SimpleExpression.java:403)
[artifact:mvn] at org.thymeleaf.standard.expression.Expression.execute(Expression.java:230)
[artifact:mvn] at org.thymeleaf.standard.expression.StandardExpressionExecutor.executeExpression(StandardExpressionExecutor.java:62)
[artifact:mvn] at org.thy


My applicationContext-servlet.xml has the same entry like the demo site. Also the scripts are loading the right rows in the tables.

Any ideas what might be going wrong.

Om

Re: cms /about_us throws exception

Posted: Fri Nov 30, 2012 11:27 am
by phillipuniverse
Ensure that all of your products have a 'primary' media item. You could also modify productListItem.html to check for nulls in the 'media' object (assuming that's the root problem further down in the stack trace).

Re: cms /about_us throws exception

Posted: Sat Dec 01, 2012 6:21 am
by om.singh
I have changed the media to large as this is what I using in my sql files

Code: Select all

INSERT INTO BLC_SKU_MEDIA_MAP (BLC_SKU_SKU_ID, MEDIA_ID, MAP_KEY) VALUES (171, 171,'large');
INSERT INTO BLC_SKU_MEDIA_MAP (BLC_SKU_SKU_ID, MEDIA_ID, MAP_KEY) VALUES (172, 172,'large');
INSERT INTO BLC_SKU_MEDIA_MAP (BLC_SKU_SKU_ID, MEDIA_ID, MAP_KEY) VALUES (173, 173,'large');
INSERT INTO BLC_SKU_MEDIA_MAP (BLC_SKU_SKU_ID, MEDIA_ID, MAP_KEY) VALUES (174, 174,'large');


Code: Select all

<img th:if="*{media['large']}" th:src="@{*{media['large'].url}}" alt="Sauce Image" />


But it throws a null pointer as below
java.lang.NullPointerException
at org.broadleafcommerce.core.catalog.domain.ProductImpl.getMedia(ProductImpl.java:393)


It seems for some id - its missing the media hence null pointer. Is there a way to check for null in thymeleaf

Regards
Om