Posts

Showing posts from March, 2013

Jackson - BeanSerializer.serialize and ContainerSerializers$CollectionSerializer.serialize error

In a Spring + Hibernate + Jackson project while calling:

http://localhost:8080/SpringMVC/getAllBookmark

(...)

@RequestMapping(value="/getAllBookmark", method = RequestMethod.GET) public@ResponseBody List getAllBookmarkJSON() { List list = this.bookmarkDAO.getAllBookmark(); return list; }
(...)

, was getting the following error:

at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:122) at org.codehaus.jackson.map.ser.ContainerSerializers$CollectionSerializer.serialize(ContainerSerializers.java:151) at org.codehaus.jackson.map.ser.ContainerSerializers$CollectionSerializer.serialize(ContainerSerializers.java:117) at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:218)
The problem was related to a cyclic reference (click here for more information) in a relation type "many-to-one" between Bookmark and Image:

(...)

publicclass Bookmark implements Serializable { privatestaticfinallongserialVersionUID = 1L; private Lo…

Oracle - Conceder permisos de acceso a una table

Script para conceder permisos de acceso a una tabla/view a un User/Schema:

grant select on to ;

Con opcion "grantable"

grant select on to ; with grant option;

Hibernate - HibernateException: createQuery is not valid without active transaction

Problem:SEVERE: Servlet.service() for servlet mvc-dispatcher threw exception
org.hibernate.HibernateException: createQuery is not valid without active transaction
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:338)
at com.sun.proxy.$Proxy20.createQuery(Unknown Source)
at com.mkyong.common.dao.MessageDAO.getAllMessages(MessageDAO.java:39)
at com.mkyong.common.controller.MessageController.printMessageList(MessageController.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod…