From: Steven S. <ssc...@op...> - 2016-04-20 20:53:14
|
Thank you Jeff and Fábio for your prompt responses! The PayPal booter link is interesting, but is not quite my use case -- it uses component scanning to automatically wire things together. Part of my mission here is that I wish to ultimately control what goes into my application, and understand how every piece is wired together. No magic. Maybe I am being unreasonable but I want to really understand the tools I use :) Additionally, their approach in a few places I find suspicious: https://github.com/paypal/resteasy-spring-boot/blob/master/spring-boot-starter-resteasy/src/main/java/com/paypal/springboot/resteasy/ResteasyApplicationBuilder.java#L47-L59 Jeff, thank you very much for your detailed response on Stack Overflow! Initial testing is very promising. I've got my application up and running and the resources seem to wire up well. I've given you an upvote and if things hold together a day or two I'll accept your answer. Thanks both! Hopefully this mailing thread will save someone else a couple of days of banging their head against the wall down the road. I wonder if this example would be a good addition to the documentation? > On Apr 20, 2016, at 11:18 AM, Fábio Carvalho <fab...@gm...> wrote: > > > Hello, > > I have just joined this DL. > > Have you guys seen this? > > https://github.com/paypal/resteasy-spring-boot/ > > > > > On Wed, Apr 20, 2016 at 12:17 PM, Jeff Skjonsby <js...@re...> wrote: > I posted an answer for you on SO with the configuration we use. > > http://stackoverflow.com/questions/36730237/integrating-spring-boot-with-resteasy/36750505#36750505 > > I too agree that it was far more difficult than it should be and it would be nice if RESTEasy would provide more first class support out of the box for the Spring ecosystem in general. Java EE is increasingly becoming irrelevant and RESTEasy wants to stay relevant it's going to need to embrace that reality. > > -----Original Message----- > From: Steven Schlansker [mailto:ssc...@op...] > Sent: Tuesday, April 19, 2016 4:19 PM > To: res...@li... > Subject: [Resteasy-developers] Integrating RESTEasy with Spring Boot > > [ this is a cross-post of a StackOverflow question: https://stackoverflow.com/questions/36730237/integrating-spring-boot-with-resteasy ] > > I am looking for guidance integrating RESTEasy with Spring boot. Almost all of the documentation I have found is for very old Spring versions (2.x) with "web.xml" setup, and I want to go pure Java config. > > I'm surprised at how difficult and undocumented this task is :( > > I found the docs here: > https://docs.jboss.org/resteasy/docs/3.0.16.Final/userguide/html/RESTEasy_Spring_Integration.html > > which indicate that I should install the ResteasyBootstrap, SpringBeanProcessorServletAware, and HttpServletDispatcher. > So I write a Configuration class like this: > > @Configuration > @Import({ResteasyBootstrap.class, SpringBeanProcessorServletAware.class, HttpServletDispatcher.class}) public class EmbeddedJetty { > @Bean > @Singleton > public EmbeddedServletContainerFactory servletContainer() { > JettyEmbeddedServletContainerFactory factory = new JettyEmbeddedServletContainerFactory(); > factory.setPort(9000); > factory.setSessionTimeout(10, TimeUnit.MINUTES); > return factory; > } > } > > The ResteasyBootstrap and HttpServletDispatcher get wired up just fine. > But bringing in the SpringBeanProcessorServletAware causes things to blow up: > > java.lang.NullPointerException: null > at org.jboss.resteasy.plugins.spring.SpringBeanProcessorServletAware.getRegistry(SpringBeanProcessorServletAware.java:30) > at org.jboss.resteasy.plugins.spring.SpringBeanProcessor.postProcessBeanFactory(SpringBeanProcessor.java:247) > at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:284) > at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:174) > at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:680) > at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:522) > at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) > at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) > > If it's not present, the app comes up, but none of the resources are detected and so request routing fails miserably. > > I suspect this is some sort of ordering problem -- the SpringBeanProcessorServletAware class tries to access its Registry before the ServletContextAware interface gets the ServletContext injected. But I've no clue how to fix this! > > What's the correct incantation to wire RESTEasy into Jetty / Spring Boot? > > I am running RESTEasy 3.0.16, Spring Boot 1.3.3, Spring Framework 4.3.0.RC1 > > Thanks for any guidance, > Steven > > > ------------------------------------------------------------------------------ > Find and fix application performance issues faster with Applications Manager > Applications Manager provides deep performance insights into multiple tiers of > your business applications. It resolves application problems quickly and > reduces your MTTR. Get your free trial! > https://ad.doubleclick.net/ddm/clk/302982198;130105516;z > _______________________________________________ > Resteasy-developers mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/resteasy-developers > |