3

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; 

}
Simone Sorgon
  • 155
  • 1
  • 14
  • Can you provide a [mcve] with some code to reproduce? Does it also happen with a new service that you build from scratch? Where is your own service's code in the stacktrace? – Olaf Kock Mar 26 '21 at 19:14
  • Yes, i try to use the sample project when create a modulo service-builder. I only add in the bnd "-dsannotations-options: inherit" and in the service.xml "dependency-injector="ds"". When i use persistence second time, i still have the exception – Simone Sorgon Mar 29 '21 at 06:50
  • if you'd edit this into your question, you could use the formatting options and make it human-readable. – Olaf Kock Mar 29 '21 at 09:26
  • ok, i edit with code – Simone Sorgon Mar 29 '21 at 09:41
  • Is this generated code in ServiceBuilder? If so: Did you rebuild services, e.g. ran ServiceBuilder again after porting? – Olaf Kock Mar 29 '21 at 15:49

1 Answers1

2

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...>