New user questions

87 views
Skip to first unread message

Nishant Chandra

unread,
Apr 17, 2014, 3:15:28 PM4/17/14
to dropwiz...@googlegroups.com
Hi,

I am trying to use v 0.7.0 along with Spring/hibernate. Few questions:

i. Is anyone using 0.7.0 in production yet? How stable is it?
ii. How do I integrate it with Spring? dropwizard-spring-di-security-onejar-example seems to be not working with the latest version. Any examples would be great.

Thanks,
Nishant 

Matt Veitas

unread,
Apr 17, 2014, 10:04:21 PM4/17/14
to dropwizard-user
Nishant,

I believe there are a few companies running with 0.7.0 already and we haven't seen any issues reported. You should do your own testing to ensure it meets your needs :)

You are correct in that the dropwizard-spring-di-security-onejar-example is not working with the current version. The concepts are similar and shouldn't be difficult to move to use 0.7.0, just mostly some API changes.

If you have any specific questions, you can ask them here.

-Matt


--
You received this message because you are subscribed to the Google Groups "dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-us...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tobias Haag

unread,
Apr 17, 2014, 11:25:26 PM4/17/14
to dropwiz...@googlegroups.com
We are close to using it in prod, so far it has proven stable, but we have not run any specific benchmarks or extended loadtest yet to verify just how stable it is. The biggest factor to move is upgraded transitive dependencies like jetty/netty, guava, fasterxml etc. With jdk u51 we have been pressed to upgrade guava as some breaking changes were introduced that made use of older guava versions impossible/impractical.  

Be happy to post a few more experience reports once we got proper prod traffic running through it though. 

Cheers

Nishant Chandra

unread,
Apr 18, 2014, 2:17:31 AM4/18/14
to dropwiz...@googlegroups.com
This is what I picked up from the sample:

//init Spring context
        //before we init the app context, we have to create a parent context with all the config objects others rely on to get initialized
        AnnotationConfigWebApplicationContext parent = new AnnotationConfigWebApplicationContext();
        AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();

        parent.refresh();
        parent.getBeanFactory().registerSingleton("configuration", configuration);
        parent.registerShutdownHook();
        parent.start();

        //the real main app context has a link to the parent context
        ctx.setParent(parent);
        ctx.register(MyAppSpringConfiguration.class);
        ctx.refresh();
        ctx.registerShutdownHook();
        ctx.start();

        //now that Spring is started, let's get all the beans that matter into DropWizard

        //health checks
        Map<String, HealthCheck> healthChecks = ctx.getBeansOfType(HealthCheck.class);
        for(Map.Entry<String,HealthCheck> entry : healthChecks.entrySet()) {
            environment.healthChecks().register("template", entry.getValue());
        }

        //resources
        Map<String, Object> resources = ctx.getBeansWithAnnotation(Path.class);
        for(Map.Entry<String,Object> entry : resources.entrySet()) {
            environment.jersey().register(entry.getValue());
        }

@Configuration
//@ImportResource("classpath:myapp-security.xml")
@ComponentScan(basePackages = {"com.example.resources"})
public class MyAppSpringConfiguration {

}

And getting this exception:

ERROR [2014-04-18 06:12:34,552] com.sun.jersey.server.impl.application.RootResourceUriRules: The ResourceConfig instance does not contain any root resource classes.
Exception in thread "main" javax.servlet.ServletException: com.sun.jersey.spi.container.servlet.ServletContainer-358311fc@81642924==com.sun.jersey.spi.container.servlet.ServletContainer,1,false
at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:561)
at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:349)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:812)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:288)

Seems Spring is not able to find classes annotated with @Path. Any help here?

Thanks,
Nishant

Nishant Chandra

unread,
Apr 20, 2014, 3:04:21 PM4/20/14
to dropwiz...@googlegroups.com
I got everything working.

A sample service using Dropwizard 0.7, Spring and JPA/Hibernate is publicly available at http://n-chandra.blogspot.in/2014/04/the-sweetness-of-developing-rest.html

Thanks,
Nishant

On Friday, 18 April 2014 00:45:28 UTC+5:30, Nishant Chandra wrote:
Reply all
Reply to author
Forward
0 new messages