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

Dynamic Datasource not judging Jakarta EE namespace when using SPEL #471

Closed
linghengqian opened this issue Dec 23, 2022 · 2 comments · Fixed by #474
Closed

Dynamic Datasource not judging Jakarta EE namespace when using SPEL #471

linghengqian opened this issue Dec 23, 2022 · 2 comments · Fixed by #474

Comments

@linghengqian
Copy link
Contributor

linghengqian commented Dec 23, 2022

Please fill it out carefully, or it will be closed.
请认真填写,不然会直接关闭。

Enviroment

JDK Version(required):

  • 17

SpringBoot Version(required):

  • 3.0.1

dynamic-datasource-spring-boot-starter Version(required):

  • 3.6.1

druid Version(optional):

  • Null.

Describe what happened

Expected Result:

  • Normal.

Actual Result:

  • An error occurred.

If there is an exception,or aop invalid,please attach the exception trace:

Caused by: jakarta.servlet.ServletException: Handler dispatch failed: java.lang.NoSuchMethodError: 'javax.servlet.http.HttpServletRequest org.springframework.web.context.request.ServletRequestAttributes.getRequest()'
	at app//org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1095)
	at app//org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:973)
	at app//org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1010)
	at app//org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:902)
	at app//jakarta.servlet.http.HttpServlet.service(HttpServlet.java:705)
	at app//org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:884)
	at app//org.springframework.test.web.servlet.TestDispatcherServlet.service(TestDispatcherServlet.java:72)
	at app//jakarta.servlet.http.HttpServlet.service(HttpServlet.java:814)
	at app//org.springframework.mock.web.MockFilterChain$ServletFilterProxy.doFilter(MockFilterChain.java:165)
	at app//org.springframework.mock.web.MockFilterChain.doFilter(MockFilterChain.java:132)
	at app//org.springframework.test.web.servlet.MockMvc.perform(MockMvc.java:201)
	at app//com.lingh.dynamicdatasourcespeltest.SPELTest.lambda$testSPEL$0(SPELTest.java:67)
	at app//org.junit.jupiter.api.AssertDoesNotThrow.assertDoesNotThrow(AssertDoesNotThrow.java:49)
	... 88 more
Caused by: java.lang.NoSuchMethodError: 'javax.servlet.http.HttpServletRequest org.springframework.web.context.request.ServletRequestAttributes.getRequest()'
	at com.baomidou.dynamic.datasource.processor.jakarta.DsJakartaSessionProcessor.doDetermineDatasource(DsJakartaSessionProcessor.java:43)
	at com.baomidou.dynamic.datasource.processor.DsProcessor.determineDatasource(DsProcessor.java:53)
	at com.baomidou.dynamic.datasource.processor.DsProcessor.determineDatasource(DsProcessor.java:60)
	at com.baomidou.dynamic.datasource.aop.DynamicDataSourceAnnotationInterceptor.determineDatasourceKey(DynamicDataSourceAnnotationInterceptor.java:58)
	at com.baomidou.dynamic.datasource.aop.DynamicDataSourceAnnotationInterceptor.invoke(DynamicDataSourceAnnotationInterceptor.java:47)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:752)
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:703)
	at com.lingh.dynamicdatasourcespeltest.service.spel.UserService$$SpringCGLIB$$0.selectSpelBySession(<generated>)
	at com.lingh.dynamicdatasourcespeltest.controller.UserController.session(UserController.java:23)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:207)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:152)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:884)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1080)
	... 100 more

Steps to reproduce

git clone [email protected]:linghengqian/dynamic-datasource-spel-test.git
cd ./dynamic-datasource-spel-test
sdk use java 22.3.r17-grl
./gradlew clean test
@linghengqian
Copy link
Contributor Author

  • I'm working on this issue.

@linghengqian
Copy link
Contributor Author

  • Reopen this issue because packaging failed.

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

Successfully merging a pull request may close this issue.

2 participants