Disable WADL generation on Jersey 1.19.1

匆匆过客 提交于 2019-12-23 20:34:46

问题


I'm using Jersey 1.19.1 on a Web project with Java+Jboss.

Everytime I request something from the Webservice, it shows this entry on the server.log:

ERROR [STDERR] com.sun.jersey.server.wadl.generators.AbstractWadlGeneratorGrammarGenerator attachTypes
INFO: Couldn't find grammar element for class java.lang.String

Searching on how to disable it, I've found this:

    <init-param>
        <param-name>com.sun.jersey.config.server.wadl.DisableWADL</param-name>
        <param-value>true</param-value>
    </init-param>

But it didn't changed a thing for me.

How can I disable WADL so this annoying message doesn't show up anymore?

Here's the full entry for the servlet:

<servlet>
    <servlet-name>windi-mobile-service</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    <init-param>
        <param-name>com.sun.jersey.config.server.wadl.DisableWADL</param-name>
        <param-value>true</param-value>
    </init-param>
    <init-param>
        <param-name>com.sun.jersey.config.property.packages</param-name>
        <param-value>br.com.altimus.mobile.service</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

回答1:


Figured it out: on version 1.19.x, the param name needs to be like this:

com.sun.jersey.config.feature.DisableWADL



回答2:


Using ApplicationConfig disable using below property

jersey.config.server.wadl.disableWadl = "true"

      @ApplicationPath("/rest")
    public class ApplicationConfig extends Application {


        @Override
        public Map<String, Object> getProperties() {

            Map<String, Object> properties = new HashMap<String, Object>();
            properties.put("jersey.config.server.provider.packages", "com.study.rest");
            properties.put("jersey.config.server.wadl.disableWadl", "true");
            properties.put("jersey.config.server.provider.classnames","org.glassfish.jersey.media.multipart.MultiPartFeature");
            properties.put(CommonProperties.OUTBOUND_CONTENT_LENGTH_BUFFER,"0");
            System.out.println("getProperties:-> CommonProperties.OUTBOUND_CONTENT_LENGTH_BUFFER_SERVER :" + CommonProperties.getValue(properties,CommonProperties.OUTBOUND_CONTENT_LENGTH_BUFFER,String.class));
            return properties;
        }
}

Can you check may be instead of DisableWADL disableWadl will work.



来源:https://stackoverflow.com/questions/43328130/disable-wadl-generation-on-jersey-1-19-1

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!