-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
typeHandlersPackage scanning not working when custom TypeHandler is in other (nested) jar than the SqlSessionFactoryBean definition #325
Comments
We are using version 3.2.8 |
I tried to upgrade from 3.2.3 to 3.2.8 and I have missing typehandler errors too. My project's structure is similar. I tried 3.2.7 and 3.2.4 also but same errors occurred. I reverted back to 3.2.3 and now works. |
There seems to be no logical change in org.apache.ibatis.io.DefaultVFS since 3.2.3. |
👍 |
Hi @harawata, I created a verifying application for this issue. And workaround is ... |
@kazuki43zoo |
According to the Spring Boot documentation, Java does not provide any standard way to load nested jar files and Spring Boot uses its own mechanism for it. As these application server specific behavior should be handled with a custom VFS implementation, I have added a new setting 'vfsImpl' to make the VFS implementation configurable. <settings>
<setting name="vfsImpl" value="com.mydomain.vfs.SpringBootExecutableJarVFS" />
</settings> This change should be available in the latest 3.4.0-SNAPSHOT. To @s17t |
Stripes guys came up with a few custom VFS implementations supporting Spring-Boot's executable JAR. |
Just a heads up. |
👍 I tried mybatis-spring-boot 1.0.1-SNAPSHOT. It's a very nice !! Verifying application is |
Thanks for the feedback and the link, @kazuki43zoo ! |
Sorry to dive late. |
@julnamoo It should be =) |
We have a multi-module project with the following structure:
batch.jar (created using Spring boot)
--persistenceContext.xml (containing definition SqlSessionFactoryBean - see bellow)
--package1/package2/Mapper1.xml (specific mapper for batch module)
--package1/package2/Mapper1.java (specific mapper for batch module)
--lib/persistence-module.jar
--lib/persistence-module.jar/package3/package4/Mapper2.xml (common mapper re-used by multiple modules)
--lib/persistence-module.jar/package3/package4/Mapper2.java (common mapper re-used by multiple modules)
--lib/persistence-module.jar/package3/package5/typehandler/DateTimeHandler.java (common typehandler re-used by multiple modules)
relevant parts of the persistenceContext.xml (placed in the OUTER jar file):
The mapper scanning works without any problems (even for the Mapper2, which is placed in the inner jar file).
But typehandler scanning does not work correctly - the custom type handler DateTimeHandler.java is not found by myBatis in this configuration. I think the problem is on line 202 in org.apache.ibatis.io.DefaultVFS.java:
This causes the URL in the form of "jar:file:batch.jar!/lib/persistence-module.jar/package3/package5/typehandler" is transformed to "file:batch.jar!/lib/persistence-module.jar/package3/package5/typehandler" and Exception is thrown on attempt to read from this URL on line 288 (isJar method).
Workaround I had to use was to duplicate the DateTimeHandler.java and put it to the outer jar (batch.jar) as well + change the spring context so now the scanned type handler package is the one in the outer jar. But this solution is of course not ideal and I definitely consider this as a bug (especially because rest of the mybatis configuration - i.e. the mapper scanning is working normally even for the mappers placed in the INNER jar).
Also I think the "swallowing" of the Exception in DefaultVFS.isJar() without any logging is not very good and it took me some time debugging the sources before finding the cause of this problem (and obviously the comment "Failure to read the stream means this is not a JAR" is not correct).
The text was updated successfully, but these errors were encountered: