Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot inject Tomcat DBCP 2 library in Gretty 3.1.0 via dependencies/gretty #278

Open
ahubmann opened this issue Nov 18, 2022 · 5 comments

Comments

@ahubmann
Copy link

Running into an issue upgrading from 3.0.9 to 3.1.0:

I'm injecting Tomcat/DBCP2 to look up database connections via JDNI as per documentation:
build.gradle

dependencies {
  gretty ("org.apache.tomcat:tomcat-dbcp:${project.tomcat9Version}")
}

This has stopped working in 3.1.0:

javax.naming.NamingException: Could not create resource factory instance
...
Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory

I assume this is a side-effect of the class loader changes in 3.1.0? Any advice?

@f4lco
Copy link
Collaborator

f4lco commented Nov 19, 2022

Do you have a reproducer project? I have a hard time reproducing this error, because I hardly know tomcat-dbcp.

@f4lco
Copy link
Collaborator

f4lco commented Nov 19, 2022

Before that, could you try to put the dependency into configuration grettyRunnerTomcat9, rather than gretty, and report back if it works as expected?

@ahubmann
Copy link
Author

Awesome, thanks for the swift reply and indeed, moving the dependency from gretty into the grettyRunnerTomcat9 configuration resolves the issue.

May I then suggest updating the two documentation links I posted above? In both instances, the documentation refers to the gretty configuration.

@dtbullock
Copy link

Same here. using gretty() in depencencies{} doesn't work, but using the (ahem, undocumented) grettRunnerTomcatX() does.

@jonfrench
Copy link

For users of jetty, I had to do this:

dependencies {
    grettyRunnerJetty10 'commons-dbcp:commons-dbcp:1.4'
}

gretty {
    servletContainer = 'jetty10'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants