Broadleaf电商平台上传图片出现NullPointerException

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Broadleaf电商平台上传图片出现NullPointerException相关的知识,希望对你有一定的参考价值。

Broadleaf-5.1.2 + Tomcat7
异常信息如下:

严重: Servlet.service() for servlet [admin] in context with path [/admin] threw exception
java.lang.NullPointerException
    at org.broadleafcommerce.common.audit.AbstractAuditableListener.setAuditData(AbstractAuditableListener.java:88)
    at org.broadleafcommerce.common.audit.AbstractAuditableListener.setAuditCreationData(AbstractAuditableListener.java:71)
    at org.broadleafcommerce.openadmin.audit.AdminAuditableListener.setAuditCreationAndUpdateData(AdminAuditableListener.java:33)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.hibernate.ejb.event.ListenerCallback.invoke(ListenerCallback.java:48)
    at org.hibernate.ejb.event.EntityCallbackHandler.callback(EntityCallbackHandler.java:110)
    at org.hibernate.ejb.event.EntityCallbackHandler.preCreate(EntityCallbackHandler.java:79)
    at org.hibernate.ejb.event.EJB3MergeEventListener.saveWithGeneratedId(EJB3MergeEventListener.java:70)
    at org.hibernate.event.internal.DefaultMergeEventListener.saveTransientEntity(DefaultMergeEventListener.java:236)
    at org.hibernate.event.internal.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:216)
    at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:154)
    at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:76)
    at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:903)
    at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:887)
    at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:891)
    at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:889)
    at sun.reflect.GeneratedMethodAccessor394.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:344)
    at com.sun.proxy.$Proxy372.merge(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor394.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)

原因:缺少 -javaagent:agents/spring-instrument.jar jvm参数,在tomcat启动时加上上述jvm参数即可,注意spring-instrument.jar 路径。

以上是关于Broadleaf电商平台上传图片出现NullPointerException的主要内容,如果未能解决你的问题,请参考以下文章

Golang实战项目-B2C电商平台项目

Go实战 | 电商平台 图片上传到七牛云

开源 java 电商系统

Java开源电商项目比較

如何将图片上传到Cloudinary云平台?

杂谈:电商平台中的图片资源优化实战