Can't resolve java.lang.NullPointerException - spring-mvc

I am getting NullPointerException and I don't know why it is being here.
TemplateController.java
#Controller
#SessionAttributes({"user","initiative"})
public class TemplateController {
#Autowired
private TaskService taskService;
#Autowired
private InitiativeService initiativeService;
#RequestMapping(value = "/addtasktemplate/{taskTemplateObjectId}/{initiativeId}", method = RequestMethod.POST)
public
#ResponseBody
#Transactional(propagation = Propagation.REQUIRED)
String addTaskTemplateUnderInitiative(#PathVariable Integer taskTemplateObjectId, #PathVariable Integer initiativeId, ModelMap model){
User user = (User) model.get("user");
if(user!=null){
Initiative initiative = (Initiative) model.get("initiative");
Boolean check = taskService.addTask(initiative.getInitiativeId(), taskTemplateObjectId, user); //TemplateController.java:67
if(check){
return "successfull";
}else{
return "failure";
}
}
return "Not Eligible";
}
}
The function addTask called in function addTaskTemplateUnderInitiative is defined in TaskDaoImpl.java, whose code is: -
TaskDaoImpl.java
#Repository("TaskDao")
public class TaskDaoImpl implements TaskDao {
private EntityManager entitymanager;
#Autowired
private ObjectInitiativeDao objectInitiativeDao;
#Autowired
private ActionListDao actionListDao;
#PersistenceContext
public void setEntitymanager(EntityManager entitymanager) {
this.entitymanager = entitymanager;
}
#Override
#Transactional(readOnly = false)
public Boolean createTask(Task task) {
try{
entitymanager.persist(task);
return true;
}catch(Exception e){
return false;
}
}
#Override
#Transactional
public Boolean addTask(Integer initiativeId, Integer taskTemplateObjectId, User user) {
ObjectInitiative objectInitiative = objectInitiativeDao.getObjectInitiativeByObjectId(taskTemplateObjectId, false);
Task task = getTaskById(objectInitiative.getRespectiveId());
ObjectInitiative newObject = new ObjectInitiative();
/* Values set for newObject*/
objectInitiativeDao.createObjectInitiative(newObject);
Task newTask = new Task();
/* Values set for newTask */
createTask(newTask);
for(ActionList actionList : task.getActionLists()){
actionListDao.addActionList(newTask.getTaskId(), actionList.getObjectInitiative().getObjectId(), user); //TaskDaoImpl.java:105
}
return true;
}
#Override
#Transactional
public Task getTaskById(Integer taskId) {
Task task = entitymanager.find(Task.class, taskId);
for(ActionList actionList : task.getActionLists()){ //TaskDaoImpl.java:126
Hibernate.initialize(actionList);
}
return task;
}
}
Here, again function addActionList called in function addTask is defined in ActionListDaoImpl.java, whose code is: -
ActionListDaoImpl.java
#Repository("ActionListDao")
public class ActionListDaoImpl implements ActionListDao {
private final Logger logger=LoggerFactory.getLogger(getClass());
private EntityManager entitymanager;
#Autowired
private ObjectInitiativeDao objectInitiativeDao;
#Autowired
private TaskDao taskDao;
#Autowired
private ActionDao actionDao;
#PersistenceContext
public void setEntitymanager(EntityManager entitymanager) {
this.entitymanager = entitymanager;
}
#Override
#Transactional(readOnly = false)
public Boolean createActionList(ActionList actionList) {
try {
entitymanager.persist(actionList);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
#Override
#Transactional
public Boolean addActionList(Integer taskId, Integer actionListTemplateObjectId, User user) {
ObjectInitiative objectInitiative = objectInitiativeDao.getObjectInitiativeByObjectId(actionListTemplateObjectId, false);
ActionList actionList = getActionListById(objectInitiative.getRespectiveId());
Task task = taskDao.getTaskById(taskId); //ActionListDaoImpl.java:67
ObjectInitiative newObject = new ObjectInitiative();
/* Values set for newObject */
objectInitiativeDao.createObjectInitiative(newObject);
ActionList newActionList = new ActionList();
/* Values set for newActionList */
createActionList(newActionList);
return true;
}
#Override
#Transactional(readOnly = true)
public ActionList getActionListById(Integer actionListId) {
return entitymanager.find(ActionList.class, actionListId);
}
}
And, the domains of Task, ObjectInitiative and ActionList are: -
Task.java
#Entity
#Table(name = "task")
#Access(AccessType.FIELD)
public class Task {
#Id
#GenericGenerator(name = "task", strategy = "increment")
#GeneratedValue(generator = "task")
private Integer taskId;
#Column
private Integer objectId;
#Column
private Integer initiativeId;
#OneToOne(fetch = FetchType.EAGER)
#JoinColumn(name = "initiativeId", insertable = false, updatable = false, unique = true, nullable = false)
private Initiative initiative;
#OneToOne(fetch = FetchType.EAGER)
#JoinColumn(name = "objectId", insertable = false, updatable = false, unique = true, nullable = false)
private ObjectInitiative objectInitiative;
#OneToMany(mappedBy = "taskId", fetch = FetchType.LAZY)
private List<ActionList> actionLists;
/* Getters, Setters and toString() */
}
ActionList.java
#Entity
#Table(name = "actionlist")
#Access(AccessType.FIELD)
public class ActionList {
#Id
#GenericGenerator(name = "actionlist", strategy = "increment")
#GeneratedValue(generator = "actionlist")
private Integer actionListId;
#Column
private Integer objectId;
#Column
private Integer taskId;
#OneToOne(fetch = FetchType.EAGER)
#JoinColumn(name = "taskId", insertable = false, updatable = false, unique = true, nullable = false)
private Task task;
#OneToOne(fetch = FetchType.EAGER)
#JoinColumn(name = "objectId", insertable = false, updatable = false, unique = true, nullable = false)
private ObjectInitiative objectInitiative;
/* Getters, Setters and toString() */
}
ObjectInitiative.java
#Entity
#Table(name = "objectinitiative")
#Access(AccessType.FIELD)
public class ObjectInitiative {
#Id
#GenericGenerator(name = "objectinitiative", strategy = "increment")
#GeneratedValue(generator = "objectinitiative")
private Integer objectId;
/* Getters, Setters and toString() */
}
Now, I am getting NullPointerException in 'TaskDaoImpl.java' and then in 'ActionListDaoImpl.java' as you can see in log: -
java.lang.NullPointerException
at org.abc.def.dao.TaskDaoImpl.getTaskById(TaskDaoImpl.java:126)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy687.getTaskById(Unknown Source)
at org.abc.def.dao.ActionListDaoImpl.addActionList(ActionListDaoImpl.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy686.addActionList(Unknown Source)
at org.abc.def.dao.TaskDaoImpl.addTask(TaskDaoImpl.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy687.addTask(Unknown Source)
at org.abc.def.service.TaskServiceImpl.addTask(TaskServiceImpl.java:28)
at org.abc.def.controller.TemplateController.addTaskTemplateUnderInitiative(TemplateController.java:67)
at org.abc.def.controller.TemplateController$$FastClassByCGLIB$$4c5d2b90.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631)
at org.abc.def.web.controller.sim.TemplateController$$EnhancerByCGLIB$$7697f039_2.addTaskTemplateUnderInitiative(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:301)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:74)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1015)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:652)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1575)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1533)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Here, as you can see that I am using existing task template, not creating new task. Exception occurs when I fetch the task, but this does not occur when I create a new task (not using existing task template) and then fetch it.
This is all over. I can't get that how to resolve this problem.

I think you should check Null for initiative object of the method addTaskTemplateUnderInitiative in TemplateController.java
#Controller
#SessionAttributes({"user","initiative"})
public class TemplateController {
#Autowired
private TaskService taskService;
#Autowired
private InitiativeService initiativeService;
#RequestMapping(value = "/addtasktemplate/{taskTemplateObjectId}/{initiativeId}", method = RequestMethod.POST)
public
#ResponseBody
#Transactional(propagation = Propagation.REQUIRED)
String addTaskTemplateUnderInitiative(#PathVariable Integer taskTemplateObjectId, #PathVariable Integer initiativeId, ModelMap model){
User user = (User) model.get("user");
if(user!=null){
Initiative initiative = (Initiative) model.get("initiative");
if(initiative != null){
Boolean check = taskService.addTask(initiative.getInitiativeId(), taskTemplateObjectId, user);
model.addAttribute("initiative", initiativeService.getInitiativeByInitiativeId(initiativeId));
if(check){
return "successfull";
}else{
return "failure";
}
} else return "Falid";
}
return "Not Eligible";
}
}

did you check for below code.
for(ActionList actionList : task.getActionLists()){ //TaskDaoImpl.java:126
Hibernate.initialize(actionList);
}
1.) Either your task is null.
2.) If task is not null, task.getActionLists() is null then. For each will give error here
The above could be that there is no mapping data found or somehow Hibernate is not able to fetch the list.
Is the list Lazy, if yes then try intializing before for loop.
You can make the actionList inside Task as Eager, and it should work perfectly fine, but that is not the solution to your problem.
Issue is mainly because actionList is not able get intialized properly.
Hibernate.initialize(task.getActionLists());

Related

Corda White list Exception

I tried to manually add "org.hibernate.AnnotationException" to the whitelist. I tried to implement serializationWhitelist interface in my state class.
lets say my state class is of type Person and has Address type defined inside it. Every time I try to get the states out of the vault I get this error. or another for "org.hibernate.MappingException". Also When my state implements QueryableState I'm not even able to persist the data. and get the below error
Starting as webserver: localhost:10007
Webserver started up in 59.55 sec
>> Generating transaction based on new create.
>> Verifying contract constraints.
>> Signing transaction with our private key.
>> Gathering the counterparty's signature.
>> Structural step change in child of Gathering the counterparty's signature.
>> Collecting signatures from counter-parties.
>> Done
>> Obtaining notary signature and recording transaction.
>> Structural step change in child of Obtaining notary signature and recording transaction.
>> Requesting signature by notary service
[1;31mE 14:01:20+0530 [qtp9538928-76] controller.DMSController.create - com.esotericsoftware.kryo.KryoException: Class org.hibernate.MappingException is not annotated or on the whitelist, so cannot be used in serialization
Serialization trace:
cause (rx.exceptions.OnErrorNotImplementedException)
throwable (rx.Notification)
[m java.util.concurrent.ExecutionException: com.esotericsoftware.kryo.KryoException: Class org.hibernate.MappingException is not annotated or on the whitelist, so cannot be used in serialization
Serialization trace:
cause (rx.exceptions.OnErrorNotImplementedException)
throwable (rx.Notification)
at java.util.concurrent.CompletableFuture.reportGet(Unknown Source) ~[?:1.8.0_151]
at java.util.concurrent.CompletableFuture.get(Unknown Source) ~[?:1.8.0_151]
at net.corda.core.internal.concurrent.CordaFutureImpl.get(CordaFutureImpl.kt) ~[corda-core-1.0.0.jar:?]
at com.den.managment.controller.DMSController.create(DMSController.java:124) [DisputeManagmentSystem.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151]
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [jersey-server-2.25.jar:?]
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144) [jersey-server-2.25.jar:?]
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [jersey-server-2.25.jar:?]
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) [jersey-server-2.25.jar:?]
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [jersey-server-2.25.jar:?]
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [jersey-server-2.25.jar:?]
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) [jersey-server-2.25.jar:?]
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) [jersey-server-2.25.jar:?]
at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326) [jersey-server-2.25.jar:?]
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [jersey-common-2.25.jar:?]
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [jersey-common-2.25.jar:?]
at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [jersey-common-2.25.jar:?]
at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [jersey-common-2.25.jar:?]
at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [jersey-common-2.25.jar:?]
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [jersey-common-2.25.jar:?]
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [jersey-server-2.25.jar:?]
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [jersey-server-2.25.jar:?]
at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473) [jersey-container-servlet-core-2.25.jar:?]
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427) [jersey-container-servlet-core-2.25.jar:?]
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388) [jersey-container-servlet-core-2.25.jar:?]
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341) [jersey-container-servlet-core-2.25.jar:?]
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228) [jersey-container-servlet-core-2.25.jar:?]
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:845) [jetty-servlet-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583) [jetty-servlet-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1174) [jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511) [jetty-servlet-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1106) [jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:119) [jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134) [jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.server.Server.handle(Server.java:524) [jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:319) [jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:253) [jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273) [jetty-io-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95) [jetty-io-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93) [jetty-io-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303) [jetty-util-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148) [jetty-util-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136) [jetty-util-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671) [jetty-util-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589) [jetty-util-9.3.9.v20160517.jar:9.3.9.v20160517]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_151]
Caused by: com.esotericsoftware.kryo.KryoException: Class org.hibernate.MappingException is not annotated or on the whitelist, so cannot be used in serialization
Serialization trace:
cause (rx.exceptions.OnErrorNotImplementedException)
throwable (rx.Notification)
Updated
public class SomeState implements LinearState,QueryableState{
private final UniqueIdentifier uid;
private final Party partyA;
private final Party partyB;
private final List<Address> addresses;
public SomeState(Party partyA, Party partyB, List<Address> addresses) {
super();
this.uid = new UniqueIdentifier();
this.partyA = partyA;
this.partyB = partyB;
this.addresses = addresses;
}
public Party getPartyA() {
return partyA;
}
public Party getPartyB() {
return partyB;
}
public List<Address> getAddresses() {
return addresses;
}
#Override
public List<AbstractParty> getParticipants() {
return Arrays.asList(partyA,partyB);
}
#Override
public PersistentState generateMappedObject(MappedSchema schema) {
if (schema instanceof SomeStateSchema) {
return new SomeStateSchema().new PersistentSomeState(uid.getId(), partyA.getName().toString(), partyB.getName().toString(), addresses);
} else {
throw new IllegalArgumentException("Unrecognised schema $schema");
}
}
#Override
public Iterable<MappedSchema> supportedSchemas() {
return ImmutableList.of(new SomeStateSchema());
}
#Override
public UniqueIdentifier getLinearId() {
return uid;
}
}
public class SomeStateSchema extends MappedSchema {
public SomeStateSchema() {
super(SomeStateSchema.class, 1, ImmutableList.of(PersistentSomeState.class));
}
#Entity
#Table(name = "records")
public class PersistentSomeState extends PersistentState{
#Column(name = "uid")
private final UUID uId;
#Column(name = "partyA")
private final String partyA;
#Column(name = "partyB")
private final String partyB;
#ElementCollection
private final List<Address> addresses;
public PersistentSomeState(UUID uId, String partyA, String partyB, List<Address> addresses) {
super();
this.uId = uId;
this.partyA = partyA;
this.partyB = partyB;
this.addresses = addresses;
}
public UUID getuId() {
return uId;
}
public String getPartyA() {
return partyA;
}
public String getPartyB() {
return partyB;
}
public List<Address> getAddresses() {
return addresses;
}
}
}
#CordaSerializable
public class Address {
public final String street;
public final int pincode;
public Address(String street, int pincode) {
super();
this.street = street;
this.pincode = pincode;
}
public String getStreet() {
return street;
}
public int getPincode() {
return pincode;
}
}
From the controller I call:
#GET
#Path("msas")
#Produces(MediaType.APPLICATION_JSON)
public List<StateAndRef<SomeState>> getMSAs() {
return rpcOps.vaultQuery(SomeState.class).getStates();
}
FLOW is same as in IOU Example.
public SignedTransaction call() throws FlowException {
// Obtain a reference to the notary we want to use.
final Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0);
Set<PublicKey> set= getServiceHub().getKeyManagementService().getKeys();
//val ourParties = ourKeys.map { serviceHub.identityService.partyFromKey(it) ?: throw IllegalStateException("Unable to resolve party from key") }
//
List<Party> parties= new ArrayList();
for (Iterator<PublicKey> it = set.iterator(); it.hasNext(); ) {
parties.add(getServiceHub().getIdentityService().partyFromKey(it.next()));
}
progressTracker.setCurrentStep(GENERATING_TRANSACTION);
// Generate an unsigned transaction.
SomeState someState = new SomeState(getServiceHub().getMyInfo().getLegalIdentities().get(0),otherParty,Arrays.asList(new Address("Yes Street",12532)));
final Command<SomeContract.Commands.Create> txCommand = new Command<>(new SomeContract.Commands.Create(),
someState.getParticipants().stream().map(AbstractParty::getOwningKey).collect(Collectors.toList()));
final TransactionBuilder txBuilder = new TransactionBuilder(notary).withItems(new StateAndContract(someState, MSAContract.MSA_CONTRACT_ID), txCommand);
// Stage 2.
progressTracker.setCurrentStep(VERIFYING_TRANSACTION);
// Verify that the transaction is valid.
txBuilder.verify(getServiceHub());
// Stage 3.
progressTracker.setCurrentStep(SIGNING_TRANSACTION);
// Sign the transaction.
final SignedTransaction partSignedTx = getServiceHub().signInitialTransaction(txBuilder);
FlowSession otherPartySession = initiateFlow(otherparty);
// Stage 4.
progressTracker.setCurrentStep(GATHERING_SIGS);
// Send the state to the counterparty, and receive it back with their signature.
final SignedTransaction fullySignedTx = subFlow(
new CollectSignaturesFlow(partSignedTx, Sets.newHashSet(otherPartySession), CollectSignaturesFlow.Companion.tracker()));
// Stage 5.
progressTracker.setCurrentStep(FINALISING_TRANSACTION);
// Notarise and record the transaction in both parties' vaults.
return subFlow(new FinalityFlow(fullySignedTx));
}
I finally found the rootException:
Caused by: org.hibernate.MappingException: Could not determine type for: com.den.managment.state.Address, at table: SomeStateSchema$PersistentSomeState_addresses, for columns: [org.hibernate.mapping.Column(addresses)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:455)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:422)
at org.hibernate.mapping.Collection.validate(Collection.java:310)
at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:333)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444)
at net.corda.node.services.persistence.HibernateConfiguration.buildSessionFactory(HibernateConfiguration.kt:101)
at net.corda.node.services.persistence.HibernateConfiguration.makeSessionFactoryForSchemas(HibernateConfiguration.kt:74)
at net.corda.node.services.persistence.HibernateConfiguration.access$makeSessionFactoryForSchemas(HibernateConfiguration.kt:27)
at net.corda.node.services.persistence.HibernateConfiguration$sessionFactoryForSchemas$1.apply(HibernateConfiguration.kt:54)
at net.corda.node.services.persistence.HibernateConfiguration$sessionFactoryForSchemas$1.apply(HibernateConfiguration.kt:27)
at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(Unknown Source)
at net.corda.node.services.persistence.HibernateConfiguration.sessionFactoryForSchemas(HibernateConfiguration.kt:54)
at net.corda.node.services.persistence.HibernateConfiguration.sessionFactoryForSchema(HibernateConfiguration.kt:48)
at net.corda.node.services.schema.HibernateObserver.persistStateWithSchema(HibernateObserver.kt:41)
at net.corda.node.services.schema.HibernateObserver.persistState(HibernateObserver.kt:37)
at net.corda.node.services.schema.HibernateObserver.persist(HibernateObserver.kt:31)
at net.corda.node.services.schema.HibernateObserver.access$persist(HibernateObserver.kt:20)
at net.corda.node.services.schema.HibernateObserver$1.call(HibernateObserver.kt:27)
at net.corda.node.services.schema.HibernateObserver$1.call(HibernateObserver.kt:20)
at rx.internal.util.ActionSubscriber.onNext(ActionSubscriber.java:39)
at rx.observers.SafeSubscriber.onNext(SafeSubscriber.java:134)
... 42 more
Your flow is throwing various exceptions because of underlying issues with your code. Corda is then trying to serialise these exceptions to send them back to your RPC client via the RPC framework. Since these types are not whitelisted to be sent via RPC, you get a Kryo exception when you try.
In other words, these exceptions are just a symptom (of your underlying code throwijng AnnotationException or MappingException) rather than a root cause.
Can you post the code showing the Person state definition and how you are trying to retrieve it from the vault in the flow?

Authentication work only in debug but not release mode

I followed the sample code realtime database at https://github.com/firebase/quickstart-android/tree/master/database
Everything works find in debug mode. However, if i install the signed apk , download from google play , change the build variant from debug to release in android studio. Signing in will crash.
I have obtained the SHA1 for release and updated the json file accordingly.
I have observed this, do not know if t is relevant.
If i use debug mode to login successfully, the database will change
In release mode, the change do not appear in the database console
from
a:
"test#gmail.com"
b:
"test"
to
email:
"test#gmail.com"
username:
"test"
The error logcat
E/AndroidRuntime: FATAL EXCEPTION: main
Process: simonhcm.multiplay, PID: 18928
java.lang.RuntimeException: java.lang.NoSuchMethodException: <init> [class android.view.View]
at com.a.a.a.d.a(Unknown Source)
at android.support.v7.widget.ek.b(Unknown Source)
at android.support.v7.widget.fb.a(Unknown Source)
at android.support.v7.widget.fb.c(Unknown Source)
at android.support.v7.widget.dj.a(Unknown Source)
at android.support.v7.widget.LinearLayoutManager.a(Unknown Source)
at android.support.v7.widget.LinearLayoutManager.a(Unknown Source)
at android.support.v7.widget.LinearLayoutManager.c(Unknown Source)
at android.support.v7.widget.RecyclerView.J(Unknown Source)
at android.support.v7.widget.RecyclerView.k(Unknown Source)
at android.support.v7.widget.RecyclerView.t(Unknown Source)
at android.support.v7.widget.RecyclerView.c(Unknown Source)
at android.support.v7.widget.ee.run(Unknown Source)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:603)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.NoSuchMethodException: <init> [class android.view.View]
at java.lang.Class.getConstructor(Class.java:528)
at java.lang.Class.getConstructor(Class.java:492)
at com.a.a.a.d.a(Unknown Source) 
at android.support.v7.widget.ek.b(Unknown Source) 
at android.support.v7.widget.fb.a(Unknown Source) 
at android.support.v7.widget.fb.c(Unknown Source) 
at android.support.v7.widget.dj.a(Unknown Source) 
at android.support.v7.widget.LinearLayoutManager.a(Unknown Source) 
at android.support.v7.widget.LinearLayoutManager.a(Unknown Source) 
at android.support.v7.widget.LinearLayoutManager.c(Unknown Source) 
at android.support.v7.widget.RecyclerView.J(Unknown Source) 
at android.support.v7.widget.RecyclerView.k(Unknown Source) 
at android.support.v7.widget.RecyclerView.t(Unknown Source) 
at android.support.v7.widget.RecyclerView.c(Unknown Source) 
at android.support.v7.widget.ee.run(Unknown Source) 
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858) 
at android.view.Choreographer.doCallbacks(Choreographer.java:670) 
at android.view.Choreographer.doFrame(Choreographer.java:603) 
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
W/ActivityManager: Force finishing activity simonhcm.multiplay/.MainActivity
W/DropBoxManagerService: Dropping: data_app_crash (1883 > 0 bytes)
I/OpenGLRenderer: Initialized EGL, version 1.4
I/art: Background partial concurrent mark sweep GC freed 6907(456KB) AllocSpace objects, 1(20KB) LOS objects, 28% free, 41MB/57MB, paused 1.419ms total 107.537ms
E/DropBoxTask: null InputStream
java.io.IOException: null InputStream
at wtd.a(:com.google.android.gms:182)
at wtd.b(:com.google.android.gms:124)
at wsi.a(:com.google.android.gms:88)
at com.google.android.gms.stats.service.DropBoxEntryAddedChimeraService.onHandleIntent(:com.google.android.gms:1176)
at bdz.handleMessage(:com.google.android.gms:65)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148) at android.os.HandlerThread.run(HandlerThread.java:61)
The sign in activity
public class SignInActivity extends BaseActivity implements View.OnClickListener {
private static final String TAG = "SignInActivity";
private DatabaseReference mDatabase;
private FirebaseAuth mAuth;
private EditText mEmailField;
private EditText mPasswordField;
private Button mSignInButton;
private Button mSignUpButton;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_in);
mDatabase = FirebaseDatabase.getInstance().getReference();
mAuth = FirebaseAuth.getInstance();
// Views
mEmailField = (EditText) findViewById(R.id.field_email);
mPasswordField = (EditText) findViewById(R.id.field_password);
mSignInButton = (Button) findViewById(R.id.button_sign_in);
mSignUpButton = (Button) findViewById(R.id.button_sign_up);
// Click listeners
mSignInButton.setOnClickListener(this);
mSignUpButton.setOnClickListener(this);
}
#Override
public void onStart() {
super.onStart();
// Check auth on Activity start
if (mAuth.getCurrentUser() != null) {
onAuthSuccess(mAuth.getCurrentUser());
}
}
private void signIn() {
Log.d(TAG, "signIn");
if (!validateForm()) {
return;
}
showProgressDialog();
String email = mEmailField.getText().toString();
String password = mPasswordField.getText().toString();
mAuth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
Log.d(TAG, "signIn:onComplete:" + task.isSuccessful());
hideProgressDialog();
if (task.isSuccessful()) {
onAuthSuccess(task.getResult().getUser());
} else {
Toast.makeText(SignInActivity.this, "Sign In Failed",
Toast.LENGTH_SHORT).show();
}
}
});
}
private void signUp() {
Log.d(TAG, "signUp");
if (!validateForm()) {
return;
}
showProgressDialog();
String email = mEmailField.getText().toString();
String password = mPasswordField.getText().toString();
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(
new OnCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task) {
Log.d(TAG, "createUser:onComplete:" + task.isSuccessful());
hideProgressDialog();
if (task.isSuccessful()) {
onAuthSuccess(task.getResult().getUser());
} else {
Toast.makeText(SignInActivity.this, "Sign Up Failed",
Toast.LENGTH_SHORT).show();
}
}
});
}
private void onAuthSuccess(FirebaseUser user) {
String username = usernameFromEmail(user.getEmail());
// Write new user
writeNewUser(user.getUid(), username, user.getEmail());
// Go to MainActivity
startActivity(new Intent(SignInActivity.this, MainActivity.class));
finish();
}
private String usernameFromEmail(String email) {
if (email.contains("#")) {
return email.split("#")[0];
} else {
return email;
}
}
private boolean validateForm() {
boolean result = true;
if (TextUtils.isEmpty(mEmailField.getText().toString())) {
mEmailField.setError("Required");
result = false;
} else {
mEmailField.setError(null);
}
if (TextUtils.isEmpty(mPasswordField.getText().toString())) {
mPasswordField.setError("Required");
result = false;
} else {
mPasswordField.setError(null);
}
return result;
}
// [START basic_write]
private void writeNewUser(String userId, String name, String email) {
User user = new User(name, email);
mDatabase.child("users").child(userId).setValue(user);
}
// [END basic_write]
#Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.button_sign_in:
signIn();
break;
case R.id.button_sign_up:
signUp();
break;
}
}
}

Having an exception when using TopLink on WebLogic

I get the below exception when trying to run an EJB application using TopLink on WebLogic application server.
java.lang.IllegalArgumentException: NamedQuery of name: TblPkgFeature.getFeaturesData not found:
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.getDatabaseQuery(EJBQueryImpl.java:422)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.setParameterInternal(EJBQueryImpl.java:657)
at oracle.toplink.essentials.internal.ejb.cmp3.EJBQueryImpl.setParameter(EJBQueryImpl.java:202)
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:601)
at weblogic.persistence.InterceptingInvocationHandlerImpl.invoke(InterceptingInvocationHandlerImpl.java:29)
at $Proxy110.setParameter(Unknown Source)
at com.siliconexpert.avago.service.impl.PartDetailServiceImpl.getPackageData(PartDetailServiceImpl.java:170)
at com.siliconexpert.avago.service.impl.PartDetailService_888km8_PartDetailServiceRemoteImpl.__WL_invoke(Unknown Source)
at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:34)
at com.siliconexpert.avago.service.impl.PartDetailService_888km8_PartDetailServiceRemoteImpl.getPackageData(Unknown Source)
at com.siliconexpert.avago.service.impl.PartDetailService_888km8_PartDetailServiceRemoteImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:202)
at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:463)
at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:274)
at com.siliconexpert.avago.service.impl.PartDetailService_888km8_PartDetailServiceRemoteImpl_12120_WLStub.getPackageData(Unknown Source)
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:601)
at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:84)
at $Proxy111.getPackageData(Unknown Source)
at com.siliconexpert.avago.server.rmi.client.PartDetailServiceRmiClient.getPackageData(PartDetailServiceRmiClient.java:108)
at com.siliconexpert.avago.gui.server.services.PartDetailRemoteServiceImpl.getPackageData(PartDetailRemoteServiceImpl.java:121)
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:601)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:751)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:341)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
at com.siliconexpert.avago.gui.server.services.MainFilter.doFilter(MainFilter.java:47)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3367)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3333)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2220)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2146)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2124)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1564)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)
The above exception is thrown on the below line:
List<TblPkgFeature> list =
em.createNamedQuery("TblPkgFeature.getFeaturesData").setParameter("pkgTypeId", GetFeaturesData.PACKAGE.getCode()).setParameter("type", "package").getResultList();
Also when I changed this method em.createNamedQuery("TblPkgFeature.getFeaturesData") by the method
em.createQuery("select new com.siliconexpert.avago.model.TblPkgFeature(p.fetId, p.fetName, p.fetDisplayName, o.fetDefention, p.unit) " +
" from TblPkgFeature p left outer join p.tblOthersFetDef o where (lower(o.type) =:type or o.type is null )" +
" and p.display=1 and p.pkgTypeId =:pkgTypeId order by p.cmDisplayOrder")
it worked successfully and the exception wasn't thrown.
By the way both queries are the same, but the difference is that I placed the query in the method parameter of the "createQuery()" method.
The below is the entity bean that contains the NamedQuery:
package com.siliconexpert.avago.model;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
/**
* The persistent class for the TBL_PKG_FEATURES database table.
*
*/
#NamedQueries
({
#NamedQuery(name="TblPkgFeature.getFeaturesData", query="select new com.siliconexpert.avago.model.TblPkgFeature(p.fetId, p.fetName, p.fetDisplayName, o.fetDefention, p.unit) " +
" from TblPkgFeature p left outer join p.tblOthersFetDef o where (lower(o.type) =:type or o.type is null )" +
" and p.display=1 and p.pkgTypeId =:pkgTypeId order by p.cmDisplayOrder ") //and p.fetId<>39
})
#Entity
#Table(name = "TBL_PKG_FEATURES")
public class TblPkgFeature implements Serializable
{
private static final long serialVersionUID = -8604710446605212000L;
#Id
#Column(name = "FET_ID")
private long fetId;
#Column(name = "CM_DISPLAY_ORDER")
private long cmDisplayOrder;
#Column(name = "DATA_LENGHT")
private long dataLenght;
#Column(name = "DATA_TYPE")
private String dataType;
private long display;
#Column(name = "FET_DISPLAY_NAME")
private String fetDisplayName;
#Column(name = "FET_HEADER_ORDER")
private long fetHeaderOrder;
#Column(name = "FET_NAME")
private String fetName;
#Column(name = "OLD_NAME")
private String oldName;
#Column(name = "PKG_TYPE_ID")
private long pkgTypeId;
#Column(name = "QUALITY_AV")
private long qualityAv;
#Column(name = "TBL_NAME")
private String tblName;
private String unit;
#OneToOne
#JoinColumn(name="FET_NAME", referencedColumnName="FET_NAME", updatable=false, insertable=false)
private TblOthersFetDef tblOthersFetDef;
#Transient
private String fetDefinition;
public TblPkgFeature()
{
}
public TblPkgFeature(long fetId, String fetDisplayName)
{
super();
this.fetId = fetId;
this.fetDisplayName = fetDisplayName;
}
public TblOthersFetDef getTblOthersFetDef()
{
return tblOthersFetDef;
}
public void setTblOthersFetDef(TblOthersFetDef tblOthersFetDef)
{
this.tblOthersFetDef = tblOthersFetDef;
}
public TblPkgFeature(long fetId, String fetDisplayName, String fetDefinition, String unit)
{
this(fetId, fetDisplayName);
this.fetDefinition = fetDefinition;
this.unit = unit;
}
public TblPkgFeature(long fetId, String fetName, String fetDisplayName, String fetDefinition, String unit)
{
this(fetId, fetDisplayName, fetDefinition, unit);
this.fetName = fetName;
}
public String getFetDefinition()
{
return fetDefinition;
}
public void setFetDefinition(String fetDefinition)
{
this.fetDefinition = fetDefinition;
}
public long getFetId()
{
return this.fetId;
}
public void setFetId(long fetId)
{
this.fetId = fetId;
}
public long getCmDisplayOrder()
{
return this.cmDisplayOrder;
}
public void setCmDisplayOrder(long cmDisplayOrder)
{
this.cmDisplayOrder = cmDisplayOrder;
}
public long getDataLenght()
{
return this.dataLenght;
}
public void setDataLenght(long dataLenght)
{
this.dataLenght = dataLenght;
}
public String getDataType()
{
return this.dataType;
}
public void setDataType(String dataType)
{
this.dataType = dataType;
}
public long getDisplay()
{
return this.display;
}
public void setDisplay(long display)
{
this.display = display;
}
public String getFetDisplayName()
{
return this.fetDisplayName;
}
public void setFetDisplayName(String fetDisplayName)
{
this.fetDisplayName = fetDisplayName;
}
public long getFetHeaderOrder()
{
return this.fetHeaderOrder;
}
public void setFetHeaderOrder(long fetHeaderOrder)
{
this.fetHeaderOrder = fetHeaderOrder;
}
public String getFetName()
{
return this.fetName;
}
public void setFetName(String fetName)
{
this.fetName = fetName;
}
public String getOldName()
{
return this.oldName;
}
public void setOldName(String oldName)
{
this.oldName = oldName;
}
public long getPkgTypeId()
{
return this.pkgTypeId;
}
public void setPkgTypeId(long pkgTypeId)
{
this.pkgTypeId = pkgTypeId;
}
public long getQualityAv()
{
return this.qualityAv;
}
public void setQualityAv(long qualityAv)
{
this.qualityAv = qualityAv;
}
public String getTblName()
{
return this.tblName;
}
public void setTblName(String tblName)
{
this.tblName = tblName;
}
public String getUnit()
{
return this.unit;
}
public void setUnit(String unit)
{
this.unit = unit;
}
}
Please help.
Thanks.

Autowired in Spring MVC getting error : Error creating bean with name 'userService': Injection of autowired dependencies

I am having this error for few days and seem to get no luck. Tried googling but still can't get it working. Looking on the log it keeps on telling me that there is something wrong with my "Injection of autowired dependencies" but I just can't get it. Hope to hear from you.
Error Logs.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.sesame.repository.UserRepository com.sesame.service.UserService.userRepository; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.sesame.repository.UserRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1210)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:117)
at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:108)
at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:68)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175)
.......
Controller class
#Controller
#RequestMapping(value = "/protected/users")
public class UsersControl {
private static final String DEFAULT_PAGE_DISPLAYED_TO_USER = "0";
#Autowired
private UserService userService;
#Autowired
private MessageSource messageSource;
#Value("5")
private int maxResults;
#RequestMapping(method = RequestMethod.GET)
public ModelAndView welcome() {
return new ModelAndView("contactsList");
}
#RequestMapping(method = RequestMethod.GET, produces = "application/json")
public ResponseEntity<?> listAll(#RequestParam int page, Locale locale) {
return createListAllResponse(page, locale);
}
private UserListVO listAll(int page) {
return userService.findAll(page, maxResults);
}
private ResponseEntity<UserListVO> returnListToUser(UserListVO contactList) {
return new ResponseEntity<UserListVO>(contactList, HttpStatus.OK);
}
private ResponseEntity<?> createListAllResponse(int page, Locale locale) {
return createListAllResponse(page, locale, null);
}
private ResponseEntity<?> createListAllResponse(int page, Locale locale, String messageKey) {
UserListVO UserListVO = listAll(page);
addActionMessageToVO(UserListVO, locale, messageKey, null);
return returnListToUser(UserListVO);
}
private UserListVO addActionMessageToVO(UserListVO UserListVO, Locale locale, String actionMessageKey, Object[] args) {
if (StringUtils.isEmpty(actionMessageKey)) {
return UserListVO;
}
UserListVO.setActionMessage(messageSource.getMessage(actionMessageKey, args, null, locale));
return UserListVO;
}
}
service is existing:
#Service("userService")
#Transactional
public class UserService {
#Autowired
private UserRepository userRepository;
#Transactional(readOnly = true)
public UserListVO findAll(int page, int maxResults) {
Page<User> result = executeQueryFindAll(page, maxResults);
if(shouldExecuteSameQueryInLastPage(page, result)){
int lastPage = result.getTotalPages() - 1;
result = executeQueryFindAll(lastPage, maxResults);
}
return buildResult(result);
}
private Page<User> executeQueryFindAll(int page, int maxResults) {
final PageRequest pageRequest = new PageRequest(page, maxResults, sortByNameASC());
System.out.println("Now in ExectueQuery"+pageRequest);
return userRepository.findAll(pageRequest);
}
private Sort sortByNameASC() {
return new Sort(Sort.Direction.ASC, "name");
}
private UserListVO buildResult(Page<User> result) {
return new UserListVO(result.getTotalPages(), result.getTotalElements(), result.getContent());
}
private boolean shouldExecuteSameQueryInLastPage(int page, Page<User> result) {
return isUserAfterOrOnLastPage(page, result) && hasDataInDataBase(result);
}
private boolean isUserAfterOrOnLastPage(int page, Page<User> result) {
return page >= result.getTotalPages() - 1;
}
private boolean hasDataInDataBase(Page<User> result) {
return result.getTotalElements() > 0;
}
}
I've added the repository
#Repository("userRepository")
public interface UserRepository extends JpaRepository<User, Integer> {
Page<User> findByUserNameLike(Pageable pageable, String UserName);
}
WebConfiguration
#Configuration
#EnableWebMvc
#ComponentScan(basePackages="com.sesame")
#EnableAutoConfiguration
#PropertySource(value = { "classpath:application.properties" })
#EnableScheduling
#EnableAspectJAutoProxy
#EnableCaching
public class WebConfig extends WebMvcConfigurerAdapter {
#Autowired
private Environment env;
#Bean
public MessageSource messageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("messages");
return messageSource;
}
#Bean
public LocaleResolver localeResolver() {
SessionLocaleResolver resolver = new SessionLocaleResolver();
resolver.setDefaultLocale(Locale.ENGLISH);
return resolver;
}
#Override
public void addInterceptors(InterceptorRegistry registry) {
LocaleChangeInterceptor changeInterceptor = new LocaleChangeInterceptor();
changeInterceptor.setParamName("language");
registry.addInterceptor(changeInterceptor);
}
#Bean
public InternalResourceViewResolver getInternalResourceViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/views/");
resolver.setSuffix("/");
return resolver;
}
#Bean public static PropertySourcesPlaceholderConfigurer placeHolderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
#Bean
public JavaMailSenderImpl javaMailSenderImpl() {
JavaMailSenderImpl mailSenderImpl = new JavaMailSenderImpl();
mailSenderImpl.setHost(env.getProperty("smtp.host"));
mailSenderImpl.setPort(env.getProperty("smtp.port", Integer.class));
mailSenderImpl.setProtocol(env.getProperty("smtp.protocol"));
mailSenderImpl.setUsername(env.getProperty("smtp.username"));
mailSenderImpl.setPassword(env.getProperty("smtp.password"));
Properties javaMailProps = new Properties();
javaMailProps.put("mail.smtp.auth", true);
javaMailProps.put("mail.smtp.starttls.enable", true);
mailSenderImpl.setJavaMailProperties(javaMailProps);
return mailSenderImpl;
}
#Bean public CacheManager cacheManager() {
return new ConcurrentMapCacheManager();
}
#Bean
public ServletRegistrationBean dispatcherRegistration() {
ServletRegistrationBean registration = new ServletRegistrationBean(
dispatcherServlet());
registration.addUrlMappings("/");
registration.addUrlMappings("*.pdf");
registration.addUrlMappings("*.json");
registration.addUrlMappings("*.js");
registration.addUrlMappings("*.xml");
registration.addUrlMappings("*.css");
return registration;
}
#Bean(name = DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)
public DispatcherServlet dispatcherServlet() {
return new DispatcherServlet();
}
#Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/pdfs/**").addResourceLocations(
"/WEB-INF/pdf/");
registry.addResourceHandler("/resources/js/**").addResourceLocations(
"/WEB-INF/resources/js/");
registry.addResourceHandler("/resources/css/**").addResourceLocations(
"/WEB-INF/resources/css/");
registry.addResourceHandler("/resources/img/**").addResourceLocations(
"/WEB-INF/resources/img/");
}
#Bean
public ViewResolver tilesViewResolver() {
return new TilesViewResolver();
}
#Bean
public TilesConfigurer tilesConfigurer() {
TilesConfigurer tiles = new TilesConfigurer();
tiles.setDefinitions(new String[] {"/WEB-INF/tiles.xml"});
tiles.setCheckRefresh(true);
return tiles;
}
}
Create a JPA Config Class as below :
#Configuration
#EnableJpaRepositories(basePackages="com.sesame.repository")
#EntityScan(basePackages="com.sesame.model")
public class JpaConfiguration {
}

Cannot persist record with a Persistent InputStream in OpenJPA

I'm trying to persist a record that has a mapped #Persistent InputStream field.
the context is: JDK 1.8, LiferayPortal on Tomee 1.7.1 (OpenJPA 2.4-patch). Sorry about the stacktrace polluted by the Liferay one.
#Entity
#Table(name = "file_entries")
public class FileEntry implements Serializable {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
#Column(length = 120)
private String createdBy;
#Temporal(TemporalType.TIMESTAMP)
private Date created;
#Column(length = 120)
private String modifiedBy;
#Temporal(TemporalType.TIMESTAMP)
private Date modified;
#Column(length = 200)
private String title;
#Column(length = 2000)
private String description;
#Column(length = 240)
private String filename;
#Column(length = 60)
private String extension;
#Column(length = 20)
private String version;
#Column(length = 240)
private String contentType;
#Persistent(fetch = FetchType.LAZY)
private InputStream content;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public String getModifiedBy() {
return modifiedBy;
}
public void setModifiedBy(String modifiedBy) {
this.modifiedBy = modifiedBy;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getFilename() {
return filename;
}
public void setFilename(String filename) {
this.filename = filename;
}
public String getExtension() {
return extension;
}
public void setExtension(String extension) {
this.extension = extension;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public InputStream getContent() {
return content;
}
public void setContent(InputStream content) {
this.content = content;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
}
And when persisting:
logo = new FileEntry();
logo.setContent(new FileInputStream("some_local_file"));
entityService.persist(logo);
I get the following exception.
<openjpa-2.4.0-nonfinal-1598334-r422266:1599166 fatal general error> org.apache.openjpa.persistence.PersistenceException: The transaction has been rolled back. See the nested exceptions for details on the errors that occurred.
at org.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:2370)
at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2207)
at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2105)
at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1876)
at org.apache.openjpa.kernel.DelegatingBroker.flush(DelegatingBroker.java:1045)
at org.apache.openjpa.persistence.EntityManagerImpl.flush(EntityManagerImpl.java:663)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.zeroturnaround.jrebel.integration.openjpa.EntityManagerFactoryWrapper$ReloadingMethodHandler.invoke(EntityManagerFactoryWrapper.java:135)
at com.sun.proxy.$Proxy619.flush(Unknown Source)
at org.apache.openejb.persistence.JtaEntityManager.flush(JtaEntityManager.java:202)
at com.computas.generic.service.SimpleEntityService.persist(SimpleEntityService.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:192)
at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:173)
at org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:181)
at org.apache.openejb.monitoring.StatsInterceptor.invoke(StatsInterceptor.java:100)
at sun.reflect.GeneratedMethodAccessor585.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:192)
at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:173)
at org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:85)
at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:227)
at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:194)
at org.apache.openejb.core.ivm.EjbObjectProxyHandler.synchronizedBusinessMethod(EjbObjectProxyHandler.java:308)
at org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:303)
at org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:92)
at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:308)
... 171 more
Caused by: <openjpa-2.4.0-nonfinal-1598334-r422266:1599166 fatal general error> org.apache.openjpa.persistence.PersistenceException: can't call setAutoCommit when the connection is JtaManaged
at org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4998)
at org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4958)
at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:134)
at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:108)
at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:60)
at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.populateRowManager(AbstractUpdateManager.java:185)
at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:96)
at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:77)
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:732)
at org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:131)
... 204 more
Caused by: java.sql.SQLException: can't call setAutoCommit when the connection is JtaManaged
at org.apache.openejb.resource.jdbc.managed.local.ManagedConnection.forbiddenCall(ManagedConnection.java:185)
at org.apache.openejb.resource.jdbc.managed.local.ManagedConnection.invokeUnderTransaction(ManagedConnection.java:162)
at org.apache.openejb.resource.jdbc.managed.local.ManagedConnection.invoke(ManagedConnection.java:93)
at com.sun.proxy.$Proxy618.setAutoCommit(Unknown Source)
at org.apache.openjpa.lib.jdbc.DelegatingConnection.setAutoCommit(DelegatingConnection.java:167)
at org.apache.openjpa.lib.jdbc.DelegatingConnection.setAutoCommit(DelegatingConnection.java:167)
at org.apache.openjpa.lib.jdbc.ConfiguringConnectionDecorator$ConfiguringConnection.setAutoCommit(ConfiguringConnectionDecorator.java:117)
at org.apache.openjpa.lib.jdbc.DelegatingConnection.setAutoCommit(DelegatingConnection.java:167)
at org.apache.openjpa.lib.jdbc.DelegatingConnection.setAutoCommit(DelegatingConnection.java:167)
at org.apache.openjpa.jdbc.sql.PostgresDictionary.insertPostgresBlob(PostgresDictionary.java:627)
at org.apache.openjpa.jdbc.sql.PostgresDictionary.insertBlobForStreamingLoad(PostgresDictionary.java:614)
at org.apache.openjpa.jdbc.meta.strats.LobFieldStrategy.insert(LobFieldStrategy.java:100)
at org.apache.openjpa.jdbc.meta.FieldMapping.insert(FieldMapping.java:623)
at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.insert(AbstractUpdateManager.java:238)
at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.populateRowManager(AbstractUpdateManager.java:165)
... 208 more
The persistence unit declaration is:
<persistence-unit name="uefiscdi" transaction-type="JTA">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<jta-data-source>uefiscdiDS</jta-data-source>
<properties>
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)" />
<property name="openjpa.jdbc.DBDictionary" value="postgres" />
<property name="openjpa.Log" value="DefaultLevel=INFO, Tool=INFO" />
</properties>
</persistence-unit>
The Datasource declaration is:
<Resource id="uefiscdiDS" type="DataSource">
JdbcDriver org.postgresql.Driver
JdbcUrl jdbc:postgresql://localhost:5432/db_name
UserName user_name
Password user_password
JtaManaged true
DefaultAutoCommit false
</Resource>
I tried with DefaultAutoCommit true / false / not declared ... same exception.
Just a shot in the dark, but have you tried calling em.persist(...) rather than em.merge(..)?
If that doesn't work it might be helpful if you posted the full stack trace somewhere. I'm afraid you might have snipped off the important parts.

Resources