zengkid / SmartTomcat

The Tomcat plugin for Intellij IDEA
Apache License 2.0
122 stars 56 forks source link

Annotation scanning not working properly for JSF application #80

Closed gogognome closed 2 months ago

gogognome commented 2 years ago

I am working on a JSF application with ICEFaces 3, JSF 2, deployed on Tomcat 7. I use IntelliJ ultimate, which uses a different plugin to deploy an exploded WAR file in Tomcat. One colleague of mine uses Eclipse to run Tomcat. Recently we have a new team member who uses IntelliJ Community Edition with Smart Tomcat. He is the only team member that has problems when running the application in Tomcat.

The application works well when it is deployed with Smart Tomcat. However, we discovered that some managed beans are not available to the application when it its deployed with Smart Tomcat. This breaks a couple of pages in our application that use those beans. We discovered that all beans that are configured in faces-config.xml are working fine, but all beans that are configured using annotations (e.g. @ManagedBean and @Session) are absent at runtime.

We debugged the annotation processing code and discovered that some annotated classes are actually discovered: the classes in the dependencies of our application (e.g., ICEFaces jars). We suspect that the way that Smart Tomcat deals with classpaths somehow breaks the annotation scanning of the classes of our own application.

Is there some configuration we can change in Smart Tomcat to fix this?

tb12315 commented 2 years ago

你发的邮件我已经收到。会在近期内查看。

zengkid commented 2 years ago

@gogognome I have no experience for JSF, but for classpath, you can check the jars are in $user_home/.SmartTomcat///conf/server.xml. if not in it, you need check your project dependencies.

ismail-bertalfilali commented 5 months ago

In the scenario where we encountered the issue with Tomcat 7.0.109 not scanning annotations like @WebServlet and @WebFilter, we discovered a workaround by manually creating a context.xml file in the /webapp/META-INF/ directory. Here's the content we added:

`<?xml version='1.0' encoding='utf-8'?>

`

This manual intervention ensures that the JarScanner component is instructed to thoroughly scan all directories, thus recognizing the annotations within our project.

Considering the capabilities of the SmartTomcat plugin, an enhancement that seems both logical and beneficial would be to enable SmartTomcat to automatically generate and include this specific context.xml content within the conf/context.xml. This feature could greatly simplify project setups by ensuring annotations are automatically scanned, reducing the manual configuration tasks we need to handle.