Giter VIP home page Giter VIP logo

resteasy-spring-boot's Introduction

Build Status Codacy Badge Codacy Coverage Maven Central License

RESTEasy Spring Boot Starter


Important: this project has been transfered from PayPal team to RESTEasy team.

All future versions are going to be managed and released from https://github.com/resteasy/resteasy-spring-boot.

This Git repo will be kept here for historical purposes only.


There was no RESTEasy Spring Boot starter out there, so PayPal team decided to create one and share it with the community.

This Spring Boot starter is fully functional, has ZERO PayPal specific code on it, and can be used normally by any regular Spring Boot application that wants to have REST endpoints and prefers RESTEasy as the JAX-RS implementation.

Also, this RESTEasy Spring Boot starter integrates with Spring as expected, which means every JAX-RS REST resource that is also a Spring bean will be automatically auto-scanned, integrated, and available.

Features

  • Enables RESTEasy for Spring Boot applications
  • Supports JAX-RS providers, resources and sub-resources as Spring beans
  • Supports automatic discovery and registration of multiple JAX-RS Application classes as Spring beans
  • Supports optional registration of JAX-RS Application classes via class-path scanning, or manually, via configuration properties (or YAML) file
  • Leverages and supports RESTEasy configuration
  • Supports RESTEasy Asynchronous Job Service

Quick start

Adding POM dependency

Add the Maven dependency below to your Spring Boot application pom file.

<dependency>
   <groupId>com.paypal.springboot</groupId>
   <artifactId>resteasy-spring-boot-starter</artifactId>
   <version>2.3.4-RELEASE</version>
   <scope>runtime</scope>
</dependency>

Registering JAX-RS application classes

Just define your JAX-RS application class (a subclass of Application) as a Spring bean, and it will be automatically registered. See the example below. See section JAX-RS application registration methods in How to use RESTEasy Spring Boot Starter for further information.

package com.sample.app;

import org.springframework.stereotype.Component;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@Component
@ApplicationPath("/sample-app/")
public class JaxrsApplication extends Application {
}

Registering JAX-RS resources and providers

Just define them as Spring beans, and they will be automatically registered. Notice that JAX-RS resources can be singleton or request scoped, while JAX-RS providers must be singletons.

Further information

See How to use RESTEasy Spring Boot Starter.

Release notes

See RESTEasy Spring Boot starter release notes.

Projects

  • sample-app: A simple Spring Boot application that exposes JAX-RS endpoints as Spring beans using RESTEasy via this RESTEasy Spring Boot starter.
  • resteasy-spring-boot-starter: The RESTEasy Spring Boot Starter project.
  • resteasy-spring-boot-starter-test: Integration tests for the RESTEasy Spring Boot Starter project.

Reporting an issue

Please open an issue using our GitHub issues page.

Contributing

You are very welcome to contribute to RESTEasy Spring Boot starter! Read our Contribution guidelines.

Contacting us

To contact us, please send an email to [email protected].

License

This project is licensed under the Apache 2 License.

resteasy-spring-boot's People

Contributors

asoldano avatar fabiocarvalho777 avatar fehmer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

resteasy-spring-boot's Issues

Upgrade Sprig Boot to version 1.3.5

Upgrade Sprig Boot to latest version. At the time this issue was opened the latest version was 1.3.5, but upgrade to the latest version, if a newer is available.

JAX-RS application fails to register after upgrade to 2.1.0

I have a JAX-RS application class that also acts as Spring Boot entry point via @SpringBootApplication.

This fails to register properly after upgrading to 2.1.0 because the ResteasyEmbeddedServletInitializer can't find the application path annotation on that class.

It works fine if I split the Spring Boot app and the JAX-RS app into different classes.

Here are the debug logs, looks like used to inspect the JAX-RS class for annotations (nz.net.catalyst.ApiApp) and now is looking at a CGLIB enhanced version of it, which doesn't have the JAX-RS annotation anymore (nz.net.catalyst.ApiApp$$EnhancerBySpringCGLIB$$889a8b7d).

2.0.1-RELEASE

2016-07-22 12:01:09.857 [] DEBUG 11059 --- [main] p.s.r.ResteasyEmbeddedServletInitializer : Post process bean factory has been called
2016-07-22 12:01:09.857 [] DEBUG 11059 --- [main] p.s.r.ResteasyEmbeddedServletInitializer : Finding JAX-RS Application classes
2016-07-22 12:01:09.874 [] DEBUG 11059 --- [main] p.s.r.ResteasyEmbeddedServletInitializer : Ignored classpath entry: /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/libatk-wrapper.so
2016-07-22 12:01:09.913 [] DEBUG 11059 --- [main] p.s.r.ResteasyEmbeddedServletInitializer : Classpath URLs to be scanned: [..]
2016-07-22 12:01:12.607 [] DEBUG 11059 --- [main] p.s.r.ResteasyEmbeddedServletInitializer : JAX-RS Application class found: nz.net.catalyst.ApiApp
2016-07-22 12:01:12.607 [] DEBUG 11059 --- [main] p.s.r.ResteasyEmbeddedServletInitializer : JAX-RS Application class found: nz.net.catalyst.UndertowTest$MyApp
2016-07-22 12:01:12.607 [] DEBUG 11059 --- [main] p.s.r.ResteasyEmbeddedServletInitializer : JAX-RS Application class found: nz.net.catalyst.ApiApplicationTest$ApiApplication
2016-07-22 12:01:12.607 [] DEBUG 11059 --- [main] p.s.r.ResteasyEmbeddedServletInitializer : Finding JAX-RS resources and providers Spring bean classes
2016-07-22 12:01:12.618 [] DEBUG 11059 --- [main] p.s.r.ResteasyEmbeddedServletInitializer : JAX-RS resource class found: [...]
2016-07-22 12:01:12.618 [] DEBUG 11059 --- [main] p.s.r.ResteasyEmbeddedServletInitializer : JAX-RS provider class found: [...]
2016-07-22 12:01:12.619 [] DEBUG 11059 --- [main] p.s.r.ResteasyEmbeddedServletInitializer : registering JAX-RS application class nz.net.catalyst.ApiApp
2016-07-22 12:01:12.619 [] DEBUG 11059 --- [main] p.s.r.ResteasyEmbeddedServletInitializer : registering JAX-RS application class nz.net.catalyst.UndertowTest$MyApp

2.1.0-RELEASE

2016-07-22 12:05:51.423 [] DEBUG 11436 --- [main] p.s.r.ResteasyEmbeddedServletInitializer : Post process bean factory has been called
2016-07-22 12:05:51.424 []  INFO 11436 --- [main] p.s.r.ResteasyEmbeddedServletInitializer : Finding JAX-RS Application classes
2016-07-22 12:05:51.425 []  INFO 11436 --- [main] p.s.r.ResteasyEmbeddedServletInitializer : Property resteasy.jaxrs.app.registration has not been set, JAX-RS Application classes registration is being set to AUTO
2016-07-22 12:05:51.427 []  INFO 11436 --- [main] p.s.r.ResteasyEmbeddedServletInitializer : Searching for JAX-RS Application Spring beans
2016-07-22 12:05:51.428 []  INFO 11436 --- [main] p.s.r.ResteasyEmbeddedServletInitializer : JAX-RS Application class found: nz.net.catalyst.ApiApp$$EnhancerBySpringCGLIB$$889a8b7d
2016-07-22 12:05:51.428 [] DEBUG 11436 --- [main] p.s.r.ResteasyEmbeddedServletInitializer : Finding JAX-RS resources and providers Spring bean classes
2016-07-22 12:05:51.446 [] DEBUG 11436 --- [main] p.s.r.ResteasyEmbeddedServletInitializer : JAX-RS resource class found: [...]
2016-07-22 12:05:51.479 [] DEBUG 11436 --- [main] p.s.r.ResteasyEmbeddedServletInitializer : JAX-RS provider class found: [...]
2016-07-22 12:05:51.479 []  WARN 11436 --- [main] p.s.r.ResteasyEmbeddedServletInitializer : JAX-RS Application class nz.net.catalyst.ApiApp$$EnhancerBySpringCGLIB$$889a8b7d has no ApplicationPath annotation, so it will not be registered

Application class

@SpringBootApplication
@ApplicationPath("/api")
public class ApiApp extends Application {

  public static void main(String[] args) throws Exception {
    SpringApplication.run(ApiApp.class, args);
  }
}

Consider renaming `ResteasySpringBootConfig` to `RestEasyAutoConfiguration`

Auto-configuration are easy to find because they end with AutoConfiguration. This is in no way a requirement but that makes things more consistent in the auto-configuration report.

Also, since the official name of the project is RESTEasy, I'd argue classes that are prefixed that way should be named RestEasy and not Resteasy.

Do not share ResteasyProviderFactory and Registry among applications

ResteasySpringBootConfig currently uses the same ResteasyProviderFactory and Registry instances for all applications. I believe this is wrong; as an example, you could have registry clashes with applications using the same url.
This seems to the root cause of the problem described at http://stackoverflow.com/questions/41909564/resteasy-spring-incorrect-app-instance-loaded-during-tests-with-multiple-runnin .
I'm providing a PR with a tentative fix in few minutes.

Warning messages during startup

Spring reports the following warnings on Startup:

WARN o.s.c.a.ConfigurationClassEnhancer - @bean method ResteasySpringBootConfig.springBeanProcessor is non-static and returns an object assignable to Spring's BeanFactoryPostProcessor interface. This will result in a failure to process annotations such as @Autowired, @resource and @PostConstruct within the method's declaring @configuration class. Add the 'static' modifier to this method to avoid these container lifecycle issues; see @bean javadoc for complete details.
WARN o.s.c.a.ConfigurationClassEnhancer - @bean method ResteasySpringBootConfig.resteasyEmbeddedServletInitializer is non-static and returns an object assignable to Spring's BeanFactoryPostProcessor interface. This will result in a failure to process annotations such as @Autowired, @resource and @PostConstruct within the method's declaring @configuration class. Add the 'static' modifier to this method to avoid these container lifecycle issues; see @bean javadoc for complete details.

Automate Travis CI

Automate Travis CI for SNAPSHOT deployments and Cobertura report upload to Codacy

Integration Ignore @Valid javax.validation

Hi,
i'm trying to integrate Bean Validation (javax.validation) in your application stack.
I'm trying, for example, with @NotNull or @SiZe, but they are complete ignored.
Here my interface :

@Produces("application/json") @Path("/recharges") public interface RechargeController { @GET @Path("/") public BpeRechargeSearchResponse getRecharges(@Valid @BeanParam BpeRechargeSearchRequest request);

A piece of the bean :

`public class BpeRechargeSearchRequest implements Serializable {

/** Codice della ricarica*/
@QueryParam("rechargeCode")
@NotNull
private String rechargeCode;

/** Data di emissione della ricarica */
@QueryParam("issueDateFrom")

// @jsonformat(shape = JsonFormat.Shape.STRING, pattern = "yyyyMMdd")
@SiZe(min = 8, max = 8, message = "validators.invalid.date.recharge.from")
private String issueDateFrom;`

Have any idea about the problem?

Scan every package registered by Spring framework, instead of the whole class-path

The scanning registration method scans the whole classpath when looking for JAX-RS Application sub-class, and that impacts greatly performance during application start-up.

Instead of that, only packages registered to be scanned by Spring framework should be searched when registering JAX-RS Application sub-classes (regardless of them being Spring beans or not).

Don't skip all applications if one has no path

See code in ResteasyEmbeddedServletInitializer. It seems that that return was supposed to be a continue. :)

        for (Class<? extends Application> applicationClass : applications) {
            ApplicationPath path = applicationClass.getAnnotation(ApplicationPath.class);
            if (path == null) {
                return;
            }

            GenericBeanDefinition applicationServletBean = createApplicationServlet(applicationClass, path.value());
            registry.registerBeanDefinition(applicationClass.getName(), applicationServletBean);
        }

Spring 4.1 is not supported although it easily can be

Compatibility of resteasy-spring-boot with Spring 4.1 is unfortunately broken just because of using the Import annotation to directly reference a Spring component which is not allowed in this version of Spring. The limitation has been removed in Spring 4.2 but I would like to use resteasy-spring-boot in a project where I have to keep Spring 4.1 for certain reasons.

However, the Import annotation in the ResteasySpringBootConfig class can be easily replaced by the Beans annotations which is an approach that not only enables me to use Spring 4.1 but also is - at least from my perspective - more straightforward.

Support RESTEasy configuration

RESTEasy provides configuration via Servlet Context parameters, as seen here.

However, web.xml and web-fragment.xml are not possible in embedded containers. The good news though is that Spring Boot offers an alternative way to set Servlet Context parameters, and that is via adding server.context-parameters.* properties to Spring Boot application.properties file, as referenced in Spring Boot reference guide (search for server.context-parameters.*).

Important notes:

  1. A few of these properties might not make sense in a Spring Boot application with an embedded container. For example, in a Spring Boot application all JAX-RS resources will be also Spring beans, which means properties resteasy.scan, resteasy.scan.providers and resteasy.scan.resources would always be true, so no need to make them configurable.
  2. Looks like a few possible configuration properties are not listed in this table. For example property resteasy.role.based.security.

Acceptance Criteria:

  1. RESTEasy Spring Boot starter should support RESTEasy configuration by consuming Servlet Context parameters as Spring Boot server.context-parameters.* properties.
  2. Add end user documentation explained how to configure RESTEasy in RESTEasy Spring Boot starter
  3. Mention in the end user documentation which properties are not supported (due to the embedded container nature limitation, or for any other reason)
  4. Add a release notes entry

Add configuration to turn OFF scanning for JAX-RS Application sub-classes

Make scanner configurable, so it would be possible to turn it OFF.
In this case, JAX-RS Application sub-classes would have to be identified by one of these two methods:

  1. By manually setting a property for it (via Spring Boot application properties file)
  2. By having them as Spring beans as well

This configuration though would not be used by default. The default method would remain class-path scanning (for backward compatibility).

Questions about parent POM

I just watched your Spring One session on how you have configured Spring Boot. I would like to ask one question. On each of your spring boot applications is the parent pom still spring boot. Or do you have a parent pom for Paypal?

I appears that you just have a core starter pom then sub starter poms for each type of applications.

Thanks

Zach

JAX-RS application and endpoints don't get registered when running mvn spring-boot:run

When starting the application from the IDE, or from a java command directly, the application starts-up fine and everything works as expected.

However, if the application is started using the mvn spring-boot:run command, then for some reason the JAX-RS application and endpoints don't get registered.

The following log statements are missing when running the sample application from mvn spring-boot:run command.

2016-03-28 09:21:04.299  INFO 67757 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'com.test.JaxrsApplication' to [/sample-app/*]
2016-03-28 09:21:04.729  INFO 67757 --- [           main] org.jboss.resteasy.resteasy_jaxrs.i18n   : RESTEASY002225: Deploying javax.ws.rs.core.Application: class com.test.JaxrsApplication

Classpath scanner prints warning when a non jar file is scanned

Classpath scanner (in ResteasyEmbeddedServletInitializer.findJaxrsClasses) prints warning whenever it finds a file that is not a jar (like a pom.xml file).
See the stack trace below as example.

2016-03-21 18:18:18,765 WARN [WrapperStartStopAppMain] org.reflections.Reflections could not create Vfs.Dir from url. ignoring the exception and continuing
org.reflections.ReflectionsException: could not create Vfs.Dir from url, no matching UrlType was found [file:/dependencies/dockertestingserv/cronus/scripts/app/lib/rest-profile-ppaas-1.1.1.pom]
either use fromURL(final URL url, final List<UrlType> urlTypes) or use the static setDefaultURLTypes(final List<UrlType> urlTypes) or addDefaultURLTypes(UrlType urlType) with your specialized UrlType.
    at org.reflections.vfs.Vfs.fromURL(Vfs.java:109) ~[reflections-0.9.10.jar:na]
    at org.reflections.vfs.Vfs.fromURL(Vfs.java:91) ~[reflections-0.9.10.jar:na]
    at org.reflections.Reflections.scan(Reflections.java:237) [reflections-0.9.10.jar:na]
    at org.reflections.Reflections.scan(Reflections.java:204) [reflections-0.9.10.jar:na]
    at org.reflections.Reflections.<init>(Reflections.java:129) [reflections-0.9.10.jar:na]
    at org.reflections.Reflections.<init>(Reflections.java:170) [reflections-0.9.10.jar:na]
    at com.paypal.springboot.resteasy.ResteasyEmbeddedServletInitializer.findJaxrslasses(ResteasyEmbeddedServletInitializer.java:51) [spring-boot-starter-resteasy-1.0.0-RELEASE.jar:na]
    at com.paypal.springboot.resteasy.ResteasyEmbeddedServletInitializer.<init>(ResteasyEmbeddedServletInitializer.java:39) [spring-boot-starter-resteasy-1.0.0-RELEASE.jar:na]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [na:1.8.0_60]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [na:1.8.0_60]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [na:1.8.0_60]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422) [na:1.8.0_60]
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147) [spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89) [spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1098) [spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1050) [spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) [spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) [spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) [spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:179) [spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:678) [spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:520) [spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) [spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:764) [spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:357) [spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:305) [spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1124) [spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1113) [spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at com.paypal.raptor.samples.init.RaptorApplication.main(RaptorApplication.java:20) [classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_60]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_60]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_60]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_60]
    at org.tanukisoftware.wrapper.WrapperStartStopApp.run(WrapperStartStopApp.java:316) [wrapper.jar:3.5.26]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_60]

Remove deprecated code

Spring Boot 1.4 deprecated a part of its API used by this starter, such as class ServletRegistrationBean (it actually moved to a different package), used in ResteasyApplicationBuilder. Remove deprecated code, or adjust it accordingly with the latest API.

Carry over settings from regular deployment

According to javadoc, CustomDispatcherResteasyDeployment will likely be removed in the future, so this will not be an issue. But I don't know how likely it is that this will be incorporated into Resteasy itself anytime soon. :/

    public CustomDispatcherResteasyDeployment(ResteasyDeployment regularDeployment) {
        this.actualProviderClasses = regularDeployment.getActualProviderClasses();
    }

When CustomDispatcherResteasyDeployment is created, it's created based on regular ResteasyDeployment. However, the custom one only takes actualProviderClasses from the regular one. This means all other settings are ignored. For example, I can customize server.context-parameters.resteasy.role.based.security=true in application.properties and it'll properly set securityEnabled to true in regular deployment. But then this setting is not carried over to the custom one.

Asynch job and autowired bean

Hello,
first thanks for the job done.

I would like to use Reasteasy and spring boot in my project but the configuration was a little complicated and with your project evreything was simpler. I am using the 2.3.0-RELEASE version

I have a problem with Asynchronous Job Service Basically if I am requesting http://localhost:8080/sample-app/echo?asynch=true the response is synchronous.

  1. I have added server.context-parameters.resteasy.async.job.service.enabled=true in application.properties, the response is HTTP 404.
  2. I have added too server.context-parameters.resteasy.resources=com.test.Echo the response is what we are expecting
    HTTP/1.1 202
    X-Application-Context: application
    Location: http://localhost:8080/sample-app/asynch/jobs/1489333004352--164874753
    Transfer-Encoding: chunked
    Date: Sun, 12 Mar 2017 15:36:44 GMT

The problem is when requesting http://localhost:8080/sample-app/asynch/jobs/1489333004352--164874753 there is no answer.

When I am executing the program in debug mode the autowired property echoer is null.

Do you have an idea of the problem? What should I do to configure correctly the project to have asynchronous job service?
Thank you

Support specifying resources per application

Support specifying JAX-RS resources per JAX-RS application, based on section 2.3.2 in the JAX-RS 2.0 specification.

"If either getClasses or getSingletons returns a non-empty collection then only those classes or singletons returned MUST be included in the published JAX-RS application"

That must be respected even in the case of multiple JAX-RS applications.

Important note: this only applies to resources (not providers). Specific providers registration per resource can be achieved by using JAX-RS DynamicFeature.

Replace JaxrsApplicationScanner by Spring Framework scanning facility

Is JaxrsApplicationScanner scanning the full classpath (not a specific package)?

If you're using Spring, there is an API to do that, something like:

ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false);
scanner.addIncludeFilter(new AssignableTypeFilter(Application.class));
Set<BeanDefinition> candidates = scanner.findCandidateComponents(packageToScan);
Set<Class<? extends Application>> classes = new HashSet<Class<? extends Application>>();
for (BeanDefinition candidate : candidates) {
    Class<? extends Application> type = (Class<? extends Application>) ClassUtils.forName(
            candidate.getBeanClassName(), JaxrsApplicationScanner.class.getClassLoader());
    classes.add(type);
}
return classes;

It would be more consistent that the actual value of component scan was used for the scanning (by default scan only the package in which the @SpringBootApplication is defined

JAX-RS resources resolution should be targeted towards Spring beans only

JAX-RS resources resolution should be targeted towards Spring beans only, instead of any regular (non-Spring bean) JAX-RS Path or Provider annotated class. That means it is necessary to move from classpath scanning to Spring beans scanning when looking for JAX-RS resources and providers.

Add extra end-user documentation

So far RESTEasy Spring Boot starter usage has been very simple and easy, so documentation has not really been necessary, other than a sample app and a few simple instructions.

However, it would be better to introduce proper documentation. We need to clarify for example the situation described in issue 19

RESTEASY003815: Subresource for target class has no jax-rs annotations.: com.simpleSpring.ighack.Greeting

Greeting

package com.simpleSpring.ighack;

public class Greeting {
	private final long id;
    private final String content;
   
    public Greeting(long id, String content) {
        this.id = id;
        this.content = content;
    }

    public long getId() {
        return id;
    }

    public String getContent() {
        return content;
    }
}

GreetingRestEasy

package com.simpleSpring.ighack;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/resteasy")
@Component
public class GreetingRestEasy {
	
	@Path("/greeting")
	@Consumes({MediaType.TEXT_PLAIN})
	@Produces({MediaType.APPLICATION_JSON})
    public Greeting Greeting() {
		Logger logger=LoggerFactory.getLogger(GreetingRestEasy.class); 
		logger.debug("访问Greetingrestful");
		return new Greeting(1, "ighack");
		
	}
}

JaxrsApplication

package com.simpleSpring.ighack;

import org.springframework.stereotype.Component;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@Component
@ApplicationPath("/simplespring/")
public class JaxrsApplication extends Application {
}

SimpleSpringApplication

package com.simpleSpring.ighack;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.support.SpringBootServletInitializer;

@SpringBootApplication
public class SimpleSpringApplication extends SpringBootServletInitializer {

	public static void main(String[] args) {
		SpringApplication.run(SimpleSpringApplication.class, args);
	}
}

http://127.0.0.1:8080/simplespring/resteasy/greeting

I get error

2017-02-19 12:10:23,450 DEBUG (GreetingRestEasy.java:23)- 访问Greetingrestful
2017-02-19 12:10:23,458 ERROR (ExceptionHandler.java:151)- RESTEASY002005: Failed executing GET /resteasy/greeting
org.jboss.resteasy.spi.InternalServerErrorException: RESTEASY003815: Subresource for target class has no jax-rs annotations.: com.simpleSpring.ighack.Greeting
at org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:124)
at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:101)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:402)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:209)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:105)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.springframework.boot.web.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:115)
at org.springframework.boot.web.support.ErrorPageFilter.access$000(ErrorPageFilter.java:59)
at org.springframework.boot.web.support.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:90)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.boot.web.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
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)

What should I do?
Thanks

Add easy-to-use integration tests

It would be nice to give users of this module an easy and nice way to write integration tests for their resteasy jaxrs services.

The tests should

  • not be executed in normal mvn test but in mvn integration-test
  • start the application on a random port
  • allow easy definition and validation of requests/responses
  • allow to inject mocks in the running application

The documentation should contain all needed information to get started with integration tests to encourage users if this module to write them.

Edit: make clear that this issue aims for integration tests for applications which use this module

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.