Trying to integrate Apache Wink with IBM-Ecommerce

387 views
Skip to first unread message

Mahesh Vipat

unread,
Nov 21, 2014, 1:52:02 PM11/21/14
to swagger-sw...@googlegroups.com
I am trying to integrate Apache Wink with IBM-Ecommerce project. I followed the instructions as specified on this link https://groups.google.com/forum/#!searchin/swagger-swaggersocket/Swagger$20with$20wink/swagger-swaggersocket/uA3Glc2JMXA/RGd1D52Vn4AJ but I am getting below exception

[11/21/14 12:44:44:331 CST] 00000036 ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [WC] [/wcs/resources] [JAX-RS Servlet]: Initialization successful.
[11/21/14 12:44:44:402 CST] 00000036 ServletWrappe E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E: Uncaught exception created in one of the service methods of the servlet JAX-RS Servlet in application WC. Exception created : java.lang.IllegalArgumentException: class javax.ws.rs.core.Application must be an interface
at org.apache.wink.common.internal.registry.ContextAccessor.getContextFromAccessor(ContextAccessor.java:69)
at org.apache.wink.common.internal.registry.ContextAccessor.getContext(ContextAccessor.java:49)
at org.apache.wink.server.internal.registry.ServerInjectableFactory$ServerContextParam.getValue(ServerInjectableFactory.java:154)
at org.apache.wink.common.internal.registry.InjectableFactory.instantiate(InjectableFactory.java:68)

and here is my configuration 

web.xml ---

<servlet>
   <servlet-name>DefaultJaxrsConfig</servlet-name>
   <servlet-class>com.wordnik.swagger.jaxrs.config.DefaultJaxrsConfig</servlet-class>
  <load-on-startup>2</load-on-startup>
  <init-param>
    <param-name>swagger.resource.package</param-name>
    <param-value>com.xxx.apiservices</param-value>
  </init-param>
  <init-param>
    <param-name>swagger.api.basepath</param-name>
    <param-value>http://localhost/wcs/resources/api-docs</param-value>
  </init-param>
  <init-param>
    <param-name>api.version</param-name>
    <param-value>1.0.0</param-value>
  </init-param>
</servlet>
<servlet>
<description></description>
<display-name></display-name>
<icon>
<small-icon></small-icon>
<large-icon></large-icon>
</icon>
<servlet-name>JAX-RS Servlet</servlet-name>
<servlet-class>org.apache.wink.server.internal.servlet.RestServlet</servlet-class>
<init-param>
<param-name>applicationConfigLocation</param-name>
<param-value>/WEB-INF/config/providers-ext.properties;/WEB-INF/config/providers.properties;/WEB-INF/config/resources-ext.properties;/WEB-INF/config/resources.properties</param-value>
</init-param>
<init-param>
<param-name>deploymentConfiguration</param-name>
<param-value>com.ibm.commerce.foundation.rest.config.CommerceDeploymentConfiguration</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>JAX-RS Servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

I added below 3 lines to resources-ext.properties

com.wordnik.swagger.jaxrs.listing.ApiDeclarationProvider
com.wordnik.swagger.jaxrs.listing.ApiListingResourceJSON
com.wordnik.swagger.jaxrs.listing.ResourceListingProvider

AddressResource class ---

@Api(value = "/v{version}/user/my/addresses", description = "Address")
@Path("/v{version}/user/my/addresses")
public class AddressResource extends BaseAccountResource {

@POST
@Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@AuthenticationValidationRequired
@ApiOperation(httpMethod = "POST", value = "Resource to save Address", 
 response = Response.class,responseContainer = "Set", nickname="addAddress")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid data supplied"),
@ApiResponse(code = 404, message = "Address not found") })
@ApiImplicitParams({
@ApiImplicitParam(name = "rawData", value = "Raw Data", required = true, dataType = "string", paramType = "body")
})
public Response addAddress(String rawData) {
AccountProcessorType accountProcessorType = AccountProcessorType.ADD_ADDRESS;
Response response = process(rawData, accountProcessorType);
return response;
}
}

Attached is the screen shot of all the dependent jars included in the classpath.
swagger-jaxrs-jars.png

Mahesh Vipat

unread,
Nov 21, 2014, 3:31:01 PM11/21/14
to swagger-sw...@googlegroups.com
Sorry correction

I am trying to integrate Swagger with Apache Wink + IBM-Ecommerce project.

Ron

unread,
Nov 24, 2014, 10:55:04 AM11/24/14
to swagger-sw...@googlegroups.com
The error you're getting doesn't seem related to Swagger.

I imagine you'll get it if you remove the swagger-related files as well.

Perhaps if you shared the full web.xml it would help finding the issue.

On 21 November 2014 at 22:31, Mahesh Vipat <mvi...@gmail.com> wrote:
Sorry correction

I am trying to integrate Swagger with Apache Wink + IBM-Ecommerce project.

--
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.

Mahesh Vipat

unread,
Nov 24, 2014, 12:53:57 PM11/24/14
to swagger-sw...@googlegroups.com
No the error is related to swagger and BTW this was working fine with Swagger Servlet configuration. Changed some configuration 

Added new class SwaggerJaxrsConfig 

import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServlet;

import com.homedepot.apiservices.platform.logger.GenericLogger;
import com.homedepot.sa.el.restful.services.common.LogFactory;
import com.wordnik.swagger.config.ConfigFactory;
import com.wordnik.swagger.config.ScannerFactory;
import com.wordnik.swagger.config.SwaggerConfig;
import com.wordnik.swagger.jaxrs.config.DefaultJaxrsScanner;
import com.wordnik.swagger.jaxrs.reader.DefaultJaxrsApiReader;
import com.wordnik.swagger.reader.ClassReaders;

public class SwaggerJaxrsConfig extends HttpServlet {
private static final GenericLogger LOGGER = LogFactory.getInstance().getLogger(SwaggerJaxrsConfig.class);

private static final long serialVersionUID = 6599857044839801800L;

public void init(ServletConfig servletConfig) {
try {
super.init(servletConfig);
SwaggerConfig swaggerConfig = new SwaggerConfig();
ConfigFactory.setConfig(swaggerConfig);
swaggerConfig.setBasePath("http://localhost/wcs/resources/api-docs");
swaggerConfig.setApiVersion("1.0");
ScannerFactory.setScanner(new DefaultJaxrsScanner());
ClassReaders.setReader(new DefaultJaxrsApiReader());
} catch (Exception e) {
LOGGER.error("Failed to configure swagger", e);
}
}
}
-------------------------------------------------------------------------
web.xml

<servlet>
<servlet-name>SwaggerJaxrsConfig</servlet-name>
<servlet-class>com.xxx.SwaggerJaxrsConfig</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>

<servlet>
<servlet-name>JAX-RS Servlet</servlet-name>
<servlet-class>org.apache.wink.server.internal.servlet.RestServlet</servlet-class>
<init-param>
<param-name>applicationConfigLocation</param-name>
<param-value>/WEB-INF/config/providers-ext.properties;/WEB-INF/config/providers.properties;/WEB-INF/config/resources-ext.properties;/WEB-INF/config/resources.properties</param-value>
</init-param>
<init-param>
            <param-name>javax.ws.rs.Application</param-name>
            <param-value>com.xxx.apiservices.ApplicationConfig</param-value>
        </init-param>
<init-param>
<param-name>deploymentConfiguration</param-name>
<param-value>com.ibm.commerce.foundation.rest.config.CommerceDeploymentConfiguration</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>JAX-RS Servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
----------------------------------------
Class ApplicationConfig

@javax.ws.rs.ApplicationPath("api-docs")
public class ApplicationConfig extends Application {

/**
*/
public ApplicationConfig() {
// TODO Auto-generated constructor stub
}

/* (non-Javadoc)
* @see javax.ws.rs.core.Application#getClasses()
*/
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> classes = new HashSet<Class<?>>();

        //Swagger classes
        classes.add(com.wordnik.swagger.jaxrs.listing.ApiDeclarationProvider.class);
        classes.add(com.wordnik.swagger.jaxrs.listing.ApiListingResourceJSON.class);
        classes.add(com.wordnik.swagger.jaxrs.listing.ResourceListingProvider.class);

        classes.add(AddressResource.class);
        classes.add(CartResource.class);
        classes.add(CartResourceV1.class);
        classes.add(AuthorizationResource.class);
return classes;
}
}

-------------------------------------------
@Api(value = "/v{version}/user/my/addresses", description = "Address")
@Path("/v{version}/user/my/addresses")
public class AddressResource extends BaseAccountResource {
private static final GenericLogger LOGGER = LogFactory.getInstance().getLogger(AddressResource.class);

/**
* Adds the address for a user
* @param rawData
* @return
*/
}

Ron

unread,
Nov 24, 2014, 2:12:52 PM11/24/14
to swagger-sw...@googlegroups.com
Why do you use @javax.ws.rs.ApplicationPath("api-docs") on the Application class?

And if you have an Application class (with the ApplicationPath) and org.apache.wink.server.internal.servlet.RestServlet in your web.xml, you're leading to everything loading twice, and that could be your problem.

--

Mahesh Vipat

unread,
Nov 24, 2014, 2:15:41 PM11/24/14
to swagger-sw...@googlegroups.com
Below is the web.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app id="WebApp_ID" metadata-complete="true" version="2.4"

<display-name>Rest</display-name>

<servlet>
<description />
<display-name>CompositionRequestServlet</display-name>
<icon>
<small-icon />
<large-icon />
</icon>
<servlet-name>CompositionRequestServlet</servlet-name>
<servlet-class>
com.ibm.commerce.messaging.composer.servlet.CompositionRequestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CompositionRequestServlet</servlet-name>
<url-pattern>/IBM.WC.Compose/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>SimpleCaptchaServlet</servlet-name>
<display-name>SimpleCaptchaServlet</display-name>
<servlet-class>nl.captcha.servlet.SimpleCaptchaServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SimpleCaptchaServlet</servlet-name>
<url-pattern>/Captcha</url-pattern>
</servlet-mapping>
<servlet>
<description></description>
<display-name>Struts</display-name>
<icon>
<small-icon></small-icon>
<large-icon></large-icon>
</icon>
<servlet-name>Atom Formatting JSP Mapping Servlet</servlet-name>
<servlet-class>com.ibm.commerce.struts.ECActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml,/WEB-INF/struts-extension.xml</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>validate</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>configFactory</param-name>
<param-value>com.ibm.commerce.struts.config.UpdatableModuleConfigFactory</param-value>
</init-param>
<init-param>
<param-name>webpath</param-name>
<param-value>/struts</param-value>
</init-param>
<init-param>
<param-name>isStoreServlet</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>isRestServlet</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Atom Formatting JSP Mapping Servlet</servlet-name>
<url-pattern>/struts/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>SwaggerJaxrsConfig</servlet-name>
<servlet-class>com.xxx.SwaggerJaxrsConfig</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<filter>
<icon />
<filter-name>CompositionFilter</filter-name>
<filter-class>
com.ibm.commerce.messaging.composer.servlet.CompositionFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CompositionFilter</filter-name>
<servlet-name>Atom Formatting JSP Mapping Servlet</servlet-name>
</filter-mapping>
<servlet>
<description></description>
<display-name></display-name>
<icon>
<small-icon></small-icon>
<large-icon></large-icon>
</icon>
<servlet-name>JAX-RS Servlet</servlet-name>
<servlet-class>org.apache.wink.server.internal.servlet.RestServlet</servlet-class>
<init-param>
<param-name>applicationConfigLocation</param-name>
<param-value>/WEB-INF/config/providers-ext.properties;/WEB-INF/config/providers.properties;/WEB-INF/config/resources-ext.properties;/WEB-INF/config/resources.properties</param-value>
</init-param>
<init-param>
            <param-name>javax.ws.rs.Application</param-name>
            <param-value>com.xxx.apiservices.ApplicationConfig</param-value>
        </init-param>
<init-param>
<param-name>deploymentConfiguration</param-name>
<param-value>com.ibm.commerce.foundation.rest.config.CommerceDeploymentConfiguration</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>JAX-RS Servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>KillSwitch</servlet-name>
<servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.xxx.sa.el.restful.services.KillSwitchesConfig</param-value>
</init-param>
<init-param>
<param-name>requestProcessorAttribute</param-name>
<param-value>requestProcessorAttribute_KillSwitches</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>LoadStoreInfo</servlet-name>
<servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.xxx.sa.el.restful.services.StoreInfoConfig</param-value>
</init-param>
<init-param>
<param-name>requestProcessorAttribute</param-name>
<param-value>requestProcessorAttribute_LoadStoreInfo</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>AddressInfo</servlet-name>
<servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.xxx.sa.el.restful.services.AddressInfoConfig</param-value>
</init-param>
<init-param>
<param-name>requestProcessorAttribute</param-name>
<param-value>requestProcessorAttribute_AddressInfo</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>SurveyInfo</servlet-name>
<servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.xxx.sa.el.restful.services.SurveyInfoConfig</param-value>
</init-param>
<init-param>
<param-name>requestProcessorAttribute</param-name>
<param-value>requestProcessorAttribute_SurveyInfo</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>SubscriptionInfo</servlet-name>
<servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.xxx.sa.el.restful.services.SubscrGroupAndSubgroupConfig</param-value>
</init-param>
<init-param>
<param-name>requestProcessorAttribute</param-name>
<param-value>requestProcessorAttribute_SubscriptionInfo</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>AttributeService</servlet-name>
<servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.xxx.sa.el.restful.services.AttributeServiceConfig</param-value>
</init-param>
<init-param>
<param-name>requestProcessorAttribute</param-name>
<param-value>requestProcessorAttribute_AttributeService</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>PromotionService</servlet-name>
<servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.xxx.sa.el.restful.services.PromotionServiceConfig</param-value>
</init-param>
<init-param>
<param-name>requestProcessorAttribute</param-name>
<param-value>requestProcessorAttribute_PromotionService</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>RelatedItemsService</servlet-name>
<servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.xxx.sa.el.restful.services.RelatedItemsServiceConfig</param-value>
</init-param>
<init-param>
<param-name>requestProcessorAttribute</param-name>
<param-value>requestProcessorAttribute_RelatedItemsService</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>ApplianceSkuCatService</servlet-name>
<servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.xxx.sa.el.restful.services.ApplianceSkuCatServiceConfig</param-value>
</init-param>
<init-param>
<param-name>requestProcessorAttribute</param-name>
<param-value>requestProcessorAttribute_ApplianceSkuCatService</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>CheckoutAPIServices</servlet-name>
<servlet-class>
com.xxx.apiservices.authentication.common.controller.ApiServlet</servlet-class>

<init-param>
<param-name>requestProcessorAttribute</param-name>
<param-value>requestProcessorAttribute_CheckoutAPIServices</param-value>
</init-param>
<init-param>
<param-name>propertiesLocation</param-name>
<param-value>/WEB-INF/config/handler.properties</param-value>
</init-param>
<init-param>
<param-name>applicationConfigLocation</param-name>
<param-value>/WEB-INF/config/providers-ext.properties;/WEB-INF/config/providers.properties;/WEB-INF/config/resources-ext.properties;/WEB-INF/config/resources.properties</param-value>
</init-param>
<init-param>
<param-name>sslSecurityConfigLocation</param-name>
<param-value>/WEB-INF/config/com.ibm.commerce.rest-ext/wc-rest-security.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<filter>
<icon />
<filter-name>SecurityFilter</filter-name>
<filter-class>com.xxx.sa.el.security.filter.SecurityFilter</filter-class>
<init-param>
<param-name>enabled</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>RedirctView</param-name>
<param-value>GenericApplicationError</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>SecurityFilter</filter-name>
<servlet-name>CheckoutAPIServices</servlet-name>
</filter-mapping>
<servlet>
<servlet-name>ProductDataService</servlet-name>
<servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.xxx.sa.el.restful.services.ProductDataServiceConfig</param-value>
</init-param>
<init-param>
<param-name>requestProcessorAttribute</param-name>
<param-value>requestProcessorAttribute_ProductDataService</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>ShippingService</servlet-name>
<servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.xxx.sa.el.restful.services.ShippingServiceConfig</param-value>
</init-param>
<init-param>
<param-name>requestProcessorAttribute</param-name>
<param-value>requestProcessorAttribute_ShippingService</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>ShippingReturnService</servlet-name>
<servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.xxx.sa.el.restful.services.ShippingReturnServiceConfig</param-value>
</init-param>
<init-param>
<param-name>requestProcessorAttribute</param-name>
<param-value>requestProcessorAttribute_ShippingReturnService</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>KillSwitch</servlet-name>
<url-pattern>/killswitch/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>LoadStoreInfo</servlet-name>
<url-pattern>/LoadStoreInfo/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AddressInfo</servlet-name>
<url-pattern>/AddressInfo/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SurveyInfo</servlet-name>
<url-pattern>/SurveyInfo/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SubscriptionInfo</servlet-name>
<url-pattern>/SubscriptionInfo/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AttributeService</servlet-name>
<url-pattern>/AttributeService/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>PromotionService</servlet-name>
<url-pattern>/PromotionService/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>RelatedItemsService</servlet-name>
<url-pattern>/RelatedItemsService/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ApplianceSkuCatService</servlet-name>
<url-pattern>/ApplianceSkuCatService/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>CheckoutAPIServices</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ProductDataService</servlet-name>
<url-pattern>/ProductDataService/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ShippingService</servlet-name>
<url-pattern>/ShippingService/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ShippingReturnService</servlet-name>
<url-pattern>/ShippingReturnService/*</url-pattern>
</servlet-mapping>
<filter>
<icon />
<filter-name>RuntimeServletFilter</filter-name>
<filter-class>com.ibm.commerce.webcontroller.RuntimeServletFilter</filter-class>
<init-param>
<param-name>ServletName</param-name>
<param-value>Stores</param-value>
</init-param>
</filter>
<error-page>
<error-code>500</error-code>
<location>/jsp/commerce/foundation/restricted/Server500.jsp</location>
</error-page>
</web-app>

Ron

unread,
Nov 24, 2014, 2:22:32 PM11/24/14
to swagger-sw...@googlegroups.com
That's different than the original web.xml you posted.

And I don't know what's included in the <param-value>/WEB-INF/config/providers-ext.properties;/WEB-INF/config/providers.properties;/WEB-INF/config/resources-ext.properties;/WEB-INF/config/resources.properties</param-value> files.

I still don't see how this is a Swagger issue. Nothing in the original exception mentions any of the Swagger classes. This is purely a Wink configuration problem.



Mahesh Vipat

unread,
Nov 28, 2014, 11:53:44 AM11/28/14
to swagger-sw...@googlegroups.com
I am attaching the code. The other files in the web.xml for list 

<init-param>
<param-name>applicationConfigLocation</param-name>
<param-value>/WEB-INF/config/providers-ext.properties;/WEB-INF/config/providers.properties;/WEB-INF/config/resources-ext.properties;/WEB-INF/config/resources.properties</param-value>
</init-param>

are similar to providers.properties. When I hit the url http://localhost/wcs/resources/api-docs I get below in the logs and a blank response

[11/28/14 10:52:35:313 CST] 00000047 ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [WC] [/wcs/resources] [JAX-RS Servlet Api Docs]: Initialization successful. 


ApplicationConfig.java
AuthorizationResource.java
providers.properties
SwaggerJaxrsConfig.java
web.xml

Mahesh Vipat

unread,
Dec 1, 2014, 9:39:33 AM12/1/14
to swagger-sw...@googlegroups.com
Hi,

I tried multiple options to get Swagger working, but I am not successful yet. I commented out the block 

<!-- servlet>
<description></description>
<display-name></display-name>
<icon>
<small-icon></small-icon>
<large-icon></large-icon>
</icon>
<servlet-name>JAX-RS Servlet</servlet-name>
<servlet-class>org.apache.wink.server.internal.servlet.RestServlet</servlet-class>
<init-param>
<param-name>applicationConfigLocation</param-name>
<param-value>/WEB-INF/config/providers-ext.properties;/WEB-INF/config/providers.properties;/WEB-INF/config/resources-ext.properties;/WEB-INF/config/resources.properties</param-value>
</init-param>
<init-param>
<param-name>deploymentConfiguration</param-name>
<param-value>com.ibm.commerce.foundation.rest.config.CommerceDeploymentConfiguration</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>JAX-RS Servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping -->

Updated the Servlet class for below block from org.apache.wink.server.internal.servlet.RestServlet to com.ibm.websphere.jaxrs.server.IBMRestServlet

<servlet>
<description></description>
<display-name></display-name>
<icon>
<small-icon></small-icon>
<large-icon></large-icon>
</icon>
<servlet-name>JAX-RS Servlet Api Docs</servlet-name>
<servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
<init-param>
            <param-name>javax.ws.rs.Application</param-name>
            <param-value>com.homedepot.apiservices.ApplicationConfig</param-value>
        </init-param>
<init-param>
<param-name>requestProcessorAttribute</param-name>
<param-value>requestProcessorAttribute_Swagger</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>JAX-RS Servlet Api Docs</servlet-name>
<url-pattern>/api-docs/*</url-pattern>
</servlet-mapping>

Also in my earlier post for the class ApplicationConfig below are the contents of method getClasses()

        Set<Class<?>> classes = new HashSet<Class<?>>();

        //Swagger classes
classes.add(com.wordnik.swagger.jaxrs.listing.ApiListingResource.class);
        classes.add(com.wordnik.swagger.jaxrs.listing.ApiDeclarationProvider.class);
        classes.add(com.wordnik.swagger.jaxrs.listing.ApiListingResourceJSON.class);
        classes.add(com.wordnik.swagger.jaxrs.listing.ResourceListingProvider.class);

        classes.add(AddressResource.class);
        classes.add(CartResource.class);
        classes.add(CartResourceV1.class);
        classes.add(AuthorizationResource.class);
return classes;

Thanks
Mahesh

Ron

unread,
Dec 2, 2014, 10:13:22 AM12/2/14
to swagger-sw...@googlegroups.com
There has been so many changes that I can't follow. I'm not sure what the current state of the code is and what is the current problem. I really need more details.


--

Mahesh Vipat

unread,
Dec 2, 2014, 11:22:42 AM12/2/14
to swagger-sw...@googlegroups.com
Attached are the latest classes and configuration files.
ApplicationConfig.java
AuthorizationResource.java
providers.properties
SwaggerJaxrsConfig.java
web.xml

Ron

unread,
Dec 2, 2014, 11:57:35 AM12/2/14
to swagger-sw...@googlegroups.com
That doesn't tell me what the problem is.

On 2 December 2014 at 18:22, Mahesh Vipat <mvi...@gmail.com> wrote:
Attached are the latest classes and configuration files.

--

Mahesh Vipat

unread,
Dec 2, 2014, 12:48:15 PM12/2/14
to swagger-sw...@googlegroups.com
I get a 404 response code  when I access http://localhost/wcs/resources/api-docs back with following message printed in the logs

[11/28/14 10:52:35:313 CST] 00000047 ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [WC] [/wcs/resources] [JAX-RS Servlet Api Docs]: Initialization successful.

Ron

unread,
Dec 2, 2014, 1:10:04 PM12/2/14
to swagger-sw...@googlegroups.com
First, remove this from the web.xml, it is not required:
	<servlet-mapping>
		<servlet-name>JAX-RS Servlet Api Docs</servlet-name>
		<url-pattern>/api-docs</url-pattern>
	</servlet-mapping>

Second, what is the context root of that application? For example, how do you reach any of these classes?
classes.add(AddressResource.class);
classes.add(CartResource.class);
classes.add(CartResourceV1.class);
classes.add(AuthorizationResource.class);

The api-docs should be available directly under the same context root.


On 2 December 2014 at 19:48, Mahesh Vipat <mvi...@gmail.com> wrote:
I get a 404 response code  when I access http://localhost/wcs/resources/api-docs back with following message printed in the logs

[11/28/14 10:52:35:313 CST] 00000047 ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [WC] [/wcs/resources] [JAX-RS Servlet Api Docs]: Initialization successful.

--

Mahesh Vipat

unread,
Dec 2, 2014, 2:56:24 PM12/2/14
to swagger-sw...@googlegroups.com
Still getting 404 response with following printed in the browser

Error 404: SRVE0190E: File not found: /api-docs

If I remove

<servlet-mapping>
		<servlet-name>JAX-RS Servlet Api Docs</servlet-name>
		<url-pattern>/api-docs</url-pattern>
	</servlet-mapping>

how the documentation automatically becomes available under /api-docs?

The example of api with different path are as below

http://localhost/wcs/resources/api/v2/user/my/authorization/guestUserToken
http://localhost/wcs/resources/api/v2/user/my/addresses
http://localhost/wcs/resources/api/v1/user/my/addresses

I am attaching AddressResource.java.



AddressResource.java

Ron

unread,
Dec 2, 2014, 3:40:14 PM12/2/14
to swagger-sw...@googlegroups.com
The resource listing is a regular JAX-RS resource which is annotated with @Path("/api-docs"). Since you add it as a resource, it would just be deployed to that path.

Based on the samples above, you should try http://localhost/wcs/resources/api/api-docs

Mahesh Vipat

unread,
Dec 2, 2014, 5:32:57 PM12/2/14
to swagger-sw...@googlegroups.com
It didn't work either.

Mahesh Vipat

unread,
Dec 3, 2014, 10:39:02 AM12/3/14
to swagger-sw...@googlegroups.com
>The resource listing is a regular JAX-RS resource which is annotated with @Path("/api-docs"). Since you add it as a resource, it would just be deployed to that path.

Is this something you see in my code or it is part of Swagger libs.

Ron

unread,
Dec 3, 2014, 11:02:36 AM12/3/14
to swagger-sw...@googlegroups.com
It's part of the Swagger libs.

Do you see anything related to Swagger in your startup logs?

On 3 December 2014 at 17:39, Mahesh Vipat <mvi...@gmail.com> wrote:
>The resource listing is a regular JAX-RS resource which is annotated with @Path("/api-docs"). Since you add it as a resource, it would just be deployed to that path.

Is this something you see in my code or it is part of Swagger libs.

--

Mahesh Vipat

unread,
Dec 3, 2014, 5:22:41 PM12/3/14
to swagger-sw...@googlegroups.com
Hi Ron,

I do not see anything in logs related to Swagger. The IBM commerce is configured in such a way that it is a combination of multiple projects. If I need to access a resource/project then I need to access it over the path /wcs/resources. The api services are accessed such as for address as below


servlet mapping from web.xml

<servlet-mapping>
<servlet-name>CheckoutAPIServices</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>

and then uses the path from the AddressResource

@Path("/v{version}/user/my/addresses")
@Api(value = "/v{version}/user/my/addresses", description = "Address")
public class AddressResource extends BaseAccountResource {

Is there any way we can debug this? I increased the log level but it didn't print anything related to Swagger when the /api-docs was accessed. In browser I got 404 error message.

Ron

unread,
Dec 4, 2014, 10:19:10 AM12/4/14
to swagger-sw...@googlegroups.com
Do you see in the logs log.info("Swagger classes added"); and         log.info("API classes added");
 from your ApplicationConfig class?

Mahesh Vipat

unread,
Dec 5, 2014, 6:02:37 PM12/5/14
to swagger-sw...@googlegroups.com
Hi Ron,

Here is the snippet of log

[12/5/14 16:52:59:656 CST] 00000018 ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [WC] [/wcs/resources] [ProductDataService]: Initialization successful.
[12/5/14 16:52:59:718 CST] 00000018 SwaggerJaxrsC I   Starting swagger
[12/5/14 16:53:00:834 CST] 00000018 SwaggerJaxrsC I   Path changed
[12/5/14 16:53:00:885 CST] 00000018 SwaggerJaxrsC I   Ending swagger
[12/5/14 16:53:00:885 CST] 00000018 ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [WC] [/wcs/resources] [SwaggerJaxrsConfig]: Initialization successful.
[12/5/14 16:53:00:987 CST] 00000018 ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [WC] [/wcs/resources] [AttributeService]: Initialization successful.
[12/5/14 16:53:01:104 CST] 00000018 ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [WC] [/wcs/resources] [ShippingReturnService]: Initialization successful.
[12/5/14 16:53:01:243 CST] 00000018 ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [WC] [/wcs/resources] [PromotionService]: Initialization successful.
[12/5/14 16:53:01:313 CST] 00000018 ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [WC] [/wcs/resources] [KillSwitch]: Initialization successful.
[12/5/14 16:53:01:572 CST] 00000018 ApiServiceUti I   Will be loading binding by name : {0}accesslevels_1_0
[12/5/14 16:53:01:592 CST] 00000018 ApiServiceUti I   Unmarshalling the XML to object...
[12/5/14 16:53:01:648 CST] 00000018 ApiServiceUti I   Done, time taken to unmarshal XML = {0} ms.76
[12/5/14 16:53:01:655 CST] 00000018 AccessLevelCo I   API Token Access Level Config Initialized
[12/5/14 16:53:05:750 CST] 00000018 SSLResourceCo I   Loaded SSL API Resource config from location :/WEB-INF/config/com.ibm.commerce.rest-ext/wc-rest-security.xml
[12/5/14 16:53:05:750 CST] 00000018 ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [WC] [/wcs/resources] [CheckoutAPIServices]: Initialization successful.
[12/5/14 16:53:05:761 CST] 00000018 SwaggerApiSer I   SwaggerApiServlet init() called
[12/5/14 16:53:05:803 CST] 00000018 ApplicationCo I   getClasses() called
[12/5/14 16:53:05:813 CST] 00000018 ApplicationCo I   Swagger classes added
[12/5/14 16:53:05:813 CST] 00000018 ApplicationCo I   API classes added
[12/5/14 16:53:05:976 CST] 00000018 ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [WC] [/wcs/resources] [JAX-RS Servlet Api Docs]: Initialization successful.
[12/5/14 16:53:06:078 CST] 00000018 ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [WC] [/wcs/resources] [ApplianceSkuCatService]: Initialization successful.

and I do see those 2 message.

Ron

unread,
Dec 7, 2014, 5:43:08 AM12/7/14
to swagger-sw...@googlegroups.com
Hi Mahesh,

I'm sorry, but I'm pretty much out of ideas. You're loading the correct Swagger resources, but you're still getting 404.
This can be due to two reasons:
  1. We can't pinpoint the context root of the application (the /api-docs will be directly under it).
  2. There's some additional container configuration that blocks access to the /api-docs.

The problem is that you're using a commercial product to which I don't have access, and as such I can't test it locally.

Not really sure how to proceed with that.


--
Reply all
Reply to author
Forward
0 new messages