Hello,
Attempting to upgrade Spring 4.3.30 to Spring 5.3.18. Get the following error when loading Tomcat 8.5.56:
Caused by: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
Tech stack:
Eclipselink JPA 2.5.1
BasicDatasource connection is setup using Apache commons-dbcp-1.1
Apache CXF Bundle Jar 2.7.18.SP7-redhat-1 - used for JAXRS
I have tried to replace the RequestContextListener with an updated RequestContextFilter with default value for threadContextInheritable to true.
Listed below are some excerpts from web.xml, persistence.xml and spring-config.xml files. Any inputs will be useful.
Thanks,
Mansur Farooq`
Web.xml:
org.springframework.web.context.ContextLoaderListener
<filter>
<filter-name>requestContextFilter</filter-name>
<filter-class>org.springframework.web.filter.RequestContextFilter</filter-class>
<init-param>
<param-name>threadContextInheritable</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>requestContextFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
transaction-type="RESOURCE_LOCAL">
<mapping-file>META-INF/orm.xml</mapping-file>
<class><Custom JPA entities></class>
true
<property name="eclipselink.weaving" value="static">
</property>
<property name="eclipselink.logging.level" value="OFF" />
<property name="eclipselink.logging.logger"
value="org.eclipse.persistence.logging.CommonsLoggingSessionLog" />
<property name="eclipselink.logging.session" value="FALSE" />
<property name="eclipselink.logging.level.sql" value="OFF" />
<property name="eclipselink.logging.parameters" value="FALSE" />
</properties>
<!-- custom SessionLog implementation to use apache commons logging 1.1
API (so log4J) -->
<shared-cache-mode>NONE</shared-cache-mode>
</persistence-unit>
Spring-Config.xml:
<?xml version="1.0" encoding="UTF-8"?>
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xmlns:flow="http://www.springframework.org/schema/webflow-config" xmlns:jms="http://www.springframework.org/schema/jms"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:osgi="http://www.springframework.org/schema/osgi" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p" xmlns:cxf="http://cxf.apache.org/core" xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-1.0.xsd
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://cxf.apache.org/core
http://cxf.apache.org/schemas/core.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd
"
default-autowire="byName">
<cxf:bus>
<cxf:features>
<cxf:logging />
</cxf:features>
</cxf:bus>
<jaxrs:server id="restServer" address="/services/"
beanNames="<custom bean names> ">
<jaxrs:extensionMappings>
<entry key="feed" value="application/atom+xml" />
<entry key="json" value="application/json" />
<entry key="xml" value="application/xml" />
<entry key="html" value="text/html" />
</jaxrs:extensionMappings>
<jaxrs:providers>
<bean class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
<property name="writeXsiType" value="false" />
<property name="readXsiType" value="false" />
</bean>
</jaxrs:providers>
</jaxrs:server>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" scope="session">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
<property name="showSql" value="false" />
<property name="generateDdl" value="false" />
</bean>
</property>
<property name="persistenceUnitPostProcessors" ref="persistenceUnitPostProcessor" />
</bean>
<bean id="persistenceUnitPostProcessor" class="<path to custom class file>"
scope="session">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="dataSource" class="<path to custom datasource class file(Apache DBCP)>" scope="session">
</bean>
Top comments (0)