Jersey EntityFilteringFeature NoClassDefFoundError

时间:2016-06-22 07:52:01

标签: java jersey noclassdeffounderror

我有一个问题,真的很烦我。我无法在任何地方找到答案。我没有使用maven。我跟着this,看起来很简单。

使用: JDK 8, 泽西岛2.5.1(包括jersey-media-moxy-2.5.1.jar)

应用程序配置:

@javax.ws.rs.ApplicationPath("webresources")
public class ApplicationConfig extends ResourceConfig {

public ApplicationConfig() throws MalformedURLException, ClassNotFoundException {
    ResourceConfig.forApplication(new ApplicationConfig2());
    new ResourceConfig()
        // Set entity-filtering scope via configuration.
        .property(EntityFilteringFeature.ENTITY_FILTERING_SCOPE, new Annotation[] {Protect.Factory.get()})
        // Register the EntityFilteringFeature.
        .register(EntityFilteringFeature.class);
}

class ApplicationConfig2 extends Application {
    @Override
    public Set<Class<?>> getClasses() {
        Set<Class<?>> resources = new java.util.HashSet<Class<?>>();
        addRestResourceClasses(resources);
        return resources;
    }

    /**
     * Do not modify addRestResourceClasses() method.
     * It is automatically populated with
     * all resources defined in the project.
     * If required, comment out calling this method in getClasses().
     */
    private void addRestResourceClasses(Set<Class<?>> resources) {
        resources.add(lensworld.application.Application.class);
        resources.add(lensworld.languages.rest.LanguagesREST.class);
        resources.add(lensworld.restservices.AbstractRestService.class);
        resources.add(lensworld.restservices.CompaniesREST.class);
        resources.add(lensworld.restservices.Diagnose.class);
        resources.add(lensworld.restservices.MailQueueREST.class);
        resources.add(lensworld.restservices.MailQueueSettingsREST.class);
        resources.add(lensworld.restservices.MailTemplatesREST.class);
        resources.add(lensworld.restservices.MailTypesREST.class);
        resources.add(lensworld.restservices.MailUrgenciesREST.class);
        resources.add(lensworld.restservices.MessagesREST.class);
        resources.add(lensworld.restservices.Products.class);
        resources.add(lensworld.restservices.SecurityREST.class);
        resources.add(lensworld.restservices.SiteREST.class);
        resources.add(lensworld.restservices.UserREST.class);
        resources.add(lensworld.search.rest.SearchREST.class);
        resources.add(lensworld.security.RESTRequestFilter.class);
        resources.add(lensworld.security.RESTResponseFilter.class);
        resources.add(lensworld.translations.rest.TranslationsREST.class);

    }
}
}

尝试加载注释类工厂时显示问题

@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@EntityFiltering
public @interface Protect {
/**
 * Factory class for creating instances of {@code ProjectDetailedView} annotation.
 */
public static class Factory
                    extends AnnotationLiteral<Protect>
                    implements Protect {

    private Factory() {
    }

    public static Protect get() {
        return new Factory();
    }
}
}

堆栈跟踪:

jun 22, 2016 9:38:21 AM org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
MultiException stack 1 of 1
java.lang.NoClassDefFoundError: lensworld/data/annotations/Protect$Factory
at lensworld.application.ApplicationConfig.<init>(ApplicationConfig.java:31)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1117)
at org.jvnet.hk2.internal.Utilities.justCreate(Utilities.java:867)
at org.jvnet.hk2.internal.ServiceLocatorImpl.create(ServiceLocatorImpl.java:814)
at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:906)
at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:898)
at org.glassfish.jersey.server.ApplicationHandler.createApplication(ApplicationHandler.java:317)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:296)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:311)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:169)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:359)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:884)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:134)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)

任何想法?

0 个答案:

没有答案