RestEasy - Socorro!

4 respostas
Z

Pessoal , preciso tornar minhas classes acessíveis por Rest . Mas não estou conseguindo fazer funcionar .
O deploy funciona ok . Mas quando tento acessar algum metodo via get gera exception ( Descrita abaixo )
Eu acho que o problema está no classpath ( pra variar ) . Quais jars da instalação eu posso retirar para pode usar o RestEasy ? ( Lista de jars abaixo )

Meu setup é : JVM 1.6 , JBOSS 4.23 + Eclipse + WTP .
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Servlet.init() for servlet Resteasy threw exception
	org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
	org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
	java.lang.Thread.run(Unknown Source)
root cause

java.lang.RuntimeException: Unable to instantiate MessageBodyReader
	org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:762)
	org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:744)
	org.jboss.resteasy.spi.ResteasyDeployment.registerProvider(ResteasyDeployment.java:371)
	org.jboss.resteasy.spi.ResteasyDeployment.registration(ResteasyDeployment.java:249)
	org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:185)
	org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:68)
	org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36)
	org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
	org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
	java.lang.Thread.run(Unknown Source)
root cause

java.lang.RuntimeException: Illegal to inject a message body into a singleton into public org.codehaus.jackson.jaxrs.JacksonJsonProvider(org.codehaus.jackson.jaxrs.Annotations[])
	org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:157)
	org.jboss.resteasy.core.ConstructorInjectorImpl.injectableArguments(ConstructorInjectorImpl.java:63)
	org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:129)
	org.jboss.resteasy.spi.ResteasyProviderFactory.getProviderInstance(ResteasyProviderFactory.java:1036)
	org.jboss.resteasy.spi.ResteasyProviderFactory.addMessageBodyReader(ResteasyProviderFactory.java:450)
	org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:758)
	org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:744)
	org.jboss.resteasy.spi.ResteasyDeployment.registerProvider(ResteasyDeployment.java:371)
	org.jboss.resteasy.spi.ResteasyDeployment.registration(ResteasyDeployment.java:249)
	org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:185)
	org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:68)
	org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36)
	org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
	org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
	java.lang.Thread.run(Unknown Source)
note The full stack trace of the root cause is available in the JBossWeb/2.0.1.GA logs.

Lista de jars do Resteasy :
atachado :

4 Respostas

R

Zaperjava,

Pelo log que você passou parace ser algum problema nas anotações colocadas no seu recurso.
Poste o mesmo aqui para melhor averiguar.

[]`s

Z

rafachies:
Zaperjava,

Pelo log que você passou parace ser algum problema nas anotações colocadas no seu recurso.
Poste o mesmo aqui para melhor averiguar.

[]`s

Olá Obrigado pela resposta .
Segue abaixo as classes .

package net.test

import java.util.ArrayList;
import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import net.test.entity.Cities;
@Path("/test")
public class Cidades {

			@GET
			@Path("/cidades")
			@Produces(MediaType.APPLICATION_XML)
			public Cities getString(){
				Cities c1= new Cities();
				c1.setName("z");
				return c1;
				
			}
	
	
}
package net.test.entity;

// Generated Jul 27, 2010 5:37:33 AM by Hibernate Tools 3.3.0.GA

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * Cities generated by hbm2java
 */
@Entity
@XmlRootElement
@Table(name = "cities", schema = "public")
public class Cities implements java.io.Serializable {

	private int id;
	private String name;
	private Date createdAt;
	private Date updatedAt;
	private String state;
	private String country;
	public Cities() {
	}

	public Cities(int id) {
		this.id = id;
	}

	public Cities(int id, String name, Date createdAt, Date updatedAt,
			String state, String country) {
		this.id = id;
		this.name = name;
		this.createdAt = createdAt;
		this.updatedAt = updatedAt;
		this.state = state;
		this.country = country;

	}

	@Id
	@Column(name = "id", unique = true, nullable = false)
	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Column(name = "name", length = 75)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "created_at", length = 29)
	public Date getCreatedAt() {
		return this.createdAt;
	}

	public void setCreatedAt(Date createdAt) {
		this.createdAt = createdAt;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "updated_at", length = 29)
	public Date getUpdatedAt() {
		return this.updatedAt;
	}

	public void setUpdatedAt(Date updatedAt) {
		this.updatedAt = updatedAt;
	}

	@Column(name = "state", length = 30)
	public String getState() {
		return this.state;
	}

	public void setState(String state) {
		this.state = state;
	}

	@Column(name = "country", length = 30)
	public String getCountry() {
		return this.country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	

}
R

É cara,

Realmente não parece ter haver nada errado com a declaração do recurso. O estranho é estar estourando exception no momento de criar o reader do Consume, sendo que voce nem declarou o mesmo. Olhando o source do resteasy, era pra ele adicionar um mime desse jeito “messageBodyReaders.add(new MediaType(”", ""), key)".
Zapenado pela net encontrei alguns tópicos parecidos, alguns falando que esse problema só era atingido no windows. Você está usando windows ?
Segue abaixo a thread do fórum que achei:

http://groups.google.com/group/okapi-devel/browse_thread/thread/38ad8447fa250cad?pli=1

Vo continuar dando uma olhada, e se achar algo novo lhe comunico.

[]'s

R

Cara,

Faca um teste. Retire todas as libs do resteasy que voce colocou. Deixe apenas as realmente nescessarias: resteasy-jaxrs-2.0.0.GA.jar, slf4.jar, jaxrs-api-2.0.0.GA.jar, scannotation-1.0.2.jar, resteasy-jaxb-provider-2.0.0.GA.jar.

Acredito que o problema pode estar ocorrendo porque como voce tem a lib do provider do json (reasteasy-jackson-provider), ele tenta em algum momento registrar o mesmo.

Faca este teste e de um feedback aki.

[]`s

Criado 28 de julho de 2010
Ultima resposta 29 de jul. de 2010
Respostas 4
Participantes 2