I have following code to define Docket for swagger documentation for my rest API in a spring boot application:
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(regex("/((^|, )(api1|api2))+$/.*"))
.build().apiInfo(apiInfo());
My aim is to have endpoints url as /api1/... OR /api2/..., but it is not working.
What am I missing here?
I am having the below scenario while implementing JAX-RS web service.
Service A:
#Path("/customer/{customerId}")
public interface ICustomerDataUsageService{
#GET
#Path("/datausage")
public Response getCustomerDataUsage();
//other methods...
}
Service B:
#Path("/")
public interface IHelpDeskService{
#GET
#Path("/customer/{customerId}")
public Response getCustomer();
//other methods...
}
After deployment only the Service A is working (Its registered after the Service B). For the second one I am getting HTTP 404 error.
Unfortunately we cannot change the interfaces since its provided by another entity. We are only having control of the implementation classes for these.
I am using Jersey-2.22.
Is there any way out to have both these services working without changing the interfaces.
Thanks in Advance!
This was indeed a bug and was fixed by the API team by correcting the API.
The fix looks as below:
Service A:
#Path("/customer")
public interface ICustomerDataUsageService{
#GET
#Path("/{customerId}/datausage")
public Response getCustomerDataUsage();
//other methods also got /{customerId} added in path
}
Service B:
#Path("/")
public interface IHelpDeskService{
#GET
#Path("/customer/{customerId}")
public Response getCustomer();
//other methods...
}
I am pretty new in WSO2 EI and I am trying to develop a custom message processor that I have to use into the ESB flow.
At this time I have only exteded the SamplingProcessor class, this one: https://github.com/wso2/wso2-synapse/blob/master/modules/core/src/main/java/org/apache/synapse/message/processor/impl/sampler/SamplingProcessor.java
into a Maven project.
I am trying with a minimalistic scenario where I only override the setParameters() method inserting a simple log, this is my code:
package com.mycompany.toolkit.messageprocessor;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.message.processor.impl.ScheduledMessageProcessor;
import org.apache.synapse.message.processor.impl.sampler.SamplingProcessor;
public abstract class SamplingProcessorHeaderRateLimitation extends SamplingProcessor {
private static final Log logger = LogFactory.getLog(ScheduledMessageProcessor.class.getName());
#Override
public void setParameters(Map<String, Object> parameters) {
logger.info("setParameters() START");
// TODO Auto-generated method stub
super.setParameters(parameters);
logger.info("setParameters() END");
}
}
I create the jar file containing the compiled version of thi class using Maven.
My doubt is: where have I to put the generated SamplingProcessorHeaderRateLimitation-0.0.1-SNAPSHOT.jar file into my WSO2 EI 6.0.0 installation?
Place the JAR file in the lib directory of WSO2 EI.
<EI_HOME>/lib
Another Option:
The artifacts can also be updoaded through the admin console. Refer the following link
https://docs.wso2.com/display/EI600/Uploading+Artifacts
You should put it in wso2ei-6.0.0\lib. Then, you should be able to reference it in your XML as com.mycompany.toolkit.messageprocessor.SamplingProcessorHeaderRateLimitation.
However, I believe you cannot make it an abstract class as doing so will prevent WSO2 from instantiating it. So you should remove the 'abstract' keyword from your class.
I am working on an application that uses rest webservices where a uri has been invoked from a .js file.
var invokeWS = "/resource/domain/program/tasks";
jQuery.getJSON(invokeWS ,data)
While looking at all the jar's I found out that the class corresponding to program is present in a package "com.company.project.webapps.util.rest.service" as below
package com.company.project.webapps.util.rest.service;
#Path("/program")
public class Program extends RS
{
#Path("/tasks")
#GET
public get...()
{
}
}
I do not see any mapping url in web.xml but the the webservice call made through .js would some how pick the correct path and invokes the service.
Can you please let me know if this can be achieved in a any other way as I do not see any entries in web.xml of the applicaiton.
Thanks
Awanish
I'm trying to deploy a weeb-service, generated from an EJB into glassfish, but, for some reason, my web service is never visible in Glassfish. The web-service is defined from an EJB interface as follows :
#Remote
#WebService
public interface TemplateEJBRemote {
public abstract #WebResult(name="found") Template find(#WebParam(name="templateId", mode=Mode.IN) Long id);
}
This EJB interface has a Local implementation :
#Local
#Stateless
public class TemplateEJBImpl implements TemplateEJBRemote {
#PersistenceContext(unitName=NamingConstants.PERSISTENCE_CONTEXT)
private EntityManager entityManager;
#Override
public Template find(Long id) {
return entityManager.find(Template.class, id);
}
}
And they're both defined in a war module, which an ear module sends to Glassfish.
Those module produce correctly looking artefacts, including an ear with the correct application.xml :
<application xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd"
version="6">
<description>This is the project that will deliver a full usable
EAR including all delivered components. All the project
dependencies here will be included in this</description>
<display-name>my-ear</display-name>
<module>
<web>
<web-uri>my-war-0.0.1-SNAPSHOT.war</web-uri>
<context-root>/my-war</context-root>
</web>
</module>
</application>
When deployed in Glassfish, all infos I can get is
E:\java-ext\glassfish3>bin\asadmin list-components --subcomponents
my-ear-0.0.1-SNAPSHOT <ear, ejb, webservices, web>
my-war-0.0.1-SNAPSHOT.war <WebModule>
Command list-components executed successfully.
it seems to me that, were my web-service really deployed, it would appear below my war submodule, no ?
If not, what can I do to ensure my web-service is correctly defined and deployed ?
[UPDATE 1] In order to give some more informations, i created a smaller web-service endpoint, the infamous Hello world, coded as such :
#WebService
public class Hello {
public String hello(String world) {
return "Salut, "+world+" !";
}
}
using this definition, it is a perfect Glassfiosh web-service :
But, as soon as I make it a bean, as such :
#WebService
#Stateless
public class Hello {
public String hello(String world) {
return "Salut, "+world+" !";
}
}
Things become a little different :
However, as log files told me, HelloService is still present :
[#|2011-03-31T17:55:55.059+0200|INFO|glassfish3.1|javax.enterprise.webservices.org.glassfish.webservices|_ThreadID=339;_ThreadName=Thread-1;|WS00019: EJB Endpoint deployed
autocat-ear-0.0.1-SNAPSHOT listening at address at http://perigee-567125f:8080/HelloService/Hello|#]
I tried to apply the same logic to my initial bean, but with an infortunate result (a 404 error, of course). So I guess there is another issue hidden beneath. But which on ? I can't have any idea.
[UPDATE 2] To make things clear, the EJb I try to deploy is not visible as a web-service in Glassfish console, and its URL can't be pinged by any web client.
I'm looking at my copy of "EJB 3 In Action" and it says:
"A careful look at the code reveals that the #WebService endpoint interface looks similar to the remote interface. You might be tempted to mark the same interface as both a web service and a remote interface, like this:
#WebService
#Remote
public interface PlaceBid {
public Long addBid(String bidderID, Long itemID, Double dibPrice);
}
Unfortunately, although some vendors allow this as an extension, this is not part of the specification, and code that uses this particular attribute combination won't be portable."
You're going to have to remove the #Remote
You need to do some more troubleshooting. Have a look at the logs in glassfish3/glassfish/domains/domain1/logs. Or if you have standalone or cluster nodes look in glassfish3/glassfish/nodes/<nodename>/<instancename>/logs.
Also, log into the admin page "http://localhost:4848", default username is admin, default password is adminadmin. On the left there is a tree, find Applications, then your Ear should be listed there. Click it and you'll see a list of modules and components. If your web service is listed there you can click View Endpoint. There is a built-in tester, and you can get the wsdl URL there too.
update 1:
You don't have any #WebMethod(operationName = "blah) on your hello(). Maybe if there are no WebMethods GlassFish decides it's not worth making your web service available.
update 2: More complete example of how my web service is put together inside the ear. I'm pretty sure you don't have to separate the #WebService and #Stateless classes, but I like it that way because it feels cleaner and seems to separate the concerns.
war:
SomePojo.java:
#WebService(targetNamespace="blah.com")
public class SomePojo {
#EJB
private BlahSessionLocal blahSession;
#WebMethod(operationName = "hello")
public String hello(#WebParam(name = "user_id") Integer userId) throws Exception {
return blahSession.hello(userId);
}
}
ejb jar:
BlahSessionLocal.java
#Local
public interface BlahSessionLocal {
String hello(Integer userId);
}
BlahSessionBean.java
#Stateless(mappedName = "BlahSession")
public class BlahSessionBean implements BlahSessionLocal {
public String hello(Integer userId) {
return "hello user " + userId);
}
}