<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: farma07-dev</title>
    <description>The latest articles on DEV Community by farma07-dev (@farma07dev).</description>
    <link>https://dev.to/farma07dev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F865319%2F3d2d2308-9fee-4ece-b3a4-6a7634b1ee40.png</url>
      <title>DEV Community: farma07-dev</title>
      <link>https://dev.to/farma07dev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/farma07dev"/>
    <language>en</language>
    <item>
      <title>Spring 4.3.30 to Spring 5.3.18 - No thread-bound request found</title>
      <dc:creator>farma07-dev</dc:creator>
      <pubDate>Fri, 20 May 2022 12:00:39 +0000</pubDate>
      <link>https://dev.to/farma07dev/spring-4330-to-spring-5318-no-thread-bound-request-found-228o</link>
      <guid>https://dev.to/farma07dev/spring-4330-to-spring-5318-no-thread-bound-request-found-228o</guid>
      <description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;Attempting to upgrade Spring 4.3.30 to Spring 5.3.18. Get the following error when loading Tomcat 8.5.56:&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;Tech stack:&lt;br&gt;
Eclipselink JPA 2.5.1&lt;br&gt;
BasicDatasource connection is setup using Apache commons-dbcp-1.1&lt;br&gt;
Apache CXF Bundle Jar 2.7.18.SP7-redhat-1 - used for JAXRS&lt;/p&gt;

&lt;p&gt;I have tried to replace the RequestContextListener with an updated RequestContextFilter with default value for threadContextInheritable to true.&lt;/p&gt;

&lt;p&gt;Listed below are some excerpts from web.xml, persistence.xml and spring-config.xml files. Any inputs will be useful.&lt;/p&gt;

&lt;p&gt;Thanks,&lt;br&gt;
Mansur Farooq`&lt;/p&gt;

&lt;p&gt;Web.xml:&lt;/p&gt;

&lt;p&gt;&lt;br&gt;
        org.springframework.web.context.ContextLoaderListener&lt;br&gt;
     &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;filter&amp;gt;
    &amp;lt;filter-name&amp;gt;requestContextFilter&amp;lt;/filter-name&amp;gt;
    &amp;lt;filter-class&amp;gt;org.springframework.web.filter.RequestContextFilter&amp;lt;/filter-class&amp;gt;
    &amp;lt;init-param&amp;gt;
        &amp;lt;param-name&amp;gt;threadContextInheritable&amp;lt;/param-name&amp;gt;
        &amp;lt;param-value&amp;gt;true&amp;lt;/param-value&amp;gt;
    &amp;lt;/init-param&amp;gt;
&amp;lt;/filter&amp;gt;

&amp;lt;filter-mapping&amp;gt;
    &amp;lt;filter-name&amp;gt;requestContextFilter&amp;lt;/filter-name&amp;gt;
    &amp;lt;url-pattern&amp;gt;/*&amp;lt;/url-pattern&amp;gt;
&amp;lt;/filter-mapping&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Persistence.xml:&lt;/p&gt;

&lt;p&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;br&gt;

    xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&lt;br&gt;
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"&amp;gt;&lt;br&gt;
    
        transaction-type="RESOURCE_LOCAL"&amp;gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;mapping-file&amp;gt;META-INF/orm.xml&amp;lt;/mapping-file&amp;gt;
    &amp;lt;class&amp;gt;&amp;lt;Custom JPA entities&amp;gt;&amp;lt;/class&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;true&lt;br&gt;
        &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        &amp;lt;property name="eclipselink.weaving" value="static"&amp;gt;
        &amp;lt;/property&amp;gt;
        &amp;lt;property name="eclipselink.logging.level" value="OFF" /&amp;gt;
        &amp;lt;property name="eclipselink.logging.logger"
            value="org.eclipse.persistence.logging.CommonsLoggingSessionLog" /&amp;gt;
        &amp;lt;property name="eclipselink.logging.session" value="FALSE" /&amp;gt;
        &amp;lt;property name="eclipselink.logging.level.sql" value="OFF" /&amp;gt;
        &amp;lt;property name="eclipselink.logging.parameters" value="FALSE" /&amp;gt;


    &amp;lt;/properties&amp;gt;
    &amp;lt;!-- custom SessionLog implementation to use apache commons logging 1.1 
        API (so log4J) --&amp;gt;

    &amp;lt;shared-cache-mode&amp;gt;NONE&amp;lt;/shared-cache-mode&amp;gt;
&amp;lt;/persistence-unit&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Spring-Config.xml:&lt;/p&gt;

&lt;p&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;br&gt;

    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"&lt;br&gt;
    xmlns:flow="http://www.springframework.org/schema/webflow-config" xmlns:jms="http://www.springframework.org/schema/jms"&lt;br&gt;
    xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang"&lt;br&gt;
    xmlns:osgi="http://www.springframework.org/schema/osgi" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"&lt;br&gt;
    xmlns:p="http://www.springframework.org/schema/p" xmlns:cxf="http://cxf.apache.org/core" xmlns:jaxws="http://cxf.apache.org/jaxws"&lt;br&gt;
    xmlns:jaxrs="http://cxf.apache.org/jaxrs"&lt;br&gt;
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&lt;br&gt;
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd&lt;br&gt;
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd&lt;br&gt;
       http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-1.0.xsd&lt;br&gt;
       http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-2.5.xsd&lt;br&gt;
       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd&lt;br&gt;
       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd&lt;br&gt;
       http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd&lt;br&gt;
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd&lt;br&gt;
       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd&lt;br&gt;
       http://cxf.apache.org/core&lt;br&gt;
       http://cxf.apache.org/schemas/core.xsd&lt;br&gt;
       http://cxf.apache.org/jaxws&lt;br&gt;
       http://cxf.apache.org/schemas/jaxws.xsd&lt;br&gt;
       http://cxf.apache.org/jaxrs&lt;br&gt;
       http://cxf.apache.org/schemas/jaxrs.xsd&lt;br&gt;
       "&lt;br&gt;
    default-autowire="byName"&amp;gt;&lt;br&gt;
    &lt;br&gt;
    &lt;br&gt;
    &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;cxf:bus&amp;gt;
    &amp;lt;cxf:features&amp;gt;
        &amp;lt;cxf:logging /&amp;gt;
    &amp;lt;/cxf:features&amp;gt;
&amp;lt;/cxf:bus&amp;gt;

&amp;lt;jaxrs:server id="restServer" address="/services/"
    beanNames="&amp;lt;custom bean names&amp;gt; "&amp;gt;


    &amp;lt;jaxrs:extensionMappings&amp;gt;
        &amp;lt;entry key="feed" value="application/atom+xml" /&amp;gt;
        &amp;lt;entry key="json" value="application/json" /&amp;gt;
        &amp;lt;entry key="xml" value="application/xml" /&amp;gt;
        &amp;lt;entry key="html" value="text/html" /&amp;gt;
    &amp;lt;/jaxrs:extensionMappings&amp;gt;

    &amp;lt;jaxrs:providers&amp;gt;
        &amp;lt;bean class="org.apache.cxf.jaxrs.provider.json.JSONProvider"&amp;gt;
            &amp;lt;property name="writeXsiType" value="false" /&amp;gt;
            &amp;lt;property name="readXsiType" value="false" /&amp;gt;
        &amp;lt;/bean&amp;gt;
    &amp;lt;/jaxrs:providers&amp;gt;
&amp;lt;/jaxrs:server&amp;gt;



&amp;lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" scope="session"&amp;gt;
    &amp;lt;property name="dataSource" ref="dataSource" /&amp;gt;
    &amp;lt;property name="jpaVendorAdapter"&amp;gt;
        &amp;lt;bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter"&amp;gt;
            &amp;lt;property name="showSql" value="false" /&amp;gt;
            &amp;lt;property name="generateDdl" value="false" /&amp;gt;
        &amp;lt;/bean&amp;gt;
    &amp;lt;/property&amp;gt;
    &amp;lt;property name="persistenceUnitPostProcessors" ref="persistenceUnitPostProcessor" /&amp;gt;
&amp;lt;/bean&amp;gt;

&amp;lt;bean id="persistenceUnitPostProcessor" class="&amp;lt;path to custom class file&amp;gt;"
    scope="session"&amp;gt;
    &amp;lt;property name="dataSource" ref="dataSource" /&amp;gt;
&amp;lt;/bean&amp;gt;


&amp;lt;bean id="dataSource" class="&amp;lt;path to custom datasource class file(Apache DBCP)&amp;gt;" scope="session"&amp;gt;
&amp;lt;/bean&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





</description>
      <category>spring</category>
    </item>
  </channel>
</rss>
