Jdbi: AnnotationFormatError

Created on 19 Dec 2016  路  6Comments  路  Source: jdbi/jdbi

Invocation of init method failed; nested exception is java.lang.annotation.AnnotationFormatError: Invalid default: public abstract java.lang.Class org.skife.jdbi.v2.sqlobject.stringtemplate.UseStringTemplate3StatementLocator.errorListener()

How to fix this?

Most helpful comment

Ah, I see you resolved this issue. The StringTemplate library is optional, because it's needed only to specific features like using ST expressions. For example, the @BindIn annotation uses them, because it's not possible to provide in (:list) prepared statements via the JDBC API.

In JDBI3 this issue is resolved, by moving the StringTemplate functionality to a specific module with a compile dependency to StringTemplate.

All 6 comments

Could you provide a more detailed test case? Unfortunately your snipped doesn't provide enough information to reproduce the error.

@UseStringTemplate3StatementLocator
public interface UsersRepository {

    @SqlQuery("SELECT id FROM users WHERE phone IN (<phones>)")
    List<Long> find(@BindIn("phones") List<String> phones);
}

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: Invocation of init method failed; nested exception is java.lang.annotation.AnnotationFormatError: Invalid default: public abstract java.lang.Class org.skife.jdbi.v2.sqlobject.stringtemplate.UseStringTemplate3StatementLocator.errorListener()

So
dbi().onDemand(UsersRepository.class);
not work

I've added https://mvnrepository.com/artifact/org.antlr/stringtemplate/3.2.1 to dependencies and now it works
But why this dependecy is not included in jdbi?

Could you check that the StringTemplate library (Maven coordinates org.antlr:stringtemplate) exists in your classpath? If so, which version?

Ah, I see you resolved this issue. The StringTemplate library is optional, because it's needed only to specific features like using ST expressions. For example, the @BindIn annotation uses them, because it's not possible to provide in (:list) prepared statements via the JDBC API.

In JDBI3 this issue is resolved, by moving the StringTemplate functionality to a specific module with a compile dependency to StringTemplate.

ok, thanks

Was this page helpful?
0 / 5 - 0 ratings