Swagger没有在Websphere 8.5上加载类模型类

时间:2015-04-09 15:56:17

标签: scala websphere swagger websphere-8

当我在我的WAS实例上运行时,它不会为我生成JSON模型。在我的日志中,我得到了这个:

(com.wordnik.swagger.core.SwaggerContext) - Class com.foo.bar.model.TestRequest not found in classLoader

我得到的UI是这样的: enter image description here

这是我的服务代码:

@Path("/testServiceUnit")
@Api(
        value = "/testServiceUnit",
        description = "Swagger Unit Test Service")
public class TestServiceUnit {
    /**
     * Simple Post test
     * 
     * @param tReq
     *            Request sent via post
     * @return stub response
     */
    @POST
    @Path("/tstPost")
    @ApiOperation(
            value = "Check Reference",
            notes = "code to do check cross reference for the object starts",
            response = TestResponse.class)
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public Response checkReference(TestRequest tReq) {

        TestResponse tresp = new TestResponse();
        tresp.setTestResponder("Hello");
        return Response.status(200).entity(tresp).build();
    }
}

我已经将问题缩小到swagger中的这段代码:

package com.wordnik.swagger.core

import collection.mutable.ListBuffer
import org.slf4j.{ LoggerFactory, Logger }

object SwaggerContext {
  private val LOGGER = LoggerFactory.getLogger("com.wordnik.swagger.core.SwaggerContext")

  var suffixResponseFormat = true

  private val classLoaders = ListBuffer.empty[ClassLoader]
  registerClassLoader(this.getClass.getClassLoader)

  def registerClassLoader(cl: ClassLoader) = this.classLoaders += cl

  def loadClass(name: String) = {
    var cls: Class[_] = null
    val itr = classLoaders.reverse.iterator
    while (cls == null && itr.hasNext) {
      try {
        cls = Class.forName(name.trim, true, itr.next)
      } catch {
        case e: ClassNotFoundException => {
          LOGGER.debug("Class %s not found in classLoader".format(name))
        }
      }
    }
    if (cls == null)
      throw new ClassNotFoundException("class " + name + " not found")
    cls
  }
}

现在我已经在两个模块模式下加载WAS,其中一个耳朵中的每个模块都有自己的类加载器和应用程序模式,它在整个EAR文件中使用一个类加载器。既不起作用,也不起作用。我也尝试过scala 2.11版本,结果相同。我没有尝试过摇摇晃晃的1.5,因为它看起来像是改变了很多代码而且我没心情在这里重建一切。我的wAS设置为parentfirst类加载,parentlast导致整个应用程序无法加载。我在这里结束了,我不知道还有什么可以尝试。我唯一能想到的是他们在Websphere中构建的IBM JVM做了一些棘手的事情(想象一下),但我不能为我的生活弄清楚为什么这不起作用。有人有什么想法吗?

0 个答案:

没有答案
相关问题