Simple JAX-RS service like:
@Path("/MyRESTApplication")
@SessionScoped
public class HelloWorldResource implements Serializable {
@Inject
private LoggedUser loggedUser;
@Path( "/nome/
{nome}
" )
@GET
@Produces( "text/plain" )
public String sayHello( @PathParam( "nome" ) String nome )
{
loggedUser.setNome(nome);
return "Hello " + nome;
}
@Path( "/remove" )
@GET
@Produces( "text/plain" )
public String remove()
{
loggedUser.destroy();
return "destruido";
}
}
and a simple SFSB:
@LocalBean
@Stateful
@StatefulTimeout( unit = TimeUnit.MINUTES, value = 2 )
public class LoggedUser implements Serializable {
private static final long serialVersionUID = 1L;
private String nome;
public String getNome()
{
return nome;
}
public void setNome(String nome)
{
this.nome = nome;
}
@PostConstruct
public void init()
{
System.out.println("Construido instancia de " + getClass().getSimpleName());
}
@Remove
public void destroy()
{
System.out.println("Destruindo instancia de " + getClass().getSimpleName());
}
}
so, when i called the service remove from my rest service i got the error.
some details that i got from weld 1.1.4 source:
in the class: EnterpriseBeanProxyMethodHandler in line 94
if ("destroy".equals(method.getName()) && Marker.isMarker(0, method, args)) {
we can see that my method is named as "destroy" and the next condition will be checked, then inside the method isMarker
the first condition is method.getParameterTypes().length >= position and my method.getParameterTypes().length is 0 too,
so when next condition is checked method.getParameterTypes()[position].equals(Marker.class) && INSTANCE.equals(args[position])
im getting the exception.