xvik on master
support providing config overri… (compare)
xvik on master
remove usages and mentions of d… disable signing for jitpack bui… (compare)
dependabot[bot] on gradle
xvik on master
Bump spotbugs-annotations from … Merge pull request #225 from xv… (compare)
dependabot[bot] on gradle
Bump spotbugs-annotations from … (compare)
xvik on gh-pages
Publish 5.5.0 documentation (compare)
dependabot[bot] on gradle
xvik on gh-pages
Publish 5.5.0 documentation (compare)
xvik on master
update to dropwizard 2.1.0 (compare)
xvik on master
mention in doc duplicate module… (compare)
dependabot[bot] on gradle
Bump dropwizard-dependencies fr… (compare)
public Index getIndex(@PathParam("indexId") String indexId) {
Optional<Index> indexOpt = indexDao.findById(indexId);
if (indexOpt.isPresent()) {
return indexOpt.get();
} else {
throw new IndexNotFoundException(indexId);
}
}
@Provider
public class IndexNotFoundExceptionMapper
implements ExceptionMapper<IndexNotFoundException> {
@Override
public Response toResponse(IndexNotFoundException indexNotFoundException) {
int errorCode = ErrorConstants.INDEX_NOT_FOUND_CODE;
String errorMessage =
String.format(
ErrorConstants.INDEX_NOT_FOUND,
indexNotFoundException.getIndexId()
);
return Response
.status(Response.Status.NOT_FOUND)
.entity(
new KalaErrorEntity(
errorMessage,
errorCode
)
)
.build();
}
}
public void initialize(Bootstrap<HttpServerConfiguration> bootstrap) {
// register hbn bundle before guice to make sure factory initialized before guice context start
final HbnBundle hibernate = new HbnBundle();
bootstrap.addBundle(hibernate);
// do not use auto scan here otherwise filter will be scanned without CredentialRequiredFeature
bootstrap.addBundle(GuiceBundle.builder()
.extensions(
AccountResource.class,
AppResource.class,
IndexResource.class,
DocResource.class,
CredentialRequiredFeature.class,
LoginRequiredFeature.class,
IndexNotFoundExceptionMapper.class,
CredentialUnauthorizedExceptionMapper.class
)
.modules(new HbnModule(hibernate))
.modules(new GuiceModule())
.build());
}
Application<HttpServerConfiguration>
and without using extensions(IndexNotFoundExceptionMapper)
but use environment.jersey().register(new CredentialUnauthorizedExceptionMapper());
instead right?
public ResourceExtension resourceExtension = ResourceExtension.builder()
.addResource(
new IndexResource(indexDao, indexServiceManager)
)
.addResource(new IndexNotFoundExceptionMapper())
.build();
Hi all , I have a question regarding the JDBI3 extension.
I'm trying to add to our solution a support for @UnitOfWork annotation with the JDBI extension.
Currently we use Guice to inject Resources and DAO's.
We have one ServiceModule and one DataAccessModule
in ServiceModule we do the following for all our Jeresy resources
binder.bind(FooResource.class);
And in our DataAccessModule
@Provides
fun fooDao(dbi: Jdbi): FooDao = dbi.onDemand(FooDao::class.java)
and of all these are defined in the Init function in the server
guiceBundle = GuiceBundle.builder()
.modules(ServiceModule, DataAccessModule...)
.build();
This code above works , however once ill change it to
`guiceBundle = GuiceBundle.builder()
.bundles(JdbiBundle.<Configucation>forDatabase((conf, env) -> conf.getDataSourceFactory()))
.modules(ServiceModule)
.build();`
(notice I removed the DataAccessModule as I marked my DAO's with @JDBIRepository annotations so the repositoryInstaller should install them.
Now as you can see I added the JdbiBundle as per the documentation, but I'm getting a lot of Guice exceptions such as
1) No implementation for ..fooDAO was bound.
while locating .FooDao
for the 3rd parameter of fooHandler.<init>(FooHandler.kt:21)
Basically it looks like the resources are getting fired up before the DAO's in Guice , which causing him to throw exceptions as he don't have yet their mappings.
I added some debug information to Guicey and saw the following order of modules
ServiceModule (c.n.claims.di)
...
JdbiModule (r.v.g.jdbi3.module)
GuiceBootstrapModule (r.v.d.guice.module)
Can anyone give me some pointers on what am I doing wrong?
Thanks
.enableAutoConfig(package)
) on guice bundle to automate extensions search (like in JDBI example) or declare you dao extensions manually: .extensions(MyDAO1.class, MyDAO2.class )
.
INFO [2020-07-09 01:12:36,980] ru.vyarus.guicey.jdbi3.installer.repository.RepositoryInstaller: repositories =
(ru.vyarus.guicey.jdbi3.support.repository.CustTxRepository)
(ru.vyarus.guicey.jdbi3.support.repository.LogicfulRepository)
(ru.vyarus.guicey.jdbi3.support.repository.SampleRepository)
@xvik first, let me say thank you for your help.
I managed to get my service working ( I added manual bindings with the extensions you suggested)
However I'm facing now another issue
I'm getting the following errors:Error handling a request: XXX! java.lang.IllegalStateException: Unit of work not started yet
It appears to happen when I try to invoke a function from my DAO injection.
For example I have in my handler constructor @Inject private val fooDao: FooDao
and then I do something like fooDao.insertFoo(foo:Foo)
not sure why I'm getting this error
fun getFooById(fooId: String): FooDto {
val foo = fooDao.getFooByFooId(fooId)
return foo.toDto()
}
this is my function , where fooDAO is getting injected in the constructor
I'm still getting the error Unit of work not started yet
my fooDao is defined as
@JdbiRepository
interface fooDAO {
}
@xvik Hi , I have a small question.
In our testing we are using GuiceyAppRule to start our service from within the tests.
To define the GuiceyAppRule we need to provide the path to the config.yaml file, however our config files are residing in the Src folder and not in the test folder, which makes it fails to find the configuration files.
As a temp workaround , we copied the files from the Src also to the test folder.
We were wandering if there is a better alternative for that , didn't find something in the documentation.
thank you