0
votes

the source of "uts.dae.model.rest.Calculadora" class

 package uts.dae.model.rest;

 import javax.ejb.Stateless;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.QueryParam;

  /**
  *
  * @author x2010s
  */

  @Stateless

  @Path("/calculadora")


  public class Calculadora {


  @GET 
  public String Suma(@QueryParam("num1") double num1,@QueryParam("num2") double num2)    {
  return Double.toString($Suma(num1,num2));
 }
  @Path("calculadora/suma")
    double $Suma(double num1,double num2) {
    double resultado;
    resultado = num1 + num2;
    return resultado; 
 }

@GET 
public String Resta(@QueryParam("num1") double num1,@QueryParam("num2") double num2)    {
return Double.toString($Resta(num1,num2));
 }
 @Path("calculadora/resta")
    double $Resta(@QueryParam("num1") double num1,@QueryParam("num2") double num2) {
    double resultado;
    resultado = num1 - num2;
    return resultado;

 }

 @GET    
 public String Multiplicacion(@QueryParam("num1") double num1,@QueryParam("num2") double num2)    {
 return Double.toString($Multiplicacion(num1,num2));
  } 
 @Path("calculadora/multiplicacion")
   double $Multiplicacion(double num1,double num2) {
    double resultado;
    resultado = num1 * num2;
    return resultado;

}  



 @GET 
 public String Division(@QueryParam("num1") double num1,@QueryParam("num2") double num2)    {
 return Double.toString($Division(num1,num2));
 }
 @Path("calculadora/Division")
  double $Division(double num1,double num2) {
    double resultado;
    resultado = num1 / num2;
    return resultado;

}


@GET 
public String Modulo(@QueryParam("num1") double num1,@QueryParam("num2") double num2)    {
 return Double.toString($Modulo(num1,num2));
 }
@Path("calculadora/Modulo")
double $Modulo(@QueryParam("num1") double num1,@QueryParam("num2") double num2) {
    double resultado;
    resultado = num1 % num2;
    return resultado;

}
}

when I deploy, the following error occurs, if they have different url:

[[WARNING] A sub-resource model, double uts.dae.model.rest.Calculadora.$Suma(double,double), MUST be public scoped otherwise the method is ignored; source='class uts.dae.model.rest.Calculadora', [WARNING] A sub-resource model, double uts.dae.model.rest.Calculadora.$Multiplicacion(double,double), MUST be public scoped otherwise the method is ignored; source='class uts.dae.model.rest.Calculadora', [WARNING] A sub-resource model, double uts.dae.model.rest.Calculadora.$Resta(double,double), MUST be public scoped otherwise the method is ignored; source='class uts.dae.model.rest.Calculadora', [WARNING] A sub-resource model, double uts.dae.model.rest.Calculadora.$Modulo(double,double), MUST be public scoped otherwise the method is ignored; source='class uts.dae.model.rest.Calculadora', [WARNING] A sub-resource model, double uts.dae.model.rest.Calculadora.$Division(double,double), MUST be public scoped otherwise the method is ignored; source='class uts.dae.model.rest.Calculadora', [FATAL] A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by"@Consumes" and "@Produces" annotations at Java methods public java.lang.String uts.dae.model.rest.Calculadora.Suma(double,double) and public java.lang.String uts.dae.model.rest.Calculadora.Resta(double,double) at matching regular expression /calculadora. These two methods produces and consumes exactly the same mime-types and therefore their invocation as a resource methods will always fail.; source='org.glassfish.jersey.server.model.RuntimeResource@1f7972f', [FATAL] A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by"@Consumes" and "@Produces" annotations at Java methods public java.lang.String uts.dae.model.rest.Calculadora.Suma(double,double) and public java.lang.String uts.dae.model.rest.Calculadora.Multiplicacion(double,double) at matching regular expression /calculadora. These two methods produces and consumes exactly the same mime-types and therefore their invocation as a resource methods will always fail.; source='org.glassfish.jersey.server.model.RuntimeResource@1f7972f', [FATAL] A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by"@Consumes" and "@Produces" annotations at Java methods public java.lang.String uts.dae.model.rest.Calculadora.Suma(double,double) and public java.lang.String uts.dae.model.rest.Calculadora.Division(double,double) at matching regular expression /calculadora. These two methods produces and consumes exactly the same mime-types and therefore their invocation as a resource methods will always fail.; source='org.glassfish.jersey.server.model.RuntimeResource@1f7972f', [FATAL] A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by"@Consumes" and "@Produces" annotations at Java methods public java.lang.String uts.dae.model.rest.Calculadora.Suma(double,double) and public java.lang.String uts.dae.model.rest.Calculadora.Modulo(double,double) at matching regular expression /calculadora. These two methods produces and consumes exactly the same mime-types and therefore their invocation as a resource methods will always fail.; source='org.glassfish.jersey.server.model.RuntimeResource@1f7972f', [FATAL] A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by"@Consumes" and "@Produces" annotations at Java methods public java.lang.String uts.dae.model.rest.Calculadora.Resta(double,double) and public java.lang.String uts.dae.model.rest.Calculadora.Multiplicacion(double,double) at matching regular expression /calculadora. These two methods produces and consumes exactly the same mime-types and therefore their invocation as a resource methods will always fail.; source='org.glassfish.jersey.server.model.RuntimeResource@1f7972f', [FATAL] A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by"@Consumes" and "@Produces" annotations at Java methods public java.lang.String uts.dae.model.rest.Calculadora.Resta(double,double) and public java.lang.String uts.dae.model.rest.Calculadora.Division(double,double) at matching regular expression /calculadora. These two methods produces and consumes exactly the same mime-types and therefore their invocation as a resource methods will always fail.; source='org.glassfish.jersey.server.model.RuntimeResource@1f7972f', [FATAL] A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by"@Consumes" and "@Produces" annotations at Java methods public java.lang.String uts.dae.model.rest.Calculadora.Resta(double,double) and public java.lang.String uts.dae.model.rest.Calculadora.Modulo(double,double) at matching regular expression /calculadora. These two methods produces and consumes exactly the same mime-types and therefore their invocation as a resource methods will always fail.; source='org.glassfish.jersey.server.model.RuntimeResource@1f7972f', [FATAL] A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by"@Consumes" and "@Produces" annotations at Java methods public java.lang.String uts.dae.model.rest.Calculadora.Multiplicacion(double,double) and public java.lang.String uts.dae.model.rest.Calculadora.Division(double,double) at matching regular expression /calculadora. These two methods produces and consumes exactly the same mime-types and therefore their invocation as a resource methods will always fail.; source='org.glassfish.jersey.server.model.RuntimeResource@1f7972f', [FATAL] A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by"@Consumes" and "@Produces" annotations at Java methods public java.lang.String uts.dae.model.rest.Calculadora.Multiplicacion(double,double) and public java.lang.String uts.dae.model.rest.Calculadora.Modulo(double,double) at matching regular expression /calculadora. These two methods produces and consumes exactly the same mime-types and therefore their invocation as a resource methods will always fail.; source='org.glassfish.jersey.server.model.RuntimeResource@1f7972f', [FATAL] A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by"@Consumes" and "@Produces" annotations at Java methods public java.lang.String uts.dae.model.rest.Calculadora.Division(double,double) and public java.lang.String uts.dae.model.rest.Calculadora.Modulo(double,double) at matching regular expression /calculadora. These two methods produces and consumes exactly the same mime-types and therefore their invocation as a resource methods will always fail.; source='org.glassfish.jersey.server.model.RuntimeResource@1f7972f']

1
please post the source of "uts.dae.model.rest.Calculadora" classali4j
the code that I just published is from uts.dae.model.rest.Calculadora.javaIves Rodriguez

1 Answers

0
votes

move all @Path annotations from methods having '$' as the prefix to those public methods, something like this:

@GET
@Path("calculadora/Modulo")
public String Modulo(@QueryParam("num1") double num1,@QueryParam("num2") double num2)    {
    return Double.toString($Modulo(num1,num2));
}

double $Modulo(@QueryParam("num1") double num1,@QueryParam("num2") double num2) {
    double resultado;
    resultado = num1 % num2;
    return resultado;
}

also take a look at this SO post.

The problem is that, since all of the public methods are resource methods which are annotated with @GET, they do not have @Path annotation and their list of arguments are the same, if you send a http GET request to "/calculadora" url there is a ambiguouty that which one the methods should be called, so moving @Path annotations to public methods will resolve the problem.