求助:PrettyFaces 3.4.2在JSF 2.2项目中请求性能极差
Hey Steve, sorry to hear you're stuck with this frustrating performance issue after adding PrettyFaces 3.4.2 to your JSF 2.2 project. Let's walk through some actionable steps to diagnose and fix the problem:
Audit your URL rewriting rules
Complex or overly broad regex patterns in yourpretty-config.xmlcan force PrettyFaces to spend excessive time matching every incoming request. Try simplifying regex to more specific path matches (e.g., use/users/{id}instead of/.+/users/.+) and reorder rules so high-traffic paths are checked first. Avoid wildcard patterns that catch more requests than necessary.Enable debug logging for PrettyFaces
Turn on DEBUG-level logging for theorg.ocpsoft.prettyfacespackage. This will show you exactly what the rewrite engine is doing for each request—look for repeated processing steps, unexpected rule matches, or long delays in rule evaluation. You can adjust your logging config (e.g., log4j, slf4j) to capture these details.Validate version compatibility
While PrettyFaces 3.4.2 claims JSF 2.2 support, there might be subtle incompatibilities causing hidden overhead. Try downgrading to the stable 3.3.4 release, or consider migrating to the OCPSoft Rewrite project (since PrettyFaces was merged into Rewrite in later versions). The Rewrite PrettyFaces module is actively maintained and may resolve performance quirks with newer JSF versions.Check for container-level rewrite conflicts
Application servers like Tomcat or WildFly often include built-in URL rewrite modules. These can clash with PrettyFaces' engine, leading to duplicate request processing. Temporarily disable the container's rewrite feature or adjust filter order to ensurePrettyFilterruns first in the filter chain.Disable unnecessary PrettyFaces features
Even with minimal config, some default features might add overhead. For example, if you're not using URL parameter encryption or session-scoped URL binding, explicitly disable them in your config:<pretty-config> <context-param name="org.ocpsoft.prettyfaces.ENCRYPTION_ENABLED" value="false"/> <context-param name="org.ocpsoft.prettyfaces.SESSION_BINDING_ENABLED" value="false"/> </pretty-config>Profile request performance
Use tools like VisualVM or JProfiler to run a performance profile of your application. Look for bottlenecks in PrettyFaces-related methods—for example, rule matching, URL parsing, or view navigation logic. This will pinpoint exactly where the performance drain is happening, making it easier to target fixes.
内容的提问来源于stack exchange,提问作者Steve

