The type org.springframework.dao.InvalidDataAccessApiUsageException cannot be resolved.
It is indirectly referenced from required .class files (error is in a first line of code ).
I have not imported org.springframework.dao.InvalidDataAccessApiUsageExceptionstill it is showing the error.
(Error) /**
*#author Infosys
*Create Date Created on Nov 23, 2011
*Sr.No. Modification Date Modified By Reason
* 1.0 11/28/2011 Vasu Rathore Initial code for P8344b
*/
package com.aetna.channel.catsIntake.common.util.sp;
import java.sql.Types;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.sql.DataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.SqlOutParameter;
import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.object.StoredProcedure;
import com.aetna.channel.catsIntake.caseId.spAdapters.ComplaintAndAppealCaseIdGenSP;
import com.aetna.channel.catsIntake.common.exceptions.CatsControllerException;
import com.aetna.channel.catsIntake.common.exceptions.CatsDatabaseException;
import com.aetna.channel.catsIntake.common.exceptions.CatsExceptionConstants;
import com.aetna.channel.catsIntake.common.exceptions.CatsIntakeSvcDAOException;
import com.aetna.channel.catsIntake.common.exceptions.CatsInvalidInputException;
import com.aetna.channel.catsIntake.common.exceptions.CatsNoDataFoundExeception;
import com.aetna.channel.catsIntake.common.util.dao.CatsLookUpDao;
org.springframework.dao.InvalidDataAccessApiUsageException is contained in spring-tx-<version>.jar so you are probably missing that dependency.
I got the same error in Spring project and I added the spring jdbc dependency which resolved my issue.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
Related
I am getting this following exception on my production while running my code. I don't know what I am making mistake, the same code is happily running on my local machine, please help
Feb 19 13:46:40 ip-10-0-77-139 server: ShopifyGetItems: Service
function shop.getShopifyDomain():
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'hibernateConfig': Injection of autowired
dependencies failed; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No
bean named 'environment' available
import java.util.Properties;
import javax.sql.DataSource;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.orm.hibernate4.HibernateTransactionManager;
import org.springframework.orm.hibernate4.LocalSessionFactoryBean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
#Configuration
#EnableTransactionManagement
#ComponentScan({ "com.webbee.app" })
#PropertySource(value = { "classpath:internal.properties" })
public class HibernateConfig {
#Autowired
private Environment environment;
private Properties hibernateProperties() {
System.out.println(environment.getRequiredProperty("hibernate.dialect"));
Properties properties = new Properties();
properties.put("hibernate.dialect", environment.getRequiredProperty("hibernate.dialect"));
properties.put("hibernate.show_sql", environment.getRequiredProperty("hibernate.show_sql"));
properties.put("hibernate.format_sql", environment.getRequiredProperty("hibernate.format_sql"));
properties.put("hibernate.hbm2ddl.auto", environment.getRequiredProperty("hibernate.hbm2ddl.auto"));
properties.put("hibernate.jdbc.batch_size", 1000); // batch size for save or update
return properties;
}
}
It will be good, if you can debug the issue -
System.out.println("Created beans: " + Arrays.toString(context.getBeanNamesForType(Environment.class)));
if you are getting empty list it means, your bean is not instantiated in spring container and there is some problem with component scan.
This helped me in spring boot 2.4 but not in 2.6
spring:
config:
use-legacy-processing: false
I realized a simple projetc using spring and maven, my project contains an interface and 3 classes and the pom.xml file
Interface : CompactDisc.java
3 classes :
SgtPeppers.java that implements the CompactDisc interface
CDPlayersConfig.java is an empty class and contains the annotations of automatic scan
CDPlayersTest.java is a test class to test if the spring container works.
My problem is with #RunWith(SpringJUnit4ClassRunner.class) and #ContextConfiguration(classes=CDPlayersConfig.class), Eclipse suggests this proposition for the first annotation Class cannot be resolved to a type and it doesn't understand the second annotation.
You find here the code :
CompactDisc.java
package soundsystem;
public interface CompactDisc {
void play();
}
SgtPeppers.java
package soundsystem;
import org.springframework.stereotype.Component;
#Component
public class SgtPeppers implements CompactDisc{
private String title = "Sgt. Pepper's Lonely Hearts Club Band";
private String artist = "The Beatles";
public void play() {
System.out.println("Playing " + title + "by"+ artist);
}
}
CDPlayersConfig.java
package soundsystem;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
#Configuration
#ComponentScan
public class CDPlayersConfig {
}
CDPlayerTest.java
package soundsystem;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.jta.SpringJtaSynchronizationAdapter;
#RunWith(SpringJUnit4ClassRunner.class)//Here is my problem
#ContextConfiguration(classes=CDPlayersConfig.class)//Here is my problem
public class CDPlayerTest {
#Autowired
private CompactDisc cd;
#Test
public void cdShouldNotBeNull() {
assertNotNull(cd);
}
}
Dependencies im the pom file
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>4.0.5.RELEASE</version>
<scope>test</scope>
</dependency>
In Eclipse
Right Click on your Project
Select Maven
Select Update Project
Tick
Update project config from pom.xml
Refresh workspace
Clean projects
After doing that the required libraries should be available to Eclipse and you should be able to import the classes as required.
I can't see
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.ContextConfiguration;
in your import section. Also, maybe you should use SpringRunner.class instead of SpringJUnit4ClassRunner.class
Control+click on the class. Eclipse will open the file. Copy the package name. Create a new import statement and paste the package name + the class name. Problem solved.
If Eclipse does not open the file when you control+click, you don't have it on your class path or imported correctly.
You are missing the imports (import org.springframework...) for SpringJUnit4ClassRunner and ContextConfiguration. That's why they are not recognized.
You have to add dependency:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>4.3.9.RELEASE</version>
</dependency>
And then
import org.springframework.test.context.ContextConfiguration;
It's working in my Gradle project after complete some steps.
1st: Add dependency in build.gradle file ->
testImplementation 'junit:junit:4.13.2'
implementation 'org.springframework:spring-test:4.0.0.RELEASE'
2nd: Clean Gradle project using IDE or using command prompt -> Open command prompt -> Go to project location c:\gradle_projects\test_gradle>gradlew clean build -> Enter
3rd: Refresh Gradle project -> Open command prompt -> Go to project location c:\gradle_projects\test_gradle>gradlew --refresh-dependencies -> Enter
4th: Go to IDE -> right-click on project name -> Gradle -> Refresh Gradle Project
-> finally download jar files and import class
i am trying to build a web using Spring and Angular Js tegether w/ Gradle. my problem is When i run my project or build gradle this error comes out.
"contextLoads FAILED"
"What went Wrong:"
.> There were failing tests.: /build/reports/tests/test/index.html
Caused by:
org.springframework.beans.factory.UnsatisfiedDependencyException
Caused by:
org.springframework.beans.factory.NoSuchBeanDefinitionException
ContextLoad Leads me to this Class:
package com.linkedin.learning.linkedinlearningfullstackappangularspringboot;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
#RunWith(SpringRunner.class)
#SpringBootTest
public class LinkedInLearningFullStackAppAngularSpringBootApplicationTests {
#Test
public void contextLoads() {
}
}
heres the screenshot to make it clearer:
enter image description here
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-04-12 18:47:51.811 ERROR 340 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
APPLICATION FAILED TO START
Description:
Field leadRepository in com.example.lead.controller.LeadController required a bean of type 'com.example.lead.repo.LeadRepository' that could not be found.
Action:
Consider defining a bean of type 'com.example.lead.repo.LeadRepository' in your configuration.
package com.example.lead.repo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
// import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.example.leadmodel.Lead;
import com.example.leadmodel.LeadEntity;
#Repository
public interface LeadRepository extends JpaRepository<Lead, Integer> {
#Bean
#Autowired
Lead findOne(Integer lead_id);
void save(LeadEntity leadEntity);
}
I started to update a wep application from Tomcat 6 to the current version of Tomcat (7-27). The problem arises when I start-up the server with the following error message:
ERROR LifeCycle - Cannot start object
org.gatein.pc.portlet.container.PortletInitializationException: Cannot create filter with class com.qnamic.railopt.web.security.portlet.PortletSecurityFilter because it does not implement the expected interface javax.portlet.filter.PortletFilter
at org.gatein.pc.portlet.impl.jsr168.ClassInstanceLifeCycle.create(ClassInstanceLifeCycle.java:85)
at org.gatein.pc.portlet.impl.jsr168.PortletFilterImpl.start(PortletFilterImpl.java:144)
at org.gatein.pc.portlet.impl.container.PortletFilterLifeCycle.invokeStart(PortletFilterLifeCycle.java:66)
at org.gatein.pc.portlet.impl.container.LifeCycle.managedStart(LifeCycle.java:93)
at org.gatein.pc.portlet.impl.container.PortletApplicationLifeCycle.startDependents(PortletApplicationLifeCycle.java:339)
at org.gatein.pc.portlet.impl.container.LifeCycle.managedStart(LifeCycle.java:129)
at org.gatein.pc.mc.PortletApplicationDeployment.install(PortletApplicationDeployment.java:153)
at org.gatein.pc.mc.PortletApplicationDeployer.add(PortletApplicationDeployer.java:216)
at org.gatein.pc.mc.PortletApplicationDeployer.onEvent(PortletApplicationDeployer.java:185)
at org.gatein.wci.impl.DefaultServletContainer.safeFireEvent(DefaultServletContainer.java:200)
at org.gatein.wci.impl.DefaultServletContainer.fireEvent(DefaultServletContainer.java:219)
at org.gatein.wci.impl.DefaultServletContainer.access$400(DefaultServletContainer.java:60)
at org.gatein.wci.impl.DefaultServletContainer$RegistrationImpl.registerWebApp(DefaultServletContainer.java:338)
at org.gatein.wci.tomcat.TC7ServletContainerContext.start(TC7ServletContainerContext.java:380)
at org.gatein.wci.tomcat.TC7ServletContainerContext.lifecycleEvent(TC7ServletContainerContext.java:234)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:401)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:168)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
A: S: R: U: ERROR LifeCycle - Cannot start object
org.gatein.pc.portlet.container.PortletInitializationException: Cannot create filter with class com.qnamic.railopt.web.core.portal.ContextFilter because it does not implement the expected interface javax.portlet.filter.PortletFilter
at org.gatein.pc.portlet.impl.jsr168.ClassInstanceLifeCycle.create(ClassInstanceLifeCycle.java:85)
at org.gatein.pc.portlet.impl.jsr168.PortletFilterImpl.start(PortletFilterImpl.java:144)
at org.gatein.pc.portlet.impl.container.PortletFilterLifeCycle.invokeStart(PortletFilterLifeCycle.java:66)
at org.gatein.pc.portlet.impl.container.LifeCycle.managedStart(LifeCycle.java:93)
at org.gatein.pc.portlet.impl.container.PortletApplicationLifeCycle.startDependents(PortletApplicationLifeCycle.java:339)
at org.gatein.pc.portlet.impl.container.LifeCycle.managedStart(LifeCycle.java:129)
at org.gatein.pc.mc.PortletApplicationDeployment.install(PortletApplicationDeployment.java:153)
at org.gatein.pc.mc.PortletApplicationDeployer.add(PortletApplicationDeployer.java:216)
at org.gatein.pc.mc.PortletApplicationDeployer.onEvent(PortletApplicationDeployer.java:185)
at org.gatein.wci.impl.DefaultServletContainer.safeFireEvent(DefaultServletContainer.java:200)
at org.gatein.wci.impl.DefaultServletContainer.fireEvent(DefaultServletContainer.java:219)
at org.gatein.wci.impl.DefaultServletContainer.access$400(DefaultServletContainer.java:60)
at org.gatein.wci.impl.DefaultServletContainer$RegistrationImpl.registerWebApp(DefaultServletContainer.java:338)
at org.gatein.wci.tomcat.TC7ServletContainerContext.start(TC7ServletContainerContext.java:380)
at org.gatein.wci.tomcat.TC7ServletContainerContext.lifecycleEvent(TC7ServletContainerContext.java:234)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:401)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:168)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
The class com.qnamic.railopt.web.security.portlet.PortletSecurityFilter does implement the interface javax.portlet.filter.PortletFilter:
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.security.Principal;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.EventRequest;
import javax.portlet.EventResponse;
import javax.portlet.PortletException;
import javax.portlet.PortletMode;
import javax.portlet.PortletRequest;
import javax.portlet.PortletResponse;
import javax.portlet.PortletSession;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
import javax.portlet.filter.ActionFilter;
import javax.portlet.filter.EventFilter;
import javax.portlet.filter.FilterChain;
import javax.portlet.filter.FilterConfig;
import javax.portlet.filter.RenderFilter;
import javax.portlet.filter.ResourceFilter;
import org.apache.log4j.Logger;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
public class PortletSecurityFilter implements ActionFilter, EventFilter, RenderFilter, ResourceFilter {
ActionFilter does implement javax.portlet.filter.PortletFilter
The dependent jars are:
primefaces-3.2.jar
spring-core-3.0.5.RELEASE.jar
spring-asm-3.0.5.RELEASE.jar
spring-context-3.0.5.RELEASE.jar
spring-aop-3.0.5.RELEASE.jar
spring-expression-3.0.5.RELEASE.jar
spring-webmvc-portlet-3.0.5.RELEASE.jar
spring-webmvc-3.0.5.RELEASE.jar
spring-context-support-3.0.5.RELEASE.jar
portlet-api-2.0.jar
Platform-3.8.0.jar
jdo-2.0.jar
kodo-runtime.jar
openjpa-1.0-fast.jar
PlanOpt-3.8.0.jar
RailOptBase-3.8.0.jar
portletfaces-bridge-api-2.0.0-RC1.jar
portletfaces-bridge-impl-2.0.0-RC1.jar
portletfaces-logging-1.1.0.jar
commons-collections-3.2.1.jar
spring-web-3.0.5.RELEASE.jar
aopalliance-1.0.jar
spring-beans-3.0.5.RELEASE.jar
spring-security-web-3.0.5.RELEASE.jar
spring-security-core-3.0.5.RELEASE.jar
spring-tx-3.0.3.RELEASE.jar
aspectjrt-1.6.8.jar
aspectjweaver-1.6.8.jar
spring-security-config-3.0.5.RELEASE.jar
log4j-1.2.15.jar
el-api-1.0.jar
slf4j-api-1.5.8.jar
servlet-api-2.5.jar
jstl-1.2.jar
commons-lang-2.5.jar
RailOptIntegration-3.8.0.jar
google-collections-1.0.jar
junit-4.8.2.jar
commons-io-2.0.1.jar
el-impl-2.2.jar
javax.faces-2.1.7.jar
Some dependencies have the scope "provided" and are not included in the war (as long tomcat doesn't use them)!
Part of my portlet.xml
<filter>
<filter-name>PortletSecurityFilter</filter-name>
<filter-class>com.qnamic.railopt.web.security.portlet.PortletSecurityFilter</filter- class>
<lifecycle>ACTION_PHASE</lifecycle>
<lifecycle>EVENT_PHASE</lifecycle>
<lifecycle>RENDER_PHASE</lifecycle>
<lifecycle>RESOURCE_PHASE</lifecycle>
<init-param>
<name>message</name>
<value>Security Filter</value>
</init-param>
</filter>
<filter-mapping>
<filter-name>PortletSecurityFilter</filter-name>
<portlet-name>*</portlet-name>
</filter-mapping>
The other dependencies are found in a parent project:
pc-api-2.2.0-GA.jar
pc-controller-2.2.0-GA.jar
pc-portlet-2.2.0-GA.jar
pc-mc-2.2.0-GA.jar
wci-wci-2.1.1-GA.jar
wci-tomcat7-2.1.1-GA.jar
When I debug the code in
org.gatein.pc.portlet.impl.jsr168.ClassInstanceLifeCycle.create(...)
it stops on the second line
Class clazz = classLoader.loadClass(className);
if (expectedClass.isAssignableFrom(clazz)) {
Class<? extends T> castedClass = clazz.asSubclass(expectedClass);
Constructor<? extends T> ctor = castedClass.getConstructor();
instance = ctor.newInstance();
}
else {
String msg = "Cannot create " + type + " with class " + className + " because it does not implement the expected interface " + expectedClass.getName();
throw new PortletInitializationException(msg);
}
My suggestion was first that there is a problem with the class loader but it shouldn't be, because the first line correctly loads the class PortletSecurityFilter. The expected class is javax.portlet.filter.PortletFilter as expected. Why the class is not assignable from?
I thank for any help!
I must admit that I have no idea what is the exact version of GateIn you used to meet this issue but anyway I could reproduce this issue with GateIn-3.2.0.Final-tomcat7 by simply keeping (on purpose) portlet-api-2.0.jar in the WEB-INF/lib directory of my war file. I could then get something like:
28 janv. 2013 15:48:09 org.gatein.common.logging.Logger log
GRAVE: Cannot start object
org.gatein.pc.portlet.container.PortletInitializationException: Cannot create filter with class org.exoplatform.tutorial.portlet.MyPortletFilter because it does not implement the expected interface javax.portlet.filter.PortletFilter
at org.gatein.pc.portlet.impl.jsr168.ClassInstanceLifeCycle.create(ClassInstanceLifeCycle.java:85)
at org.gatein.pc.portlet.impl.jsr168.PortletFilterImpl.start(PortletFilterImpl.java:144)
at org.gatein.pc.portlet.impl.container.PortletFilterLifeCycle.invokeStart(PortletFilterLifeCycle.java:66)
at org.gatein.pc.portlet.impl.container.LifeCycle.managedStart(LifeCycle.java:93)
at org.gatein.pc.portlet.impl.container.PortletApplicationLifeCycle.startDependents(PortletApplicationLifeCycle.java:339)
at org.gatein.pc.portlet.impl.container.LifeCycle.managedStart(LifeCycle.java:129)
at org.gatein.pc.portlet.impl.deployment.PortletApplicationDeployment.install(PortletApplicationDeployment.java:153)
at org.gatein.pc.portlet.impl.deployment.PortletApplicationDeployer.add(PortletApplicationDeployer.java:199)
at org.gatein.pc.portlet.impl.deployment.PortletApplicationDeployer.onEvent(PortletApplicationDeployer.java:168)
at org.gatein.wci.impl.DefaultServletContainer.safeFireEvent(DefaultServletContainer.java:200)
at org.gatein.wci.impl.DefaultServletContainer.addWebAppListener(DefaultServletContainer.java:166)
at org.gatein.pc.portlet.impl.deployment.PortletApplicationDeployer.start(PortletApplicationDeployer.java:241)
at org.exoplatform.portal.pc.ExoKernelIntegration.start(ExoKernelIntegration.java:178)
at sun.reflect.GeneratedMethodAccessor53.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.exoplatform.container.LifecycleVisitor.traverse(LifecycleVisitor.java:100)
at org.exoplatform.container.LifecycleVisitor.start(LifecycleVisitor.java:170)
at org.exoplatform.container.ConcurrentPicoContainer.start(ConcurrentPicoContainer.java:554)
at org.exoplatform.container.ExoContainer.start(ExoContainer.java:266)
at org.exoplatform.container.PortalContainer.start(PortalContainer.java:667)
at org.exoplatform.container.ExoContainer.start(ExoContainer.java:254)
at org.exoplatform.container.RootContainer.createPortalContainer(RootContainer.java:399)
at org.exoplatform.container.RootContainer.registerPortalContainer(RootContainer.java:266)
at org.exoplatform.portal.application.PortalController.afterInit(PortalController.java:114)
at org.exoplatform.container.web.AbstractHttpServlet.init(AbstractHttpServlet.java:79)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1201)
I could fix it by simply removing portlet-api-2.0.jar from WEB-INF/lib of my webapp (or defining this dependency in maven as provided). This happens simply because the jar file is already in tomcat/lib so the Portlet Container refers to the class javax.portlet.filter.PortletFilter that has been loaded from the common ClassLoader of Tomcat and your Filter implements the class javax.portlet.filter.PortletFilter that has been loaded from the ClassLoader of your webapp (from WEB-INF/lib), even if the FQN of these 2 classes are equal, they are not considered as the same classes that is the reason why expectedClass.isAssignableFrom(clazz) returns false.