Liferay 7.3 java.lang.NullPointerException after porting from 7.2

2k Views Asked by At

I'm doing a porting from Liferay 7.2 to Liferay 7.3.6 GA7. I have a customTable. When i add a first row using ..LocalServiceUtil it's ok. But every subsequent time I use persistence (for example tablePersistence.update(table);) fail and liferay throws:

ERROR [http-nio-8080-exec-1][ExceptionMapper:31] java.lang.NullPointerException java.lang.NullPointerException at com.liferay.portal.cache.internal.dao.orm.FinderCacheImpl._getArguments(FinderCacheImpl.java:466) at com.liferay.portal.cache.internal.dao.orm.FinderCacheImpl.updateByEntityCache(FinderCacheImpl.java:378) at com.liferay.portal.cache.internal.dao.orm.EntityCacheImpl._putResult(EntityCacheImpl.java:439) at com.liferay.portal.cache.internal.dao.orm.EntityCacheImpl.putResult(EntityCacheImpl.java:336) at com.liferay.portal.cache.internal.dao.orm.EntityCacheImpl.putResult(EntityCacheImpl.java:358) at com.liferay.portal.cache.internal.dao.orm.EntityCacheImpl.putResult(EntityCacheImpl.java:328)

The exception is in ..PersistenceImpl when try to do entityCache.putResult(entityCacheEnabled,...); I don't understand if i lost something during porting or if something is missing in 7.3.

This is an example with the method to add a row in customTable, and fooPersistence.update(foo) throws exception after the first time:

@Indexable(type = IndexableType.REINDEX) 
public Foo add(ServiceContext serviceContext) 
throws PortalException { 
   long companyId = serviceContext.getCompanyId(); 
   long userId = serviceContext.getUserId(); 
   User user = UserLocalServiceUtil.getUser(userId); 
   long groupId = user.getGroupId(); 
   long id = counterLocalService.increment(); 
   Foo foo = fooPersistence.create(id); 
   Date now = new Date(); 
   foo.setCreateDate(now); foo.setCompanyId(companyId); 
   foo.setGroupId(groupId); 
   fooPersistence.update(foo);
   return foo; 

}
1

There are 1 best solutions below

2
On

Had the same issue. After debugging the ServiceBuilder's code, I found out that the templates used for generating the classes use the version from service.xml's DTD definition (check the file persistence_impl.ftl in com.liferay.portal.tools.service.builder.jar). Ensure that you have 7.3.0 there and not 7.2.0 (or even older).

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 7.3.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_7_3_0.dtd">

<service-builder...>