You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by "Patel, Sanjay" <Sa...@nemours.org> on 2013/03/11 19:50:30 UTC

issue with REST service

I have simple REST service. It returns list of entity. (e.g. Event)

       @GET
       @Path("/events")
       @Produces({ "application/json" })
       public List<Event> findEvents() {
              return eventBean.findEvents().getList();
       }


It works fine if return type is List<Event>. If I change it to EntityDTO (which contains list of Event and int property as shown below), it gives below error.

EntityDTO.java
@XmlRootElement
@XmlSeeAlso({ Event.class })
public class EntityDTO<E> {

       private List<E> list;
       private int totalCount;

       public List<E> getList() {
              return list;
       }

       public void setList(List<E> list) {
              this.list = list;
       }

       public int getTotalCount() {
              return totalCount;
       }

       public void setTotalCount(int totalCount) {
              this.totalCount = totalCount;
       }

}

This is the error I get.
WARNING: javax.ws.rs.WebApplicationException: java.lang.NullPointerException
at org.apache.cxf.jaxrs.provider.json.JSONProvider.writeTo(JSONProvider.java:370)
at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.writeTo(JAXRSOutInterceptor.java:298)
at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:258)
at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(JAXRSOutInterceptor.java:146)
at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAXRSOutInterceptor.java:84)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:77)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:236)
at org.apache.openejb.server.cxf.rs.CxfRsHttpListener.onMessage(CxfRsHttpListener.java:70)
at org.apache.openejb.server.rest.RsServlet.service(RsServlet.java:53)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)


What am I missing? Any help would be appreciated.

Thanks.

RE: issue with REST service

Posted by "Patel, Sanjay" <Sa...@nemours.org>.
I was getting same error in both 1.5.1 and 1.6.0 snapshot.

I got it working by adding @XmlAnyElement(lax=true) in EntityDTO.java. I think it is required because of generic entity E.

@XmlAnyElement(lax=true)
public List<E> getList() {
	return list;
}

Thanks,
-Sanjay Patel

-----Original Message-----
From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com] 
Sent: Tuesday, March 12, 2013 1:35 AM
To: users@tomee.apache.org
Subject: RE: issue with REST service

I didnt try to be honest...but basically the serialization is the same so the issue should be somewhere else Le 12 mars 2013 06:03, "Patel, Sanjay" <Sa...@nemours.org> a écrit :

> Do you get same error on 1.5.1?
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
> Sent: Monday, March 11, 2013 4:52 PM
> To: users@tomee.apache.org
> Subject: Re: issue with REST service
>
> works fine on the snapshot
>
> i just added to the pom in build section the plugin:
>
> <plugin>
>         <groupId>org.apache.openejb.maven</groupId>
>         <artifactId>tomee-maven-plugin</artifactId>
>         <version>1.6.0-SNAPSHOT</version>
>         <configuration>
>           <tomeeClassifier>jaxrs</tomeeClassifier>
>           <simpleLog>true</simpleLog>
>         </configuration>
>       </plugin>
>
>
> then ran mvn tomee:run
>
> *Romain Manni-Bucau*
> *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> *Blog: **http://rmannibucau.wordpress.com/*<
> http://rmannibucau.wordpress.com/>
> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> *Github: https://github.com/rmannibucau*
>
>
>
> 2013/3/11 Patel, Sanjay <Sa...@nemours.org>
>
> > See attached Project and war.
> >
> > Deploy war to tome 1.5.1.
> >
> > http://localhost:8080/test/secure/rest/one works
> >
> > http://localhost:8080/test/secure/rest/two does not work
> >
> >
> >
> > -----Original Message-----
> > From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
> > Sent: Monday, March 11, 2013 2:57 PM
> > To: users@tomee.apache.org
> > Subject: Re: issue with REST service
> >
> > Any way to reproduce it?
> >
> > Not sure the generics help
> > Le 11 mars 2013 19:51, "Patel, Sanjay" <Sa...@nemours.org> a 
> > écrit
> > :
> >
> > > I have simple REST service. It returns list of entity. (e.g. 
> > > Event)
> > >
> > >        @GET
> > >        @Path("/events")
> > >        @Produces({ "application/json" })
> > >        public List<Event> findEvents() {
> > >               return eventBean.findEvents().getList();
> > >        }
> > >
> > >
> > > It works fine if return type is List<Event>. If I change it to 
> > > EntityDTO (which contains list of Event and int property as shown 
> > > below), it gives below error.
> > >
> > > EntityDTO.java
> > > @XmlRootElement
> > > @XmlSeeAlso({ Event.class })
> > > public class EntityDTO<E> {
> > >
> > >        private List<E> list;
> > >        private int totalCount;
> > >
> > >        public List<E> getList() {
> > >               return list;
> > >        }
> > >
> > >        public void setList(List<E> list) {
> > >               this.list = list;
> > >        }
> > >
> > >        public int getTotalCount() {
> > >               return totalCount;
> > >        }
> > >
> > >        public void setTotalCount(int totalCount) {
> > >               this.totalCount = totalCount;
> > >        }
> > >
> > > }
> > >
> > > This is the error I get.
> > > WARNING: javax.ws.rs.WebApplicationException:
> > > java.lang.NullPointerException
> > > at
> > > org.apache.cxf.jaxrs.provider.json.JSONProvider.writeTo(JSONProvid
> > > er
> > > .j
> > > ava:370)
> > > at
> > > org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.writeTo(JAXRS
> > > Ou
> > > tI
> > > nterceptor.java:298)
> > > at
> > > org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMess
> > > ag
> > > e(
> > > JAXRSOutInterceptor.java:258)
> > > at
> > > org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processRespon
> > > se
> > > (J
> > > AXRSOutInterceptor.java:146)
> > > at
> > > org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage
> > > (J
> > > AX
> > > RSOutInterceptor.java:84)
> > > at
> > > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterc
> > > ep
> > > to
> > > rChain.java:262)
> > > at
> > > org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(
> > > Ou
> > > tg
> > > oingChainInterceptor.java:77)
> > > at
> > > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterc
> > > ep
> > > to
> > > rChain.java:262)
> > > at
> > > org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainIn
> > > it
> > > ia
> > > tionObserver.java:121)
> > > at
> > > org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(Abstr
> > > ac
> > > tH
> > > TTPDestination.java:236)
> > > at
> > > org.apache.openejb.server.cxf.rs.CxfRsHttpListener.onMessage(CxfRs
> > > Ht
> > > tp
> > > Listener.java:70) at
> > > org.apache.openejb.server.rest.RsServlet.service(RsServlet.java:53
> > > ) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
> > > at
> > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(A
> > > pp
> > > li
> > > cationFilterChain.java:305)
> > > at
> > > org.apache.catalina.core.ApplicationFilterChain.doFilter(Applicati
> > > on
> > > Fi
> > > lterChain.java:210)
> > > at
> > > org.springframework.security.web.FilterChainProxy$VirtualFilterCha
> > > in
> > > .d
> > > oFilter(FilterChainProxy.java:330)
> > > at
> > > org.springframework.security.web.access.intercept.FilterSecurityIn
> > > te
> > > rc
> > > eptor.invoke(FilterSecurityInterceptor.java:118)
> > > at
> > > org.springframework.security.web.access.intercept.FilterSecurityIn
> > > te
> > > rc
> > > eptor.doFilter(FilterSecurityInterceptor.java:84)
> > >
> > >
> > > What am I missing? Any help would be appreciated.
> > >
> > > Thanks.
> > >
> >
>

RE: issue with REST service

Posted by Romain Manni-Bucau <rm...@gmail.com>.
I didnt try to be honest...but basically the serialization is the same so
the issue should be somewhere else
Le 12 mars 2013 06:03, "Patel, Sanjay" <Sa...@nemours.org> a écrit :

> Do you get same error on 1.5.1?
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
> Sent: Monday, March 11, 2013 4:52 PM
> To: users@tomee.apache.org
> Subject: Re: issue with REST service
>
> works fine on the snapshot
>
> i just added to the pom in build section the plugin:
>
> <plugin>
>         <groupId>org.apache.openejb.maven</groupId>
>         <artifactId>tomee-maven-plugin</artifactId>
>         <version>1.6.0-SNAPSHOT</version>
>         <configuration>
>           <tomeeClassifier>jaxrs</tomeeClassifier>
>           <simpleLog>true</simpleLog>
>         </configuration>
>       </plugin>
>
>
> then ran mvn tomee:run
>
> *Romain Manni-Bucau*
> *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> *Blog: **http://rmannibucau.wordpress.com/*<
> http://rmannibucau.wordpress.com/>
> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> *Github: https://github.com/rmannibucau*
>
>
>
> 2013/3/11 Patel, Sanjay <Sa...@nemours.org>
>
> > See attached Project and war.
> >
> > Deploy war to tome 1.5.1.
> >
> > http://localhost:8080/test/secure/rest/one works
> >
> > http://localhost:8080/test/secure/rest/two does not work
> >
> >
> >
> > -----Original Message-----
> > From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
> > Sent: Monday, March 11, 2013 2:57 PM
> > To: users@tomee.apache.org
> > Subject: Re: issue with REST service
> >
> > Any way to reproduce it?
> >
> > Not sure the generics help
> > Le 11 mars 2013 19:51, "Patel, Sanjay" <Sa...@nemours.org> a
> > écrit
> > :
> >
> > > I have simple REST service. It returns list of entity. (e.g. Event)
> > >
> > >        @GET
> > >        @Path("/events")
> > >        @Produces({ "application/json" })
> > >        public List<Event> findEvents() {
> > >               return eventBean.findEvents().getList();
> > >        }
> > >
> > >
> > > It works fine if return type is List<Event>. If I change it to
> > > EntityDTO (which contains list of Event and int property as shown
> > > below), it gives below error.
> > >
> > > EntityDTO.java
> > > @XmlRootElement
> > > @XmlSeeAlso({ Event.class })
> > > public class EntityDTO<E> {
> > >
> > >        private List<E> list;
> > >        private int totalCount;
> > >
> > >        public List<E> getList() {
> > >               return list;
> > >        }
> > >
> > >        public void setList(List<E> list) {
> > >               this.list = list;
> > >        }
> > >
> > >        public int getTotalCount() {
> > >               return totalCount;
> > >        }
> > >
> > >        public void setTotalCount(int totalCount) {
> > >               this.totalCount = totalCount;
> > >        }
> > >
> > > }
> > >
> > > This is the error I get.
> > > WARNING: javax.ws.rs.WebApplicationException:
> > > java.lang.NullPointerException
> > > at
> > > org.apache.cxf.jaxrs.provider.json.JSONProvider.writeTo(JSONProvider
> > > .j
> > > ava:370)
> > > at
> > > org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.writeTo(JAXRSOu
> > > tI
> > > nterceptor.java:298)
> > > at
> > > org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessag
> > > e(
> > > JAXRSOutInterceptor.java:258)
> > > at
> > > org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse
> > > (J
> > > AXRSOutInterceptor.java:146)
> > > at
> > > org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(J
> > > AX
> > > RSOutInterceptor.java:84)
> > > at
> > > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercep
> > > to
> > > rChain.java:262)
> > > at
> > > org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(Ou
> > > tg
> > > oingChainInterceptor.java:77)
> > > at
> > > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercep
> > > to
> > > rChain.java:262)
> > > at
> > > org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInit
> > > ia
> > > tionObserver.java:121)
> > > at
> > > org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(Abstrac
> > > tH
> > > TTPDestination.java:236)
> > > at
> > > org.apache.openejb.server.cxf.rs.CxfRsHttpListener.onMessage(CxfRsHt
> > > tp
> > > Listener.java:70) at
> > > org.apache.openejb.server.rest.RsServlet.service(RsServlet.java:53)
> > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
> > > at
> > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(App
> > > li
> > > cationFilterChain.java:305)
> > > at
> > > org.apache.catalina.core.ApplicationFilterChain.doFilter(Application
> > > Fi
> > > lterChain.java:210)
> > > at
> > > org.springframework.security.web.FilterChainProxy$VirtualFilterChain
> > > .d
> > > oFilter(FilterChainProxy.java:330)
> > > at
> > > org.springframework.security.web.access.intercept.FilterSecurityInte
> > > rc
> > > eptor.invoke(FilterSecurityInterceptor.java:118)
> > > at
> > > org.springframework.security.web.access.intercept.FilterSecurityInte
> > > rc
> > > eptor.doFilter(FilterSecurityInterceptor.java:84)
> > >
> > >
> > > What am I missing? Any help would be appreciated.
> > >
> > > Thanks.
> > >
> >
>

RE: issue with REST service

Posted by "Patel, Sanjay" <Sa...@nemours.org>.
Do you get same error on 1.5.1?

-----Original Message-----
From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com] 
Sent: Monday, March 11, 2013 4:52 PM
To: users@tomee.apache.org
Subject: Re: issue with REST service

works fine on the snapshot

i just added to the pom in build section the plugin:

<plugin>
        <groupId>org.apache.openejb.maven</groupId>
        <artifactId>tomee-maven-plugin</artifactId>
        <version>1.6.0-SNAPSHOT</version>
        <configuration>
          <tomeeClassifier>jaxrs</tomeeClassifier>
          <simpleLog>true</simpleLog>
        </configuration>
      </plugin>


then ran mvn tomee:run

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/3/11 Patel, Sanjay <Sa...@nemours.org>

> See attached Project and war.
>
> Deploy war to tome 1.5.1.
>
> http://localhost:8080/test/secure/rest/one works
>
> http://localhost:8080/test/secure/rest/two does not work
>
>
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
> Sent: Monday, March 11, 2013 2:57 PM
> To: users@tomee.apache.org
> Subject: Re: issue with REST service
>
> Any way to reproduce it?
>
> Not sure the generics help
> Le 11 mars 2013 19:51, "Patel, Sanjay" <Sa...@nemours.org> a 
> écrit
> :
>
> > I have simple REST service. It returns list of entity. (e.g. Event)
> >
> >        @GET
> >        @Path("/events")
> >        @Produces({ "application/json" })
> >        public List<Event> findEvents() {
> >               return eventBean.findEvents().getList();
> >        }
> >
> >
> > It works fine if return type is List<Event>. If I change it to 
> > EntityDTO (which contains list of Event and int property as shown 
> > below), it gives below error.
> >
> > EntityDTO.java
> > @XmlRootElement
> > @XmlSeeAlso({ Event.class })
> > public class EntityDTO<E> {
> >
> >        private List<E> list;
> >        private int totalCount;
> >
> >        public List<E> getList() {
> >               return list;
> >        }
> >
> >        public void setList(List<E> list) {
> >               this.list = list;
> >        }
> >
> >        public int getTotalCount() {
> >               return totalCount;
> >        }
> >
> >        public void setTotalCount(int totalCount) {
> >               this.totalCount = totalCount;
> >        }
> >
> > }
> >
> > This is the error I get.
> > WARNING: javax.ws.rs.WebApplicationException:
> > java.lang.NullPointerException
> > at
> > org.apache.cxf.jaxrs.provider.json.JSONProvider.writeTo(JSONProvider
> > .j
> > ava:370)
> > at
> > org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.writeTo(JAXRSOu
> > tI
> > nterceptor.java:298)
> > at
> > org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessag
> > e(
> > JAXRSOutInterceptor.java:258)
> > at
> > org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse
> > (J
> > AXRSOutInterceptor.java:146)
> > at
> > org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(J
> > AX
> > RSOutInterceptor.java:84)
> > at
> > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercep
> > to
> > rChain.java:262)
> > at
> > org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(Ou
> > tg
> > oingChainInterceptor.java:77)
> > at
> > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercep
> > to
> > rChain.java:262)
> > at
> > org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInit
> > ia
> > tionObserver.java:121)
> > at
> > org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(Abstrac
> > tH
> > TTPDestination.java:236)
> > at
> > org.apache.openejb.server.cxf.rs.CxfRsHttpListener.onMessage(CxfRsHt
> > tp
> > Listener.java:70) at
> > org.apache.openejb.server.rest.RsServlet.service(RsServlet.java:53)
> > at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
> > at
> > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(App
> > li
> > cationFilterChain.java:305)
> > at
> > org.apache.catalina.core.ApplicationFilterChain.doFilter(Application
> > Fi
> > lterChain.java:210)
> > at
> > org.springframework.security.web.FilterChainProxy$VirtualFilterChain
> > .d
> > oFilter(FilterChainProxy.java:330)
> > at
> > org.springframework.security.web.access.intercept.FilterSecurityInte
> > rc
> > eptor.invoke(FilterSecurityInterceptor.java:118)
> > at
> > org.springframework.security.web.access.intercept.FilterSecurityInte
> > rc
> > eptor.doFilter(FilterSecurityInterceptor.java:84)
> >
> >
> > What am I missing? Any help would be appreciated.
> >
> > Thanks.
> >
>

Re: issue with REST service

Posted by Romain Manni-Bucau <rm...@gmail.com>.
works fine on the snapshot

i just added to the pom in build section the plugin:

<plugin>
        <groupId>org.apache.openejb.maven</groupId>
        <artifactId>tomee-maven-plugin</artifactId>
        <version>1.6.0-SNAPSHOT</version>
        <configuration>
          <tomeeClassifier>jaxrs</tomeeClassifier>
          <simpleLog>true</simpleLog>
        </configuration>
      </plugin>


then ran mvn tomee:run

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/3/11 Patel, Sanjay <Sa...@nemours.org>

> See attached Project and war.
>
> Deploy war to tome 1.5.1.
>
> http://localhost:8080/test/secure/rest/one works
>
> http://localhost:8080/test/secure/rest/two does not work
>
>
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
> Sent: Monday, March 11, 2013 2:57 PM
> To: users@tomee.apache.org
> Subject: Re: issue with REST service
>
> Any way to reproduce it?
>
> Not sure the generics help
> Le 11 mars 2013 19:51, "Patel, Sanjay" <Sa...@nemours.org> a écrit
> :
>
> > I have simple REST service. It returns list of entity. (e.g. Event)
> >
> >        @GET
> >        @Path("/events")
> >        @Produces({ "application/json" })
> >        public List<Event> findEvents() {
> >               return eventBean.findEvents().getList();
> >        }
> >
> >
> > It works fine if return type is List<Event>. If I change it to
> > EntityDTO (which contains list of Event and int property as shown
> > below), it gives below error.
> >
> > EntityDTO.java
> > @XmlRootElement
> > @XmlSeeAlso({ Event.class })
> > public class EntityDTO<E> {
> >
> >        private List<E> list;
> >        private int totalCount;
> >
> >        public List<E> getList() {
> >               return list;
> >        }
> >
> >        public void setList(List<E> list) {
> >               this.list = list;
> >        }
> >
> >        public int getTotalCount() {
> >               return totalCount;
> >        }
> >
> >        public void setTotalCount(int totalCount) {
> >               this.totalCount = totalCount;
> >        }
> >
> > }
> >
> > This is the error I get.
> > WARNING: javax.ws.rs.WebApplicationException:
> > java.lang.NullPointerException
> > at
> > org.apache.cxf.jaxrs.provider.json.JSONProvider.writeTo(JSONProvider.j
> > ava:370)
> > at
> > org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.writeTo(JAXRSOutI
> > nterceptor.java:298)
> > at
> > org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(
> > JAXRSOutInterceptor.java:258)
> > at
> > org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(J
> > AXRSOutInterceptor.java:146)
> > at
> > org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAX
> > RSOutInterceptor.java:84)
> > at
> > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercepto
> > rChain.java:262)
> > at
> > org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(Outg
> > oingChainInterceptor.java:77)
> > at
> > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercepto
> > rChain.java:262)
> > at
> > org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitia
> > tionObserver.java:121)
> > at
> > org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractH
> > TTPDestination.java:236)
> > at
> > org.apache.openejb.server.cxf.rs.CxfRsHttpListener.onMessage(CxfRsHttp
> > Listener.java:70) at
> > org.apache.openejb.server.rest.RsServlet.service(RsServlet.java:53)
> > at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
> > at
> > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appli
> > cationFilterChain.java:305)
> > at
> > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFi
> > lterChain.java:210)
> > at
> > org.springframework.security.web.FilterChainProxy$VirtualFilterChain.d
> > oFilter(FilterChainProxy.java:330)
> > at
> > org.springframework.security.web.access.intercept.FilterSecurityInterc
> > eptor.invoke(FilterSecurityInterceptor.java:118)
> > at
> > org.springframework.security.web.access.intercept.FilterSecurityInterc
> > eptor.doFilter(FilterSecurityInterceptor.java:84)
> >
> >
> > What am I missing? Any help would be appreciated.
> >
> > Thanks.
> >
>

RE: issue with REST service

Posted by "Patel, Sanjay" <Sa...@nemours.org>.
See attached Project and war.

Deploy war to tome 1.5.1.

http://localhost:8080/test/secure/rest/one works

http://localhost:8080/test/secure/rest/two does not work



-----Original Message-----
From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com] 
Sent: Monday, March 11, 2013 2:57 PM
To: users@tomee.apache.org
Subject: Re: issue with REST service

Any way to reproduce it?

Not sure the generics help
Le 11 mars 2013 19:51, "Patel, Sanjay" <Sa...@nemours.org> a écrit :

> I have simple REST service. It returns list of entity. (e.g. Event)
>
>        @GET
>        @Path("/events")
>        @Produces({ "application/json" })
>        public List<Event> findEvents() {
>               return eventBean.findEvents().getList();
>        }
>
>
> It works fine if return type is List<Event>. If I change it to 
> EntityDTO (which contains list of Event and int property as shown 
> below), it gives below error.
>
> EntityDTO.java
> @XmlRootElement
> @XmlSeeAlso({ Event.class })
> public class EntityDTO<E> {
>
>        private List<E> list;
>        private int totalCount;
>
>        public List<E> getList() {
>               return list;
>        }
>
>        public void setList(List<E> list) {
>               this.list = list;
>        }
>
>        public int getTotalCount() {
>               return totalCount;
>        }
>
>        public void setTotalCount(int totalCount) {
>               this.totalCount = totalCount;
>        }
>
> }
>
> This is the error I get.
> WARNING: javax.ws.rs.WebApplicationException:
> java.lang.NullPointerException
> at
> org.apache.cxf.jaxrs.provider.json.JSONProvider.writeTo(JSONProvider.j
> ava:370)
> at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.writeTo(JAXRSOutI
> nterceptor.java:298)
> at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(
> JAXRSOutInterceptor.java:258)
> at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(J
> AXRSOutInterceptor.java:146)
> at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAX
> RSOutInterceptor.java:84)
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercepto
> rChain.java:262)
> at
> org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(Outg
> oingChainInterceptor.java:77)
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercepto
> rChain.java:262)
> at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitia
> tionObserver.java:121)
> at
> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractH
> TTPDestination.java:236)
> at
> org.apache.openejb.server.cxf.rs.CxfRsHttpListener.onMessage(CxfRsHttp
> Listener.java:70) at 
> org.apache.openejb.server.rest.RsServlet.service(RsServlet.java:53)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appli
> cationFilterChain.java:305)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFi
> lterChain.java:210)
> at
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.d
> oFilter(FilterChainProxy.java:330)
> at
> org.springframework.security.web.access.intercept.FilterSecurityInterc
> eptor.invoke(FilterSecurityInterceptor.java:118)
> at
> org.springframework.security.web.access.intercept.FilterSecurityInterc
> eptor.doFilter(FilterSecurityInterceptor.java:84)
>
>
> What am I missing? Any help would be appreciated.
>
> Thanks.
>

Re: issue with REST service

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Any way to reproduce it?

Not sure the generics help
Le 11 mars 2013 19:51, "Patel, Sanjay" <Sa...@nemours.org> a écrit :

> I have simple REST service. It returns list of entity. (e.g. Event)
>
>        @GET
>        @Path("/events")
>        @Produces({ "application/json" })
>        public List<Event> findEvents() {
>               return eventBean.findEvents().getList();
>        }
>
>
> It works fine if return type is List<Event>. If I change it to EntityDTO
> (which contains list of Event and int property as shown below), it gives
> below error.
>
> EntityDTO.java
> @XmlRootElement
> @XmlSeeAlso({ Event.class })
> public class EntityDTO<E> {
>
>        private List<E> list;
>        private int totalCount;
>
>        public List<E> getList() {
>               return list;
>        }
>
>        public void setList(List<E> list) {
>               this.list = list;
>        }
>
>        public int getTotalCount() {
>               return totalCount;
>        }
>
>        public void setTotalCount(int totalCount) {
>               this.totalCount = totalCount;
>        }
>
> }
>
> This is the error I get.
> WARNING: javax.ws.rs.WebApplicationException:
> java.lang.NullPointerException
> at
> org.apache.cxf.jaxrs.provider.json.JSONProvider.writeTo(JSONProvider.java:370)
> at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.writeTo(JAXRSOutInterceptor.java:298)
> at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:258)
> at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(JAXRSOutInterceptor.java:146)
> at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAXRSOutInterceptor.java:84)
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
> at
> org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:77)
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
> at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
> at
> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:236)
> at
> org.apache.openejb.server.cxf.rs.CxfRsHttpListener.onMessage(CxfRsHttpListener.java:70)
> at org.apache.openejb.server.rest.RsServlet.service(RsServlet.java:53)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> at
> org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
> at
> org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
> at
> org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
>
>
> What am I missing? Any help would be appreciated.
>
> Thanks.
>