Cant locate swagger.json on java + embedded jetty + httpservlet + swagger integration

675 views
Skip to first unread message

janet vanderpuye

unread,
Dec 22, 2016, 1:31:03 PM12/22/16
to Swagger

I recently followed this blog to integrate swagger in my embedded jetty project but after running, I'm not able to access the swagger.json file on any path combination. Accessing the servlets for the resources work with no error but I get the following errors when I try to get the swagger.json file

http://host:7000/swagger-core  ===> HTTP ERROR 405
http://host:7000/swagger-core/swagger.json ===> HTTP ERROR 404
http://host:7000/user/swagger.json ===> HTTP ProfileServlet response, not swagger.json
http://host:7000/user ===> HTTP ProfileServlet response, not swagger.json
http://host:7000/swagger.json ===> HTTP ERROR 404
http://host:7000/api/swagger.json ===> HTTP ERROR 404
http://host:7000/ ===> Static swagger sample page (Pet store), not swagger.json

Main.java

 public static void main(String[] args) throws Exception {
   Server server = initializeApi(properties);
    server.start();
    logger.info("Api resource service started");
    server.join();
 }

 private static Server initializeApi(Properties properties) {
    logger.info("Initializing user profile server...");
    new UserDao();
    Server server = new Server(Integer.parseInt(properties.getProperty(Config.JETTY_SERVICE_PORT)));
    ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
    servletContextHandler.setContextPath("/");
    server.setHandler(servletContextHandler);
    //Setup APIs

    ServletHolder apiservlet = servletContextHandler.addServlet(ProfileServlet.class, "/user/*");
    apiservlet.setInitOrder(1);
    apiservlet.setInitParameter("com.sun.jersey.config.property.packages", "com.api.resources;io.swagger.jaxrs.json;io.swagger.jaxrs.listing");
    logger.info("User profile server initialized.");

        // Setup Swagger servlet
        ServletHolder swaggerServlet = servletContextHandler.addServlet(DefaultJaxrsConfig.class, "/swagger-core");
        swaggerServlet.setInitOrder(2);
        swaggerServlet.setInitParameter("api.version", "1.0.0");

        // Setup Swagger-UI static resources
        String resourceBasePath = Main.class.getResource("/webapp").toExternalForm();
        servletContextHandler.setWelcomeFiles(new String[] {"index.html"});
        servletContextHandler.setResourceBase(resourceBasePath);
        servletContextHandler.addServlet(new ServletHolder(new DefaultServlet()), "/*");

        return server;
    }
}

ProfileServlet.java

@SwaggerDefinition(


info = @Info(
           title = "User Profile Servlet",
           version = "1.0.0",
           description = "Servlet that handles basic CRUD operations to the user profile data source",
           contact = @Contact(name = "XYZ", email = "XYZ", url = "XYZ"),
           termsOfService = "XYZ",
           license = @License(name = "XYZ", url = "XYZ")
   ),
        basePath = "/",
        consumes = {"application/json"},
        produces = {"application/json"},
        schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS},
        tags = {@Tag(name = "users", description = "CRUD operations on user datatype")}
)
@Api(value = "/user", description = "performs CRUD operations on a user profile")
public class ProfileServlet extends HttpServlet {
    Logger logger = Logger.getLogger(ProfileServlet.class.getSimpleName());

    public ProfileServlet(){

    }

    @ApiOperation(httpMethod = "GET", value = "Returns a list of the user profile datatype", notes = "", response = UserDatatype.class, nickname = "getUser", tags = ("User"))
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Succssful retrieval of user profiles", response = UserDatatype.class),
            @ApiResponse(code = 500, message = "Internal server error")
    })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "profile id", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "firstname", value = "First name of user", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "lastname", value = "Last name of user", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "phone", value = "phone number of user", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "signup", value = "Sign up date of user, in dd-MM-yyyy forma", required = false, dataType = "java.sql.Date", paramType = "query")
    })
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        RpcLogTemplate logTemplate = new RpcLogTemplate(req.getRemoteHost(),req.getParameter("client"), req.getParameter("clientapp"), Config.localhost, Config.SERVICE_INSTANCE, Config.SERVICE_APP, req.getParameterMap(), new Date().getTime() );
        logger.debug("Received request: GET");
        handleGet(req, resp, logTemplate);
        logTemplate.setResponseTimestamp(new Date().getTime());
        //LoggerService.INSTANCE.addLog(logTemplate);
    }

    private void handleGet(HttpServletRequest request, HttpServletResponse response, RpcLogTemplate logTemplate) throws IOException {
        Gson gson = new Gson();
        String param = null;
        param = request.getParameter("id");
        if(param!= null){
            logger.info("Query by ID received. All other params would be ignored");
            UserDatatype userDatatype = UserDao.INSTANCE.findById(param);
            if(userDatatype == null){
                response.setStatus(HttpServletResponse.SC_OK);
                logger.info("Null object returned");
                return;
            }else{
                response.setStatus(HttpServletResponse.SC_OK);
                PrintWriter printWriter = response.getWriter();
                printWriter.write(gson.toJson(userDatatype, UserDatatype.class));
                printWriter.flush();
                printWriter.close();
            }
        }else{
            Map<String, String> queryString = new HashMap<>();
            //TODO: optimize this
            param = request.getParameter("firstname");
            if(param != null)
                queryString.put("firstname", param);
            param = request.getParameter("lastname");
            if(param != null)
                queryString.put("lastname", param);
            param = request.getParameter("phone");
            if(param != null)
                queryString.put("phone", param);
            param = request.getParameter("signup");
            if(param != null)
                queryString.put("signup", param);
            UserDatatype[] userDatatypes = UserDao.INSTANCE.findByParams(queryString);
            if(userDatatypes == null){
                response.setStatus(HttpServletResponse.SC_OK);
                logger.info("Null object returned");
                return;
            }else{
                response.setStatus(HttpServletResponse.SC_OK);
                PrintWriter printWriter = response.getWriter();
                printWriter.write(gson.toJson(userDatatypes, UserDatatype[].class));
                printWriter.flush();
                printWriter.close();
            }
        }
    }

 }

Bootstrap.java

public class Bootstrap  extends HttpServlet {
@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);

    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setVersion("1.0.2");
    beanConfig.setSchemes(new String[]{"http"});
    beanConfig.setHost("localhost:7000");
    beanConfig.setBasePath("/");
    beanConfig.setResourcePackage("io.swagger.resources");
    beanConfig.setScan(true);
    beanConfig.setPrettyPrint(true);
}

}

All help appreciated.

janet vanderpuye

unread,
Dec 22, 2016, 1:50:29 PM12/22/16
to Swagger
Quick update. After modifying the initializeAPI method to the original Servlet class in the blog(see below),  I was able to get some response from the swagger-ui on http://host:7000/api/swagger.json. But I it seems like swagger wasnt able to parse my servlet annotations
http://host:7000/api/swagger.json ===> {"swagger":"2.0","info":{"version":"1.0.0","title":""}}

private static Server initializeApi(Properties properties) {
logger.info("Initializing user profile server...");
new UserDao();
Server server = new Server(Integer.parseInt(properties.getProperty(Config.JETTY_SERVICE_PORT)));
ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
servletContextHandler.setContextPath("/");
server.setHandler(servletContextHandler);
//Setup APIs
    ServletHolder apiservlet = servletContextHandler.addServlet(ServletContainer.class, "/api/*");

apiservlet.setInitOrder(1);
apiservlet.setInitParameter("com.sun.jersey.config.property.packages", "com.api.resources;io.swagger.jaxrs.json;io.swagger.jaxrs.listing");

apiservlet = servletContextHandler.addServlet(ProfileServlet.class, "/user/*");
    //apiservlet.setInitOrder(1);

tony tam

unread,
Dec 22, 2016, 1:52:18 PM12/22/16
to swagger-sw...@googlegroups.com
Sounds like the issue then is how it’s scanning your code.  Put your API package here:

    apiservlet.setInitParameter("com.sun.jersey.config.property.packages", "com.api.resources;io.swagger.jaxrs.json;io.swagger.jaxrs.listing");
so they can be scanned.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

janet vanderpuye

unread,
Dec 22, 2016, 2:10:43 PM12/22/16
to Swagger
So for my servlets, I just tried:

apiservlet = servletContextHandler.addServlet(ProfileServlet.class, "/user/*");
apiservlet.setInitOrder(3);
apiservlet.setInitParameter("com.sun.jersey.config.property.packages", "com.coreservices.servlets;package com.coreservices.datatypes");

and  

apiservlet = servletContextHandler.addServlet(ProfileServlet.class, "/user/*");
apiservlet.setInitOrder(3);
apiservlet.setInitParameter("com.sun.jersey.config.property.packages", "com.api.resources;io.swagger.jaxrs.json;io.swagger.jaxrs.listing;com.coreservices.servlets;package com.coreservices.datatypes");

I am still getting the default swagger response 
{"swagger":"2.0","info":{"version":"1.0.0","title":""}}
Am I missing any annotation or configuration in the files?
Secondly to access the swagger ui annotation for my custom servlet "ProfileServlet.class", do I use the same url as "http://host:7000/api/swagger.json"? 

Really appreciate the quick feedback on this
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

Ron Ratovsky

unread,
Dec 22, 2016, 2:34:08 PM12/22/16
to swagger-sw...@googlegroups.com

Which version of Jersey do you use?

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

 

--

You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

janet vanderpuye

unread,
Dec 22, 2016, 2:37:43 PM12/22/16
to Swagger
In my pom file, I have 1.19.1

<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.10</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jaxrs</artifactId>
<version>1.5.10</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>1.19.1</version>
</dependency>

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

Ron Ratovsky

unread,
Dec 22, 2016, 3:25:14 PM12/22/16
to swagger-sw...@googlegroups.com

Okay, so it should work.

 

Is your API itself accessible? Can you make any of the API calls successfully?

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

janet vanderpuye

unread,
Dec 22, 2016, 3:28:38 PM12/22/16
to Swagger
Yeah the Api calls work. I can make calls to my servlets without error. Its just the swagger documentation is not generating any of my annotations.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

Ron Ratovsky

unread,
Dec 22, 2016, 3:47:24 PM12/22/16
to swagger-sw...@googlegroups.com

Looking back, you have a Bootstrap class with the line

    beanConfig.setResourcePackage("io.swagger.resources");

 

Change “io.swagger.resources” to the package(s) of your resources and that should allow it to pick them up and scan them.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

janet vanderpuye

unread,
Dec 22, 2016, 4:03:57 PM12/22/16
to Swagger
Thanks Ron. I tried that and no success. The new code for the bootstrap class was 
beanConfig.setResourcePackage("com.api.resources");
beanConfig.setResourcePackage("io.swagger.jaxrs.json");
beanConfig.setResourcePackage("io.swagger.jaxrs.listing");
beanConfig.setResourcePackage("com.gh.cive.coreservices.servlets");
beanConfig.setResourcePackage("com.gh.cive.coreservices.datatypes");
beanConfig.setScan(true);
beanConfig.setPrettyPrint(true);

Looking at the logs, it shows that at least it picked up my servlet package for scanning. Could it be an error in the way I declared the annotations? Log output is:
308 [main] INFO Main  - User profile server initialized.
Dec 22, 2016 3:57:50 PM com.sun.jersey.api.core.PackagesResourceConfig init
INFO: Scanning for root resource and provider classes in the packages:
  com.api.resources
  io.swagger.jaxrs.json
  io.swagger.jaxrs.listing
  com.coreservices.servlets
  com.coreservices.datatypes
Dec 22, 2016 3:57:50 PM com.sun.jersey.api.core.ScanningResourceConfig logClasses
INFO: Root resource classes found:
  class io.swagger.jaxrs.listing.AcceptHeaderApiListingResource
  class io.swagger.jaxrs.listing.ApiListingResource
Dec 22, 2016 3:57:50 PM com.sun.jersey.api.core.ScanningResourceConfig logClasses
INFO: Provider classes found:
  class io.swagger.jaxrs.listing.SwaggerSerializers
Dec 22, 2016 3:57:50 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.19.1 03/11/2016 02:08 PM'
2277 [main] INFO Main  - user profile service started

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

janet vanderpuye

unread,
Dec 22, 2016, 4:05:44 PM12/22/16
to Swagger
Sorry, corrected package. Same result though

beanConfig.setResourcePackage("com.api.resources");
beanConfig.setResourcePackage("io.swagger.jaxrs.json");
beanConfig.setResourcePackage("io.swagger.jaxrs.listing");
beanConfig.setResourcePackage("com.coreservices.servlets");
beanConfig.setResourcePackage("com.coreservices.datatypes");
beanConfig.setScan(true);
beanConfig.setPrettyPrint(true);
<pre style="backg

Ron Ratovsky

unread,
Dec 22, 2016, 4:10:02 PM12/22/16
to swagger-sw...@googlegroups.com

Try keeping only

beanConfig.setResourcePackage("com.coreservices.servlets");

--

You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

janet vanderpuye

unread,
Dec 22, 2016, 4:53:01 PM12/22/16
to Swagger
WHOOHOO! We have success! Thank you, guys. You are amazing. I had spent the better part of 16 hours on this before I admitted defeat. 

That aside, i have a couple of questions
  1. Does the beanConfig.setResourcePackage("package name") take in only one package? If so, do I have to move all swagger resources into the package?What happens to my @ApiModel resource object which I have defined in another package? This is essentially a datatype so traditionally it is held in a different package from the servlets.
  2. I noticed that the documentation skipped  the annotations i had for the HttpServlet.doGet() method. Is this normal? I was expecting it to list all functions and types that i had specified with the @ApiOperation, @ApiResponse, etc annotation. This is my current swagger.json output:
    {
     
    "swagger" : "2.0",
     
    "info" : {
       
    "description" : "Servlet that handles basic CRUD operations to the user profile data source",
       
    "version" : "1.0.2",
       
    "title" : "User Profile Servlet",
       
    "termsOfService" : "XYZ",
       
    "contact" : {
         
    "name" : "XYZ",
         
    "url" : "XYZ",
         
    "email" : "XYZ"
       
    },
       
    "license" : {
         
    "name" : "XYZ",
         
    "url" : "XYZ"
       
    }
     
    },
     
    "host" : "localhost:7000",
     
    "basePath" : "/",
     
    "tags" : [ {
       
    "name" : "users",
       
    "description" : "CRUD operations on user datatype"
     
    } ],
     
    "schemes" : [ "http", "https" ],
     
    "consumes" : [ "application/json" ],
     
    "produces" : [ "application/json" ]
    }

Many thanks for the help.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

Ron Ratovsky

unread,
Dec 22, 2016, 5:04:52 PM12/22/16
to swagger-sw...@googlegroups.com

The package input should be able to accept comma separated values, so you can try that.

 

You can’t mix servlets and jax-rs resources for scanning as they use different scanners that can’t really co-exist. Do you use both?

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--

You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

janet vanderpuye

unread,
Dec 22, 2016, 5:26:10 PM12/22/16
to Swagger
Ok thanks. 

On a quick scan, I used the BeanConfig class under io.swagger.jaxrs.config in the Bootstrap.java servlet.  Maybe that is where the conflict arises from. Do you have any suggestions on how to initialize swagger servlet( That is the main purpose of the Bootstrap class). 90% the examples and tutorials I saw used the web.xml option and I was trying to avoid that. 

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

Ron Ratovsky

unread,
Dec 22, 2016, 5:30:02 PM12/22/16
to swagger-sw...@googlegroups.com

What I’m saying is that you can’t use swagger-core for both jax-rs resources and servlets in a single app.

Ok thanks. 

 

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

janet vanderpuye

unread,
Dec 22, 2016, 5:39:20 PM12/22/16
to Swagger
Oh ok. Maybe I need to read up a bit on Jax-rs but I believe application was built using only servlets. I had only the Bootstrap class and ProfileServlets class, which were written using HttpServlets. Unless one of the default package imports was built on Jax-rs. Thanks for the tip, I will double check for that.

Ok thanks. 

 

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

maldonado...@yahoo.com

unread,
Dec 22, 2016, 5:47:53 PM12/22/16
to swagger-sw...@googlegroups.com

--------------------------------------------
On Fri, 12/23/16, janet vanderpuye <rhy...@gmail.com> wrote:

Subject: Re: Cant locate swagger.json on java + embedded jetty + httpservlet + swagger integration
To: "Swagger" <swagger-sw...@googlegroups.com>
Date: Friday, December 23, 2016, 12:39 AM

Oh ok. Maybe I need
to read up a bit on Jax-rs but I believe application was
built using only servlets. I had only the Bootstrap class
and ProfileServlets class, which were written using
HttpServlets. Unless one of the default package imports was
built on Jax-rs. Thanks for the tip, I will double check for
that.

On Thursday, 22 December 2016 17:30:02 UTC-5, Ron
wrote:What I’m
saying is that you can’t use swagger-core for both jax-rs
resources and servlets in a single app.   From:
<swagger-sw...@ googlegroups.com> on
behalf of janet vanderpuye <rhy...@gmail.com>
Reply-To: "swagger-sw...@
googlegroups.com" <swagger-sw...@ googlegroups.com>
Date: Thursday, 22 December 2016 at 14:26
To: Swagger <swagger-sw...@
googlegroups.com>
Subject: Re: Cant locate swagger.json on java +
embedded jetty + httpservlet + swagger
integration Ok thanks.   On a quick scan, I used the
BeanConfig class under io.swagger.jaxrs.config in the
Bootstrap.java servlet.  Maybe that is where the conflict
arises from. Do you have any suggestions on how to
initialize swagger servlet( That is the main purpose of the
Bootstrap class). 90% the examples and tutorials I saw used
the web.xml option and I was trying to avoid that. 

On Thursday, 22 December 2016 17:04:52 UTC-5, Ron wrote:
The package
input should be able to accept comma separated values, so
you can try that. You can’t
mix servlets and jax-rs resources for scanning as they use
different scanners that can’t really co-exist. Do you use
both?   From:
<swagger-sw...@googlegroups. com> on
behalf of janet vanderpuye <rhy...@gmail.com>
Reply-To: "swagger-sw...@googlegroups. com"
<swagger-sw...@googlegroups.
com>
Date: Thursday, 22 December 2016 at 13:53
To: Swagger <swagger-sw...@googlegroups. com>
Subject: Re: Cant locate swagger.json on java +
embedded jetty + httpservlet + swagger
integration WHOOHOO! We have success!
Thank you, guys. You are amazing. I had spent the better
part of 16 hours on this before I admitted defeat. 
 That aside, i have a couple
of questionsDoes the
beanConfig.setResourcePackage( "package name")
take in only one package? If so, do I have to move all
swagger resources into the package?What happens to my
@ApiModel resource object which I have defined in another
package? This is essentially a datatype so traditionally it
is held in a different package from the servlets.I noticed that the
<swagger-sw...@googlegroups. com> on
behalf of janet vanderpuye <rhy...@gmail.com>
Reply-To: "swagger-sw...@googlegroups. com"
<swagger-sw...@googlegroups.
com>
beanConfig.setPrettyPrint(true ); Looking at the logs, it shows
that at least it picked up my servlet package for scanning.
Could it be an error in the way I declared the annotations?
Log output is:308 [main]
INFO Main  - User profile server
initialized.Dec 22, 2016
3:57:50 PM com.sun.jersey.api.core. PackagesResourceConfig
initINFO: Scanning
for root resource and provider classes in the
packages: 
com.api.resources 
io.swagger.jaxrs.json 
io.swagger.jaxrs.listing 
com.coreservices.servlets 
com.coreservices.datatypesDec 22, 2016
3:57:50 PM com.sun.jersey.api.core. ScanningResourceConfig
logClassesINFO: Root
resource classes found:  class
io.swagger.jaxrs.listing.
AcceptHeaderApiListingResource  class
io.swagger.jaxrs.listing.
ApiListingResourceDec 22, 2016
3:57:50 PM com.sun.jersey.api.core. ScanningResourceConfig
logClassesINFO: Provider
classes found:  class
io.swagger.jaxrs.listing.
SwaggerSerializersDec 22, 2016
3:57:50 PM com.sun.jersey.server.impl.
application.WebApplicationImpl
_initiateINFO:
Initiating Jersey application, version 'Jersey: 1.19.1
03/11/2016 02:08 PM'2277 [main]
INFO Main  - user profile service
started
On Thursday, 22 December 2016 15:47:24 UTC-5, Ron wrote:
Looking back,
you have a Bootstrap class with the line    
beanConfig.setResourcePackage(
"io.swagger.resources"); Change
“io.swagger.resources” to the package(s) of your
resources and that should allow it to pick them up and scan
them.   From:
<swagger-sw...@googlegroups. com> on
behalf of janet vanderpuye <rhy...@gmail.com>
Reply-To: "swagger-sw...@googlegroups. com"
<swagger-sw...@googlegroups.
com>
Date: Thursday, 22 December 2016 at 12:28
To: Swagger <swagger-sw...@googlegroups. com>
Subject: Re: Cant locate swagger.json on java +
embedded jetty + httpservlet + swagger
integration Yeah the Api calls work. I
can make calls to my servlets without error. Its just the
swagger documentation is not generating any of my
annotations.

On Thursday, 22 December 2016 15:25:14 UTC-5, Ron wrote:
Okay, so it
should work. Is your API
itself accessible? Can you make any of the API calls
successfully?   From:
<swagger-sw...@googlegroups. com> on
behalf of janet vanderpuye <rhy...@gmail.com>
Reply-To: "swagger-sw...@googlegroups. com"
<swagger-sw...@googlegroups.
com>
<swagger-sw...@googlegroups. com> on
behalf of janet vanderpuye <rhy...@gmail.com>
Reply-To: "swagger-sw...@googlegroups. com"
<swagger-sw...@googlegroups.
com>
Date: Thursday, 22 December 2016 at 11:10
To: Swagger <swagger-sw...@googlegroups. com>
Subject: Re: Cant locate swagger.json on java +
embedded jetty + httpservlet + swagger
integration So for my servlets, I just
tried:  apiservlet
= servletContextHandler. addServlet(ProfileServlet. class,
"/user/*");
apiservlet.setInitOrder(3);
apiservlet.setInitParameter(" com.sun.jersey.config.
property.packages", "com.coreservices.servlets;
package
com.coreservices.datatypes"); and   apiservlet =
servletContextHandler. addServlet(ProfileServlet. class,
"/user/*");
apiservlet.setInitOrder(3);
apiservlet.setInitParameter(" com.sun.jersey.config.
property.packages", "com.api.resources;io.swagger.
jaxrs.json;io.swagger.jaxrs. listing;com.coreservices.
servlets;package com.coreservices.datatypes"); I am still getting the
default swagger response {"swagger":"2.0","info":{"
version":"1.0.0","title":""}}Am I missing any annotation
or configuration in the files?Secondly to access the
jaxrs.json;io.swagger.jaxrs. listing");
get the swagger.json filehttp://host:7000/swagger-core 
===> HTTP ERROR 405http://host:7000/swagger-core/
swagger.json ===> HTTP ERROR 404http://host:7000/user/swagger.
json ===> HTTP ProfileServlet response, not
swagger.jsonhttp://host:7000/user
===> HTTP ProfileServlet response, not
swagger.jsonhttp://host:7000/swagger.json
===> HTTP ERROR 404http://host:7000/api/swagger.
json ===> HTTP ERROR 404http://host:7000/
//Setup
APIs    
ServletHolder apiservlet =
servletContextHandler. addServlet(ProfileServlet.clas
s,
"/user/*");   
apiservlet.setInitOrder(1);   
apiservlet.setInitParameter("
com.sun.jersey.config.
property.packages",
"com.api.resources;io.swagger.
jaxrs.json;io.swagger.jaxrs.
listing");    logger.info("User
profile server initialized.");        
// Setup Swagger
servlet       
ServletHolder swaggerServlet
= servletContextHandler.
addServlet(DefaultJaxrsConfig.
class,
"/swagger-core");       
swaggerServlet.setInitOrder(2)
;       
swaggerServlet. setInitParameter("api.version" ,
"1.0.0");        
// Setup
Swagger-UI static resources       
String
resourceBasePath = Main.class.getResource("/
webapp").toExternalForm();       
servletContextHandler.
setWelcomeFiles(new
String[]
{"index.html"});       
servletContextHandler. setResourceBase(
resourceBasePath);       
servletContextHandler. addServlet(new
from it, send an email to swagger-swaggers...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
age 29 of 131separai de distana - el la Bucureti ea la Iai - se vedeau rar in schimb purtau o frecventa corespondena. [tatalui sau in 18 mar. 1881 la 31 de ani] Bucureti 18 martie 1881 Iubite Tata M-am bucurat mult primind scrisoarea d-tale in versuri i m-am intristat asemenea afland din ea ca nu eti tocmai bine. Altfel i eu am avut acele friguri de primavara atat de obicinuite in ara la noi. N-am raspuns numaidecat pentru ca m-a apucat proclamarea regatului 1 pe dinainte i-n asemenea imprejurari noi negustorii de gogoi i de braoave adica noi gazetarii suntem foarte ocupai 2 . A dori din toata inima sa vin acasa sa va vad dac-a gasi vrun om de incredere care sa-mi ie locul caci negustoria asta pe langa ca n-aduce nimic nici nu te ingaduie sa inchizi o zi doua dugheana i sa mai iei lumea-n cap ci-n toate zilele trebuie omul sa-i bata capul ca sa afle minciuni noua. Dac-oi putea scapa iubite tata fie acum fie la vara vin desigur acasa. il rog pe Nicu a sa-mi scrie mai des i sa nu se uite la aceea ca nu-i raspund caci daca am aa de puina vreme de scris i daca mi-e acru sufletul de cerneala i de condei citesc totui cu multa bucurie scrisorile ce le primesc de la d-voastra. Sarutandu-i manile i dorindu-i multa sanatate i voie buna raman al d-tale supus fiu Mihai 1. proclamarea regatului - Romania a fost proclamata regat - i Carol I incoronat rege - in 14 martie 1881. 2. noi gazetarii suntem foarte ocupai - Eminescu era pe atunci redactor-ef la ziarul conservator Timpul i scria ziarul in buna parte el singur. 29 Page 29 of 131

Ron Ratovsky

unread,
Dec 22, 2016, 5:57:48 PM12/22/16
to swagger-sw...@googlegroups.com

Huh, I misread it as you using jersey. You need to use a different dependency then and a different set up process.

We don’t really have documentation for it, but there’s a sample - https://github.com/swagger-api/swagger-samples/tree/master/java/java-servlet

Ok thanks. 

 

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

janet vanderpuye

unread,
Dec 23, 2016, 3:25:03 PM12/23/16
to Swagger
Thanks Ron.

Last night I double-checked and made sure I had no jersey resources/dependencies in my code. I also looked through the github project link you posted and imitated his dependencies and method calls without using the web.xml ( I really want to avoid web.xml as a number of the existing projects I have run as jars with embedded jetty's and no web.xml). The two things I'm faced with now are:
  1. Adding multiple packages(separated by a comma or semi-colon) as a resource through the Servlet.setInitParam() method does not work. Multiple packages delimited by a comma or otherwise result in the default {"swagger":"2.0","info":{"version":"1.0.0","title":""}} response.
  2. Secondly, I think I still have an issue in how Swagger scans  my project. When I do get the swagger.json to display my annotations, it only captures the information in the @Info annotation on my servlet. Anything withing the @Api, @ApiOperation, @ApiResponses, @ApiModel are effectively ignored. Unless I'm mistaken, all of these are supposed to show up in the swagger.json output right? Or do I have to browse to another path to view those annotations too? I seen some posts use the path http://<host>:<port>/swagger-api/<servlet_name> but that does not work for me
 Here is what my code for the swagger servlet initialization and configuration looks like now. The custom servlet class I posted above remains largely the same.
import org.apache.log4j.Logger;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import io.swagger.servlet.listing.ApiDeclarationServlet;
import io.swagger.servlet.config.DefaultServletConfig;
.
.
.

logger
.info("Initializing user profile server...");
 
new UserDao();
 
Server server = new Server(Integer.parseInt(properties.getProperty(Config.JETTY_SERVICE_PORT)));
 
ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
 servletContextHandler
.setContextPath("/");
 server
.setHandler(servletContextHandler);



 
//Custom servlet

 
ServletHolder apiservlet = servletContextHandler.addServlet(ProfileServlet.class, "/user/*");

 apiservlet
.setInitOrder(3);

 logger
.info("User profile server initialized.");



 
// Swagger servlet reader
 
ServletHolder swaggerServlet = servletContextHandler.addServlet(DefaultServletConfig.class, "/swagger-core");

 swaggerServlet
.setInitOrder(2);
 swaggerServlet
.setInitParameter("api.version", "1.0.0");

 
//swaggerServlet.setInitParameter("swagger.resource.package", "com.coreservices.servlets,com.coreservices.datatypes"); NOTE::THIS DOES NOT WORK
 swaggerServlet
.setInitParameter("swagger.resource.package","com.coreservices.servlets");
 swaggerServlet
.setInitParameter("swagger.api.basepath", "http://localhost:7000");


 
// Swagger api declaration
 servletContextHandler
.addServlet(ApiDeclarationServlet.class, "/api/*");
 
return server;
}

Thanks once again for the help.


Ok thanks. 

 

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

beaver...@yahoo.com

unread,
Dec 23, 2016, 7:47:31 PM12/23/16
to swagger-sw...@googlegroups.com

--------------------------------------------
On Fri, 12/23/16, janet vanderpuye <rhy...@gmail.com> wrote:

Subject: Re: Cant locate swagger.json on java + embedded jetty + httpservlet + swagger integration
To: "Swagger" <swagger-sw...@googlegroups.com>
Date: Friday, December 23, 2016, 10:25 PM

Thanks Ron.
Last night I double-checked and made sure I had
no jersey resources/dependencies in my code. I also looked
through the github project link you posted and imitated his
dependencies and method calls without using the web.xml ( I
really want to avoid web.xml as a number of the existing
projects I have run as jars with embedded jetty's and no
web.xml). The two things I'm faced with now
are:Adding multiple packages(separated by
a comma or semi-colon) as a resource through the
Servlet.setInitParam() method does not work. Multiple
packages delimited by a comma or otherwise result in the
default {"swagger":"2.0","info":{"
version":"1.0.0","title":""}}
response.Secondly, I think I still have an
<swagger-sw...@ googlegroups.com> on
behalf of janet vanderpuye <rhy...@gmail.com>
Reply-To: "swagger-sw...@
googlegroups.com" <swagger-sw...@ googlegroups.com>
Date: Thursday, 22 December 2016 at 14:39
To: Swagger <swagger-sw...@
googlegroups.com>
Subject: Re: Cant locate swagger.json on java +
embedded jetty + httpservlet + swagger
integration Oh ok. Maybe I need to read
up a bit on Jax-rs but I believe application was built using
only servlets. I had only the Bootstrap class and
ProfileServlets class, which were written using
HttpServlets. Unless one of the default package imports was
built on Jax-rs. Thanks for the tip, I will double check for
that.

On Thursday, 22 December 2016 17:30:02 UTC-5, Ron wrote:
What I’m
saying is that you can’t use swagger-core for both jax-rs
resources and servlets in a single app.   From:
<swagger-sw...@googlegroups. com> on
behalf of janet vanderpuye <rhy...@gmail.com>
Reply-To: "swagger-sw...@googlegroups. com"
<swagger-sw...@googlegroups.
com>
Date: Thursday, 22 December 2016 at 14:26
To: Swagger <swagger-sw...@googlegroups. com>
Subject: Re: Cant locate swagger.json on java +
embedded jetty + httpservlet + swagger
integration Ok thanks.   On a quick scan, I used the
BeanConfig class under io.swagger.jaxrs.config in the
Bootstrap.java servlet.  Maybe that is where the conflict
arises from. Do you have any suggestions on how to
initialize swagger servlet( That is the main purpose of the
Bootstrap class). 90% the examples and tutorials I saw used
the web.xml option and I was trying to avoid that. 

On Thursday, 22 December 2016 17:04:52 UTC-5, Ron wrote:
The package
input should be able to accept comma separated values, so
you can try that. You can’t
mix servlets and jax-rs resources for scanning as they use
different scanners that can’t really co-exist. Do you use
both?   From:
<swagger-sw...@googlegroups. com> on
behalf of janet vanderpuye <rhy...@gmail.com>
Reply-To: "swagger-sw...@googlegroups. com"
<swagger-sw...@googlegroups.
com>
Date: Thursday, 22 December 2016 at 13:53
To: Swagger <swagger-sw...@googlegroups. com>
Subject: Re: Cant locate swagger.json on java +
embedded jetty + httpservlet + swagger
integration WHOOHOO! We have success!
Thank you, guys. You are amazing. I had spent the better
part of 16 hours on this before I admitted defeat. 
 That aside, i have a couple
of questionsDoes the
beanConfig.setResourcePackage( "package name")
take in only one package? If so, do I have to move all
swagger resources into the package?What happens to my
@ApiModel resource object which I have defined in another
package? This is essentially a datatype so traditionally it
is held in a different package from the servlets.I noticed that the
onlybeanConfig.setResourcePackage(
"com.coreservices.servlets");    From:
<swagger-sw...@googlegroups. com> on
behalf of janet vanderpuye <rhy...@gmail.com>
Reply-To: "swagger-sw...@googlegroups. com"
<swagger-sw...@googlegroups.
com>
"com.gh.cive.coreservices. servlets");
beanConfig.setResourcePackage(
"com.gh.cive.coreservices. datatypes");
beanConfig.setScan(true);
beanConfig.setPrettyPrint(true ); Looking at the logs, it shows
that at least it picked up my servlet package for scanning.
Could it be an error in the way I declared the annotations?
Log output is:308 [main]
INFO Main  - User profile server
initialized.Dec 22, 2016
3:57:50 PM com.sun.jersey.api.core. PackagesResourceConfig
initINFO: Scanning
for root resource and provider classes in the
packages: 
com.api.resources 
io.swagger.jaxrs.json 
io.swagger.jaxrs.listing 
com.coreservices.servlets 
com.coreservices.datatypesDec 22, 2016
3:57:50 PM com.sun.jersey.api.core. ScanningResourceConfig
logClassesINFO: Root
resource classes found:  class
io.swagger.jaxrs.listing.
AcceptHeaderApiListingResource  class
io.swagger.jaxrs.listing.
ApiListingResourceDec 22, 2016
3:57:50 PM com.sun.jersey.api.core. ScanningResourceConfig
logClassesINFO: Provider
classes found:  class
io.swagger.jaxrs.listing.
SwaggerSerializersDec 22, 2016
3:57:50 PM com.sun.jersey.server.impl.
application.WebApplicationImpl
_initiateINFO:
Initiating Jersey application, version 'Jersey: 1.19.1
03/11/2016 02:08 PM'2277 [main]
INFO Main  - user profile service
started
On Thursday, 22 December 2016 15:47:24 UTC-5, Ron wrote:
Looking back,
you have a Bootstrap class with the line    
beanConfig.setResourcePackage(
"io.swagger.resources"); Change
“io.swagger.resources” to the package(s) of your
resources and that should allow it to pick them up and scan
them.   From:
<swagger-sw...@googlegroups. com> on
behalf of janet vanderpuye <rhy...@gmail.com>
Reply-To: "swagger-sw...@googlegroups. com"
<swagger-sw...@googlegroups.
com>
Date: Thursday, 22 December 2016 at 12:28
To: Swagger <swagger-sw...@googlegroups. com>
Subject: Re: Cant locate swagger.json on java +
embedded jetty + httpservlet + swagger
integration Yeah the Api calls work. I
can make calls to my servlets without error. Its just the
swagger documentation is not generating any of my
annotations.

On Thursday, 22 December 2016 15:25:14 UTC-5, Ron wrote:
Okay, so it
should work. Is your API
itself accessible? Can you make any of the API calls
successfully?   From:
<swagger-sw...@googlegroups. com> on
behalf of janet vanderpuye <rhy...@gmail.com>
Reply-To: "swagger-sw...@googlegroups. com"
<swagger-sw...@googlegroups.
com>
Date: Thursday, 22 December 2016 at 11:37
To: Swagger <swagger-sw...@googlegroups. com>
Subject: Re: Cant locate swagger.json on java +
embedded jetty + httpservlet + swagger
integration In my pom file, I have
1.19.1 <dependency>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-
annotations</artifactId>
    <version>1.5.10</version>
</dependency>
<dependency>
    <groupId>com.google.code.gson< /groupId>
    <artifactId>gson</artifactId>
    <version>2.7</version>
</dependency>
<dependency>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-jaxrs</ artifactId>
    <version>1.5.10</version>
</dependency>
<dependency>
    <groupId>com.sun.jersey</ groupId>
    <artifactId>jersey-servlet</ artifactId>
    <version>1.19.1</version>
</dependency>
On Thursday, 22 December 2016 14:34:08 UTC-5, Ron wrote:
Which version
of Jersey do you use?   From:
<swagger-sw...@googlegroups. com> on
behalf of janet vanderpuye <rhy...@gmail.com>
Reply-To: "swagger-sw...@googlegroups. com"
<swagger-sw...@googlegroups.
com>
Date: Thursday, 22 December 2016 at 11:10
To: Swagger <swagger-sw...@googlegroups. com>
Subject: Re: Cant locate swagger.json on java +
embedded jetty + httpservlet + swagger
integration So for my servlets, I just
tried:  apiservlet
= servletContextHandler. addServlet(ProfileServlet. class,
"/user/*");
apiservlet.setInitOrder(3);
apiservlet.setInitParameter(" com.sun.jersey.config.
property.packages", "com.coreservices.servlets;
package
com.coreservices.datatypes"); and   apiservlet =
servletContextHandler. addServlet(ProfileServlet. class,
"/user/*");
apiservlet.setInitOrder(3);
apiservlet.setInitParameter(" com.sun.jersey.config.
property.packages", "com.api.resources;io.swagger.
jaxrs.json;io.swagger.jaxrs. listing;com.coreservices.
servlets;package com.coreservices.datatypes"); I am still getting the
default swagger response {"swagger":"2.0","info":{"
version":"1.0.0","title":""}}Am I missing any annotation
or configuration in the files?Secondly to access the
swagger ui annotation for my custom servlet
"ProfileServlet.class", do I use the same url as
"http://host:7000/api/swagger.
json"?  Really appreciate the quick
feedback on this
On Thursday, 22 December 2016 13:52:18 UTC-5, tony tam
wrote: Sounds like the issue then is
how it’s scanning your code.  Put your API package here:
    
apiservlet.setInitParameter("
com.sun.jersey.config.
property.packages",
"com.api.resources;io.swagger.
jaxrs.json;io.swagger.jaxrs.
listing");so
they can be scanned. On Dec 22, 2016, at 10:50 AM,
janet vanderpuye <rhy...@gmail.com> wrote: Quick update. After modifying
the initializeAPI method to the original Servlet class in
the blog(see below),  I was able to get some response from
the swagger-ui on http://host:7000/api/swagger.
json. But I it seems like swagger wasnt able to parse my
servlet annotations http://host:7000/api/swagger.
json ===>
{"swagger":"2.0","info":{"
version":"1.0.0","title":""}} private
static Server initializeApi(Properties properties) {
    logger.info("Initializing user profile
server...");
    new UserDao();
    Server server = new Server(Integer.parseInt(
properties.getProperty(Config.
JETTY_SERVICE_PORT)));
    ServletContextHandler servletContextHandler = new
ServletContextHandler( ServletContextHandler.SESSIONS
);
    servletContextHandler.
setContextPath("/");
    server.setHandler( servletContextHandler);
    //Setup APIs
    ServletHolder apiservlet = servletContextHandler.
addServlet(ServletContainer. class, "/api/*");
    apiservlet.setInitOrder(1);
    apiservlet.setInitParameter("
com.sun.jersey.config. property.packages",
"com.api.resources;io.swagger.
jaxrs.json;io.swagger.jaxrs. listing");

    apiservlet = servletContextHandler.
addServlet(ProfileServlet. class, "/user/*");
    //apiservlet.setInitOrder(1);
    apiservlet.setInitParameter("
com.sun.jersey.config. property.packages",
"com.api.resources;io.swagger.
jaxrs.json;io.swagger.jaxrs. listing");
    logger.info("User profile server
initialized.");

    // Setup Swagger servlet
    ServletHolder swaggerServlet = servletContextHandler.
addServlet(DefaultJaxrsConfig. class,
"/swagger-core");
    swaggerServlet.setInitOrder(2) ;
    swaggerServlet.
setInitParameter("api.version" ,
"1.0.0");

    // Setup Swagger-UI static resources
    String resourceBasePath =
Main.class.getResource("/
webapp").toExternalForm();
    servletContextHandler. setWelcomeFiles(new String[]
{"index.html"});
    servletContextHandler. setResourceBase(
resourceBasePath);
    servletContextHandler. addServlet(new
ServletHolder(new DefaultServlet()), "/*");

    return server;
}
On Thursday, 22 December 2016 13:31:03 UTC-5, janet
vanderpuye wrote: I
recently followed this blog to integrate swagger
in my embedded jetty project but after running, I'm not
able to access the swagger.json file on any path
combination. Accessing the servlets for the resources work
with no error but I get the following errors when I try to
get the swagger.json filehttp://host:7000/swagger-core 
===> HTTP ERROR 405http://host:7000/swagger-core/
swagger.json ===> HTTP ERROR 404http://host:7000/user/swagger.
json ===> HTTP ProfileServlet response, not
swagger.jsonhttp://host:7000/user
===> HTTP ProfileServlet response, not
swagger.jsonhttp://host:7000/swagger.json
===> HTTP ERROR 404http://host:7000/api/swagger.
json ===> HTTP ERROR 404http://host:7000/
===> Static swagger sample page (Pet store), not
swagger.jsonMain.java
public
static
void
main(String[] args)
throws
Exception
{  
Server server =
initializeApi(properties);   
server.start();    logger.info("Api
resource service started");   
server.join();

private
static
Server
initializeApi(Properties properties)
{    logger.info("Initializing
user profile server...");   
new
UserDao();   
Server server =
new
Server(Integer.parseInt(
properties.getProperty(Config.
JETTY_SERVICE_PORT)));   
ServletContextHandler
servletContextHandler = new
ServletContextHandler(ServletC
ontextHandler.SESSIONS);   
servletContextHandler.
setContextPath("/");   
server.setHandler(
servletContextHandler);   
//Setup
APIs    
ServletHolder apiservlet =
servletContextHandler. addServlet(ProfileServlet.clas
s,
"/user/*");   
apiservlet.setInitOrder(1);   
apiservlet.setInitParameter("
com.sun.jersey.config.
property.packages",
"com.api.resources;io.swagger.
jaxrs.json;io.swagger.jaxrs.
listing");    logger.info("User
profile server initialized.");        
// Setup Swagger
servlet       
ServletHolder swaggerServlet
= servletContextHandler.
addServlet(DefaultJaxrsConfig.
class,
"/swagger-core");       
swaggerServlet.setInitOrder(2)
;       
swaggerServlet. setInitParameter("api.version" ,
"1.0.0");        
// Setup
Swagger-UI static resources       
String
resourceBasePath = Main.class.getResource("/
webapp").toExternalForm();       
servletContextHandler.
setWelcomeFiles(new
String[]
{"index.html"});       
servletContextHandler. setResourceBase(
resourceBasePath);       
servletContextHandler. addServlet(new
from it, send an email to swagger-swaggers...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
in pacate instalarea noilor corpuri legislative a caror atitudine nu mai sa fi in nici intr-un fel ostila domnului si guvernului sau a coincis si cu jriorarea raporturilor dintre Alexandru I. Cuza si M. Kogalniceanu. Turneul nfal al primului ministru-in Oltenia in august-septembrie 1864 fusese rau rpretat in anturajul principelui. Desi pretutindeni M. Kogalniceanu a subliniat itele lui Alexandru I. Cuza in infaptuirea politicii de reforme a statului esul sau personal n-a putut fi trecut cu vederea. S-au adaugat in timp o ia de animozitati personale cu membri ai guvernului sau persoane apropiate inului totul culminand cu demisia primului ministru la 26 ianuarie 1865 pe j Alexandru I. Cuza a primit-o imediat. Era incontestabil o greseala politica andul colaboratorilor sai nu se gasea nici o alta personalitate de talia lectuala si politica a fostului sau prim sfetnic.

rushinc...@yahoo.com

unread,
Dec 24, 2016, 11:11:49 AM12/24/16
to swagger-sw...@googlegroups.com

--------------------------------------------
On Sat, 12/24/16, beaverscesar via Swagger <swagger-sw...@googlegroups.com> wrote:

Subject: Re: Cant locate swagger.json on java + embedded jetty + httpservlet + swagger integration
To: swagger-sw...@googlegroups.com
Date: Saturday, December 24, 2016, 2:47 AM
https://groups.google.com/d/optout.omiccel mai important in agricultura marii proprietari devin stapani asupra

beaver...@yahoo.com

unread,
Dec 25, 2016, 2:27:43 AM12/25/16
to swagger-sw...@googlegroups.com

--------------------------------------------
On Sat, 12/24/16, rushinclarence via Swagger <swagger-sw...@googlegroups.com> wrote:

Subject: Re: Cant locate swagger.json on java + embedded jetty + httpservlet + swagger integration
To: swagger-sw...@googlegroups.com
Date: Saturday, December 24, 2016, 6:11 PM
https://groups.google.com/d/optout.783 si 1791- Este stabilit regimul obligatiilor materiale ale Valahiei si Moldovei fata de Imperiul Otoman fiind exclusa orice alta cerere de bani din partea curtii suzerane. Totodata este recunoscuta autonomia celor doua tari carpato-duna-ne imixtiunile otomane in treburile lor interne fiind de asemenea interzise. Durata domniei este fixata la sapte ani. Anterior expirarii acestui termen mazilirea domnilor este conditionata de acordul comun al Rusiei si Portii. in acest context nu mai surprinde faptul ca imediat noii domni de la Bucuresti - Constantin Ipsilanti 1802-1806 1807 - si lasi - Alexandru Moruzi 1802-1806 1807 - adopta o politica filo-rusa. Ei nemultumesc astfel pe primul imparat al francezilor care il convinge pe sultan sa-i indeparteze din scaun 12 august 1806 . tarul Alexandru I 1801-1825 invoca incalcarea hatiserifului sus-mentionat si ordona trupelor ruse sa invadeze Moldova apoi Tara Romaneasca.

snowjo...@yahoo.com

unread,
Dec 25, 2016, 3:25:35 AM12/25/16
to swagger-sw...@googlegroups.com

--------------------------------------------
On Sun, 12/25/16, beaverscesar via Swagger <swagger-sw...@googlegroups.com> wrote:

Subject: Re: Cant locate swagger.json on java + embedded jetty + httpservlet + swagger integration
To: swagger-sw...@googlegroups.com
Date: Sunday, December 25, 2016, 9:27 AM
https://groups.google.com/d/optout. Balcescu si Alexandru G. Golescu. Astfel au fost abolite rangurile

vickers...@yahoo.com

unread,
Dec 25, 2016, 10:23:53 AM12/25/16
to swagger-sw...@googlegroups.com

--------------------------------------------
On Sun, 12/25/16, snowjoseph987 via Swagger <swagger-sw...@googlegroups.com> wrote:

Subject: Re: Cant locate swagger.json on java + embedded jetty + httpservlet + swagger integration
To: swagger-sw...@googlegroups.com
Date: Sunday, December 25, 2016, 10:25 AM
https://groups.google.com/d/optout.8-19 ian. - Tudor Vladimirescu paraseste Bucurestiul si se indreapta spre Oltenia. 23 ian. - Proclamatia de la Pades. 4-28 febr. -Tabara lui Tudor Vladimirescu de la tantareni. 22 febr. - Eteristii trec Prutul in Moldova si incep inaintarea in Principate. 23 febr. - Rusia condamna revolutia lui Tudor Vladimirescu. 28 febr. - Reprezentanti ai marii boierimi muntene se retrag la Brasov. 16 mart. - Proclamatia lui Tudor de la Bolintin. 'i 21 mart. - Tudor intra in Bucuresti. 30 mart. - intalnire intre Tudor Vladi-' mirescu si Alexandru Ipsilanti. 3 apr. - in urma dezavuarii Eteriei de catre Rusia Ipsilanti se retrage la Targoviste. apr. - Negocieri ale lui Tudor cu pasii otomani de la Dunare pentru a evita interventia Portii. 1 mai - Otomanii patrund in Principate. 15 mai - Tudor se retrage catre Oltenia. 21 mai - Arestarea lui Tudor in tabara de la Golesti. Este executat de catre eteristi la Targoviste 27 mai . 7 iun. - Batalia de la Dragasani. 6 aug. - Bimbasa Sava si un grup de arnauti sunt macelariti la Bucuresti de catre otomani.1821

rushinc...@yahoo.com

unread,
Dec 25, 2016, 6:29:46 PM12/25/16
to swagger-sw...@googlegroups.com

--------------------------------------------
On Sun, 12/25/16, vickersdiane390 via Swagger <swagger-sw...@googlegroups.com> wrote:

Subject: Re: Cant locate swagger.json on java + embedded jetty + httpservlet + swagger integration
To: swagger-sw...@googlegroups.com
Date: Sunday, December 25, 2016, 5:23 PM
https://groups.google.com/d/optout.evolutia de la 1848 cauta a reintregi pe roman numai in drepturile sale de om si de cetatean fara a cauta a-! reintregi in drepturile sale de natie. intr-aceasta ea se margini a cere ca Turcia sa respecte vechile capitulatii recunoscute si intarite si prin tratatul de la Adnanopol si Hatiseriful de la 1834. Ea ceru asemenea ca Rusia sa-si pazeasca tractatele care recunosc autonomia si independenta administrativa a terii si nesihrea pamantului ei si sa se margineasca in rolul ei de chezasa fara a se amesteca in treburile din launtru ale teni usurpand titlul si rolul de protectoare Revolutia de la 1848 nu era dar in drept impotrivitoare nici Portii nici Rusiei devreme ce se marginea a cere pazirea tractatelor fara a proclama un drept nou. Romanii in buna credinta a lor socoteau ca aceste Puteri vor fi gata a pazi sfintenia tractatelor si nu vor putea a le tagadui reformarea legiuirilor potrivit dreptului lor de autonomie .

vickers...@yahoo.com

unread,
Dec 26, 2016, 3:12:03 AM12/26/16
to swagger-sw...@googlegroups.com

--------------------------------------------
On Mon, 12/26/16, rushinclarence via Swagger <swagger-sw...@googlegroups.com> wrote:

Subject: Re: Cant locate swagger.json on java + embedded jetty + httpservlet + swagger integration
To: swagger-sw...@googlegroups.com
Date: Monday, December 26, 2016, 1:29 AM
https://groups.google.com/d/optout.-a instalat in Imperiul Habsburgic regimul neoabsolutist coordonat de I de interne baronul Alexander von Bach. El s-a sprijinit pe o centralizare excesiva introducerea limbii germane drept limba oficiala si presiuni npunerea religiei catolice.

Ron Ratovsky

unread,
Dec 26, 2016, 2:23:08 PM12/26/16
to swagger-sw...@googlegroups.com

If scanning multiple packages isn’t working for you, you should open a ticket on the project. We may have some basic bugs with servlet implementation as that’s less commonly used.

 

The scanning should definitely pick up anything that has the @Api annotations on it. The only reason it wouldn’t is if they are not in the package you’ve set to be scanned.

Have you had a look at the servlet sample?

Ok thanks. 

 

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

janet vanderpuye

unread,
Dec 27, 2016, 11:21:21 AM12/27/16
to Swagger
Hi,

thanks for the feedback. I will create the ticket for the multiple packages. I did look at the servlet sample you linked here. I followed that example and updated to the latest code i posted above. The only difference now between my implemetation and that  sample was I did not use a web.xml to specify the mapping. I only have that one custom servlet which has both the @Api annotation and the @Info annotation. The @info annotation is picked up and displayed but nothing shows up for the @Api contents.

Ron Ratovsky

unread,
Dec 27, 2016, 12:01:47 PM12/27/16
to swagger-sw...@googlegroups.com

The web.xml is not the only way to configure it, and I think you’ve went with different approach(es). What did you end up using?

--

janet vanderpuye

unread,
Dec 27, 2016, 4:06:40 PM12/27/16
to Swagger
Maybe. Here is what I have so far.

Main.java
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import io.swagger.servlet.listing.ApiDeclarationServlet;
import io.swagger.servlet.config.DefaultServletConfig;


 Server server = new Server(Integer.parseInt(properties.getProperty(Config.JETTY_SERVICE_PORT)));
        ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
        servletContextHandler.setContextPath("/");
        server.setHandler(servletContextHandler);

        //Custom servlet
        ServletHolder apiservlet = servletContextHandler.addServlet(ProfileServlet.class, "/user/*");
        apiservlet.setInitOrder(3);
        logger.info("User profile server initialized.");

        // Swagger servlet reader
        ServletHolder swaggerServlet = servletContextHandler.addServlet(DefaultServletConfig.class, "/swagger-core");
        swaggerServlet.setInitOrder(2);
        swaggerServlet.setInitParameter("api.version", "1.0.0");
        //swaggerServlet.setInitParameter("swagger.resource.package", "com.coreservices.servlets,com.coreservices.datatypes");
        swaggerServlet.setInitParameter("swagger.resource.package","com.coreservices.servlets");
        swaggerServlet.setInitParameter("swagger.api.basepath", "http://localhost:7000");

        // Swagger api declaration
        servletContextHandler.addServlet(ApiDeclarationServlet.class, "/api/*");
        server.start();


ProfileServlet.java /**custom httpservlet class**/
import io.swagger.annotations.*;
import org.apache.log4j.Logger;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created on 12/21/2016.
 */
@SwaggerDefinition(
   info = @Info(
           title = "User Profile Servlet",
           version = "1.0.0",
           description = "Servlet that handles basic CRUD operations to the user profile data source",
           contact = @Contact(name = "XYZ", email = "XYZ", url = "XYZ"),
           termsOfService = "XYZ",
           license = @License(name = "XYZ", url = "XYZ")
   ),
        basePath = "/",
        consumes = {"application/json"},
        produces = {"application/json"},
        schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS},
        tags = {@Tag(name = "users", description = "CRUD operations on user datatype")}
)
@Api(value = "/user", description = "performs CRUD operations on a user profile")
public class ProfileServlet extends HttpServlet {
    Logger logger = Logger.getLogger(ProfileServlet.class.getSimpleName());

    @ApiOperation(httpMethod = "GET", value = "Returns a [list of the] user profile datatype", notes = "", response = UserDatatype.class, nickname = "getUser", tags = ("User"))
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Succssful retrieval of user profiles", response = UserDatatype.class),
            @ApiResponse(code = 500, message = "Internal server error")
    })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "profile id", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "firstname", value = "First name of user", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "lastname", value = "Last name of user", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "phone", value = "phone number of user", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "signup", value = "Sign up date of user, in dd-MM-yyyy forma", required = false, dataType = "java.sql.Date", paramType = "query")
    })
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        RpcLogTemplate logTemplate = new RpcLogTemplate(req.getRemoteHost(),req.getParameter("client"), req.getParameter("clientapp"), Config.localhost, Config.SERVICE_INSTANCE, Config.SERVICE_APP, req.getParameterMap(), req.getRequestURI(),  new Date().getTime() );
        logger.debug("Received request: GET");
        logger.debug("Request URI: " + req.getRequestURI());
        logger.debug("Request servlet path: " + req.getServletPath());
        handleGet(req, resp, logTemplate);
        logTemplate.setResponseTimestamp(new Date().getTime());
        logTemplate.setResponseCode(Integer.toString(resp.getStatus()));
        Main.loggerService.addLog(logTemplate);
    }
}

Finally the dependencies in my pom file
<?xml version="1.0" encoding="UTF-8"?>
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.coreservice.dataservice</groupId>
    <artifactId>ServiceUserProfile</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <jetty.version>9.4.0.v20161208</jetty.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <!--Jetty dependencies start -->
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-server</artifactId>
            <version>${jetty.version}</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-servlet</artifactId>
            <version>${jetty.version}</version>
        </dependency>
        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-annotations</artifactId>
            <version>1.5.10</version>
        </dependency>
        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-servlet</artifactId>
            <version>1.5.10</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.7</version>
        </dependency>
        <dependency>
            <groupId>com.jolbox</groupId>
            <artifactId>bonecp</artifactId>
            <version>0.8.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>3.2.2.RELEASE</version>
        </dependency>

        <!--Jetty dependencies end -->
    </dependencies>

    <!-- Download the Swagger-UI project -->
    <build>
        <plugins>
            <plugin>
                <groupId>com.googlecode.maven-download-plugin</groupId>
                <artifactId>download-maven-plugin</artifactId>
                <version>1.2.1</version>
                <executions>
                    <execution>
                        <id>swagger-ui</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>wget</goal>
                        </goals>
                        <configuration>
                            <url>https://github.com/swagger-api/swagger-ui/archive/master.tar.gz</url>
                            <unpack>true</unpack>
                            <outputDirectory>${project.build.directory}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- Load the Swagger-UI components into the src/main/webapp/ directory to enable
            viewing/testing of the API routes. Accessible at http://<host>:<port>/swagger. -->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.0.2</version>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/src/main/resources/webapp</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${project.build.directory}/swagger-ui-master/dist</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.0</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>


</project>



To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

Ron Ratovsky

unread,
Dec 27, 2016, 5:04:57 PM12/27/16
to swagger-sw...@googlegroups.com

Okay, since you mentioned using two packages isn’t working, what happens if you only set com.coreservices.servlet for the resource packing?

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

--

You received this message because you are subscribed to the Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Ron Ratovsky

unread,
Dec 27, 2016, 5:05:29 PM12/27/16
to swagger-sw...@googlegroups.com

For the ‘resource scanning’ that is.

janet vanderpuye

unread,
Dec 27, 2016, 5:36:34 PM12/27/16
to Swagger
Yeah, that is what I have now. I have commented out the part where I use the multipackages. When I use one package, it partially works. I get only the data within the @Info annotations but nothing from the @API annotations.

Ron Ratovsky

unread,
Dec 27, 2016, 5:46:10 PM12/27/16
to swagger-sw...@googlegroups.com

At this point, I’d ask that you provide a sample app that reproduces it – would be difficult to try and debug it otherwise.

--

janet vanderpuye

unread,
Jan 3, 2017, 3:23:36 PM1/3/17
to Swagger
Hi Guys, 

Happy new year. I have a committed the problematic code here (https://github.com/rhycce/swaggersample.git) as requested. I would be grateful if you could check it out and help me resolve it.

This is the current output I have from swagger when I run it. As you can see, there is no documentation included from the portions annotated @Api, @ApiParam, etc only the annotations described within the @Info section.

{
  "swagger": "2.0",
  "info": {
    "description": "Servlet that handles basic CRUD operations to the user profile data source",
    "version": "1.0.0",



Thanks a lot. All help appreciated.

diaz_car...@yahoo.com

unread,
Jan 3, 2017, 4:46:31 PM1/3/17
to swagger-sw...@googlegroups.com

--------------------------------------------
On Tue, 1/3/17, janet vanderpuye <rhy...@gmail.com> wrote:

Subject: Re: Cant locate swagger.json on java + embedded jetty + httpservlet + swagger integration
To: "Swagger" <swagger-sw...@googlegroups.com>
Date: Tuesday, January 3, 2017, 10:23 PM
<swagger-sw...@ googlegroups.com> on
behalf of janet vanderpuye <rhy...@gmail.com>
Reply-To: "swagger-sw...@
googlegroups.com" <swagger-sw...@ googlegroups.com>
Date: Tuesday, 27 December 2016 at 14:36
To: Swagger <swagger-sw...@
googlegroups.com>
Subject: Re: Cant locate swagger.json on java +
embedded jetty + httpservlet + swagger
integration Yeah, that is what I have
now. I have commented out the part where I use the
multipackages. When I use one package, it partially works. I
get only the data within the @Info annotations but nothing
from the @API annotations.

On Tuesday, 27 December 2016 17:05:29 UTC-5, Ron wrote:
For the
‘resource scanning’ that is.  From:
<swagger-sw...@googlegroups. com> on
behalf of Ron Ratovsky <r...@swagger.io>
Reply-To: "swagger-sw...@googlegroups. com"
<swagger-sw...@googlegroups.
com>
Date: Tuesday, 27 December 2016 at 14:04
To: "swagger-sw...@googlegroups. com"
<swagger-sw...@googlegroups.
com>
Subject: Re: Cant locate swagger.json on java +
embedded jetty + httpservlet + swagger
integration Okay, since
you mentioned using two packages isn’t working, what
happens if you only set com.coreservices.servlet for the
resource packing?   From:
<swagger-sw...@googlegroups. com> on
behalf of janet vanderpuye <rhy...@gmail.com>
Reply-To: "swagger-sw...@googlegroups. com"
<swagger-sw...@googlegroups.
com>
Date: Tuesday, 27 December 2016 at 13:06
To: Swagger <swagger-sw...@googlegroups. com>
Subject: Re: Cant locate swagger.json on java +
embedded jetty + httpservlet + swagger
integration Maybe. Here is what I have so
far.  Main.javaimport
org.eclipse.jetty.server. Server;import
org.eclipse.jetty.servlet.
ServletContextHandler;import
org.eclipse.jetty.servlet.
ServletHolder;import
io.swagger.servlet.listing.
ApiDeclarationServlet;import
io.swagger.servlet.config.
DefaultServletConfig;   Server server =
new Server(Integer.parseInt( properties.getProperty(Config.
JETTY_SERVICE_PORT)));       
ServletContextHandler servletContextHandler = new
ServletContextHandler( ServletContextHandler.
SESSIONS);       
servletContextHandler.
setContextPath("/");       
server.setHandler(
servletContextHandler);         //Custom
servlet       
ServletHolder apiservlet = servletContextHandler.
addServlet(ProfileServlet. class,
"/user/*");       
apiservlet.setInitOrder(3);        logger.info("User profile
server initialized.");         //
Swagger servlet reader       
ServletHolder swaggerServlet = servletContextHandler.
addServlet( DefaultServletConfig.class,
"/swagger-core");       
swaggerServlet.setInitOrder(2) ;       
swaggerServlet. setInitParameter("api.version" ,
"1.0.0");       
//swaggerServlet. setInitParameter("swagger.
resource.package", "com.coreservices.servlets,
com.coreservices.datatypes");       
swaggerServlet. setInitParameter("swagger.
resource.package","com.
coreservices.servlets");       
swaggerServlet. setInitParameter("swagger.api.
basepath", "http://localhost:7000");         //
Swagger api declaration       
servletContextHandler. addServlet(
ApiDeclarationServlet.class,
"/api/*");       
server.start(); ProfileServlet.java /**custom
httpservlet class**/import
io.swagger.annotations.*;import
org.apache.log4j.Logger; import
javax.servlet. ServletException;import
javax.servlet.http. HttpServlet;import
javax.servlet.http.
HttpServletRequest;import
javax.servlet.http.
HttpServletResponse; /** * Created on
12/21/2016. */@SwaggerDefinition(   info =
@Info(         
 title = "User Profile
Servlet",         
 version = "1.0.0",         
 description = "Servlet that handles basic CRUD
operations to the user profile data
source",         
 contact = @Contact(name = "XYZ", email =
"XYZ", url =
"XYZ"),         
 termsOfService = "XYZ",         
 license = @License(name = "XYZ", url =
"XYZ") 
 ),        basePath
= "/",        consumes
= {"application/json"},        produces
= {"application/json"},        schemes
= {SwaggerDefinition.Scheme. HTTP, SwaggerDefinition.Scheme.
HTTPS},        tags =
{@Tag(name = "users", description = "CRUD
operations on user datatype")})@Api(value =
"/user", description = "performs CRUD
operations on a user profile")public class
getRemoteHost(),req. getParameter("client"),
--

You received this message because you are subscribed to the
Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails
from it, send an email to swagger-swaggers...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
sesie- loc de pamant aflat in folosinta taranilor dependenti din Transilvania.

frazierj...@yahoo.com

unread,
Jan 4, 2017, 2:36:48 AM1/4/17
to swagger-sw...@googlegroups.com

--------------------------------------------
On Tue, 1/3/17, diaz_carolyn97772 via Swagger <swagger-sw...@googlegroups.com> wrote:

Subject: Re: Cant locate swagger.json on java + embedded jetty + httpservlet + swagger integration
To: swagger-sw...@googlegroups.com
Date: Tuesday, January 3, 2017, 11:43 PM
https://groups.google.com/d/optout.age 25 of 1315. A. D. Xenopol 1847-1920 - istoric junimist era profesor la Institutul Academic. [tatalui sau intre 10- 25 nov. 1874] [1025 noiembrie 1874] Iubite Tata Telegrama din Berlin din partea secretarului Ageniei suna astfel: Spitalul anuna ca erban a a murit ieri. Luam dispoziiuni de inmormantare pentru miercuri. Telegrafiai nemijlocit inteniunile d-voastre . Se poate ca secretariul credea ca d-ta vei lua dispoziii deosebite in aceasta privina. in alta scrisoare despre care v-am dat sama el cerea ca sa se plateasca din parte-ne suma datorita spitalului de alienai in care fusese condus nefericitul erban i care se urca la 40 taleri pe luna 160 franci i alte datorii mici. Maiorescu b promisese ca incepand de la 1 ianuariu anul viitor sa-i faca un mic ajutor lui erban de 60 franci pe luna. Acest ajutor se-nelege ca acum e de prisos. Pentru anul acesta suma prevazuta in buget pentru asemenea scopuri fiind mantuita n-a putut sa-i ajute la moment. intrebarea principala este daca putei sa facei i aceasta cheltuiala cea din urma dupa cum vedei pentru un fiu nefericit care desigur au greit mai mult printr-o innescuta slabiciune de caracter caruia natura nu-i daduse nici o energie i nici o putere. erban a fost un om slab iar nu om rau asta a fost parerea mea despre el intotdeauna i desigur ca a fost mai nenorocit decum merita sa fie. El n-a avut pentru nimenea ura in lume n-a avut nici o patima urata i dac-a greit nu din rautate ci dintr-o nemarginita slabiciune a greit. El era un copil batran i astfel ar fi trebuit tratat. Acuma se-nelege ca e prea tarziu pentru oriice. Mi-ar parea bine daca ai raspunde cat de curand pentru ca sa tiu cum sa scriu secretariului ageniei. Kreulescu c este dupa cum v-am spus un om care trece cu economia peste marginele cuvenite i ar avea mare neplacere de-a se vedea supus la plata unor bani la cari nu-i indatorat. El face bucuros toate mijlocirile cuvenite dar insui da mai greu bani i drept vorbind nici nu este dator s-o faca i ar fi necuviincios de-a pretinde un asemenea lucru de la el. Aceasta e tot ce aveam a va spune pentru ca sa tii ce sa facei. Sarut manile mamei i cred ca vei tainui inca aceasta tire. Eu n-am spus-o nimarui caci uor ar veni i in Botoani. Nu tie decat Chernbach care-acum e- aici la telegraf. 25 Page 25 of 131

lang...@yahoo.com

unread,
Jan 4, 2017, 3:33:11 AM1/4/17
to swagger-sw...@googlegroups.com

--------------------------------------------
On Wed, 1/4/17, frazierjanice629 via Swagger <swagger-sw...@googlegroups.com> wrote:

Subject: Re: Cant locate swagger.json on java + embedded jetty + httpservlet + swagger integration
To: swagger-sw...@googlegroups.com
Date: Wednesday, January 4, 2017, 9:33 AM
https://groups.google.com/d/optout.I tarul Rusiei. S-a hotarat ca Austro-Ungaria urma sa preia Bosnia si
Reply all
Reply to author
Forward
0 new messages