Page 1 of 2

html templates causing 500 error in master branch of Demo

Posted: Wed Jul 10, 2013 11:42 am
by cigano
I did a clone of the latest DemoSite (master) branch and there are a couple of references in the html templates causing a 500 error when going to http://localhost:8080

/catalog/partials/productListItem.html
line 18: th:text="*{name}" is causing a problem

/catalog/partials/productListItem.html
line 19: th:utext="*{longDescription}" is causing a problem

/layout/partials/nav.html
line 12: th:text="${category.name}" is causing a problem

If I comment these items out I don't get any more 500 errors and the site loads but of course data is missing.
please advise.

Re: html templates causing 500 error in master branch of Demo

Posted: Wed Jul 10, 2013 8:20 pm
by cigano
java.lang.NullPointerException
org.broadleafcommerce.common.i18n.service.TranslationServiceImpl.getTranslatedValue(TranslationServiceImpl.java:130)
sun.reflect.GeneratedMethodAccessor69.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
com.sun.proxy.$Proxy95.getTranslatedValue(Unknown Source)
org.broadleafcommerce.common.i18n.service.DynamicTranslationProvider.getValue(DynamicTranslationProvider.java:46)
org.broadleafcommerce.core.catalog.domain.SkuImpl.getName(SkuImpl.java:497)
org.broadleafcommerce.core.catalog.domain.ProductImpl.getName(ProductImpl.java:279)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.springframework.expression.spel.support.ReflectivePropertyAccessor$OptimalPropertyAccessor.read(ReflectivePropertyAccessor.java:567)
org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:234)
org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:112)
org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:107)
org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:93)
org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:94)
org.thymeleaf.spring3.expression.SpelVariableExpressionEvaluator.evaluate(SpelVariableExpressionEvaluator.java:103)
org.thymeleaf.standard.expression.SelectionVariableExpression.executeSelectionVariable(SelectionVariableExpression.java:107)
org.thymeleaf.standard.expression.SimpleExpression.executeSimple(SimpleExpression.java:404)
org.thymeleaf.standard.expression.Expression.execute(Expression.java:231)
org.thymeleaf.standard.expression.StandardExpressionExecutor.executeExpression(StandardExpressionExecutor.java:70)
org.thymeleaf.standard.expression.StandardExpressionExecutor.executeExpression(StandardExpressionExecutor.java:58)
org.thymeleaf.standard.expression.StandardExpressionProcessor.executeExpression(StandardExpressionProcessor.java:124)
org.thymeleaf.standard.expression.StandardExpressionProcessor.processExpression(StandardExpressionProcessor.java:164)
org.thymeleaf.standard.processor.attr.AbstractStandardTextChildModifierAttrProcessor.getText(AbstractStandardTextChildModifierAttrProcessor.java:60)
org.thymeleaf.processor.attr.AbstractTextChildModifierAttrProcessor.getModifiedChildren(AbstractTextChildModifierAttrProcessor.java:59)
org.thymeleaf.processor.attr.AbstractChildrenModifierAttrProcessor.processAttribute(AbstractChildrenModifierAttrProcessor.java:58)
org.thymeleaf.processor.attr.AbstractAttrProcessor.doProcess(AbstractAttrProcessor.java:74)
org.thymeleaf.processor.AbstractProcessor.process(AbstractProcessor.java:212)
org.thymeleaf.dom.Node.applyNextProcessor(Node.java:914)
org.thymeleaf.dom.Node.processNode(Node.java:869)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:638)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:620)
org.thymeleaf.dom.Node.processNode(Node.java:888)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:638)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:620)
org.thymeleaf.dom.Node.processNode(Node.java:888)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:638)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:620)
org.thymeleaf.dom.Node.processNode(Node.java:888)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:638)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:620)
org.thymeleaf.dom.Node.processNode(Node.java:888)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:638)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:620)
org.thymeleaf.dom.Node.processNode(Node.java:888)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:638)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:620)
org.thymeleaf.dom.Node.processNode(Node.java:888)
org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:638)
org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:620)
org.thymeleaf.dom.Node.processNode(Node.java:888)
org.thymeleaf.dom.Document.process(Document.java:93)
org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1243)
org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1148)
org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1095)
org.thymeleaf.spring3.view.ThymeleafView.renderFragment(ThymeleafView.java:259)
org.thymeleaf.spring3.view.ThymeleafView.render(ThymeleafView.java:179)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
org.broadleafcommerce.core.web.order.security.CartStateFilter.doFilter(CartStateFilter.java:57)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.broadleafcommerce.common.web.filter.TranslationFilter.doFilter(TranslationFilter.java:48)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.broadleafcommerce.cms.web.URLHandlerFilter.doFilterInternal(URLHandlerFilter.java:71)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:166)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.broadleafcommerce.profile.web.core.security.SessionFixationProtectionFilter.doFilter(SessionFixationProtectionFilter.java:95)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.broadleafcommerce.profile.web.core.security.CustomerStateFilter.doFilter(CustomerStateFilter.java:53)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.broadleafcommerce.common.security.handler.CsrfFilter.doFilter(CsrfFilter.java:82)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.access.channel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:144)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
org.broadleafcommerce.common.web.BroadleafRequestFilter.doFilterInternal(BroadleafRequestFilter.java:97)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:180)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:166)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)

Re: html templates causing 500 error in master branch of Demo

Posted: Sun Jul 14, 2013 4:44 pm
by janschraepen
@cigano

Did you manage to get rid of the NPE? I'm experiencing the same NPE on the TranslationServiceImpl.
Thx in advance!

Jan

Re: html templates causing 500 error in master branch of Demo

Posted: Mon Jul 15, 2013 10:47 am
by cigano
I'm glad somebody else experienced this besides me. I did the following although I would prefer to know the cause and get an official fix. As you might have seen the error comes from the TranslationServiceImpl class trying to get the localized value for the attribute from the cache. I didn't dig into what's causing the null pointer exception I just put a try/catch around the code and I log the exception. It's not a permanent fix but at least it allows me to get to work on my own project. I cloned the main broadleaf development branch and then changed the source of the TranslationServiceImpl class and ran the maven target to rebuild the broadleaf-common-3.0.0-GA.jar file and replaced the jar in the DemoSite lib directory. You have to look for the entry in the DemoSite pom.xml for the broadleaf-common-3.0.0-GA.jar file and comment it out so that it doesn't get replaced.

After doing this the exception doesn't clobber the site but it's more of a work around than a fix. If after doing this you still have a problem leave a comment here. Maybe I left out a step.

Here's the code change I made: TranslationServiceImpl:getTranslatedValue()

try //SBNOTE: try/catch added by me, not sure why this is happening.
{
if (getCache().isKeyInCache(countryCacheKey)) {
translation = (Translation) getCache().get(countryCacheKey).getObjectValue();
} else {
translation = getTranslation(entityType, entityId, property, localeCountryCode);
getCache().put(new Element(countryCacheKey, translation));
}
}
catch(Exception ex)
{
LOG.warn(ex.getMessage(),ex);
}


try //SBNOTE: try/catch added by me, not sure why this is happening.
{
// If we don't find one, let's try just the language (en), again utilizing the cache
if (translation == null) {
String nonCountryCacheKey = getCacheKey(entityType, entityId, property, localeCode);
if (getCache().isKeyInCache(nonCountryCacheKey)) {
translation = (Translation) getCache().get(nonCountryCacheKey).getObjectValue();
} else {
translation = getTranslation(entityType, entityId, property, localeCode);
getCache().put(new Element(nonCountryCacheKey, translation));
}
}
}
catch(Exception ex)
{
LOG.warn(ex.getMessage(),ex);
}

Re: html templates causing 500 error in master branch of Demo

Posted: Wed Jul 17, 2013 10:21 am
by lotary
I am getting the same exception. Does anyone have a solution for this? Thanks

Code: Select all

java.lang.NullPointerException
   at org.broadleafcommerce.common.i18n.service.TranslationServiceImpl.getTranslatedValue(TranslationServiceImpl.java:140)
   at sun.reflect.GeneratedMethodAccessor64.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
   at $Proxy107.getTranslatedValue(Unknown Source)
   at org.broadleafcommerce.common.i18n.service.DynamicTranslationProvider.getValue(DynamicTranslationProvider.java:46)
   at org.broadleafcommerce.core.catalog.domain.CategoryImpl.getName(CategoryImpl.java:432)

Re: html templates causing 500 error in master branch of Demo

Posted: Wed Jul 17, 2013 5:15 pm
by jskorton
Cigano, lotary, and janschraepen,

Please have a look at this recent Thymeleaf issue:

https://github.com/thymeleaf/thymeleaf-spring3/issues/26

It is fixed in the latest Thymeleaf snapshot that Broadleaf is not yet using.

Until then your problem should be fixable by first checking whether we are in an online (IWebContext) or offline (IContext) scenario before creating the Themes instance. You need to be in an online scenario until Broadleaf moves to the next version of Thymeleaf.

Re: html templates causing 500 error in master branch of Demo

Posted: Wed Jul 17, 2013 5:56 pm
by cigano
thanks for the info but per your suggestion *how* does one check "whether we are in an online (IWebContext) or offline (IContext) scenario before creating the Themes instance. You need to be in an online scenario until Broadleaf moves to the next version of Thymeleaf"?

I cloned the demo project from git and run it so it seems like it would already by "online".

Re: html templates causing 500 error in master branch of Demo

Posted: Wed Jul 17, 2013 11:03 pm
by lotary
Thanks for the help.

Can you elaborate more on "You need to be in an online scenario" ?

Thanks .

Re: html templates causing 500 error in master branch of Demo

Posted: Thu Jul 18, 2013 11:57 am
by jskorton
An alternate solution that is easier to implement is to roll back the thymeleaf-spring3 version to 2.0.16 in your pom.

Please see:

https://github.com/BroadleafCommerce/BroadleafCommerce/issues/158

Re: html templates causing 500 error in master branch of Demo

Posted: Sun Jul 21, 2013 1:46 am
by yong9900
I tried both thymeleaf-spring3 2.0.16 and 2.0.18-SNAPSHOT. Both gave me the same error. Did I missed anything? Any one tried? I guess I have to go with cigano's approach, not a good start :(

just FYI, I added this part to the demo site pom, and I checked the version of the thymeleaf jar files in target dir were updated:

<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>2.0.18-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring3</artifactId>
<version>2.0.18-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>