URL Rewriting Param SET only on second access
elnino Apr 29, 2009 6:00 PMHello,
Two days checking my configurations... Googleling, reading docs, try demos etc...
I have a problem...
Help !
Context
I'am using URL Rewriting with rewrite patterns in each .page.xml file.
I would like to have bookmarkable URLs as the BlogEntry exemple... In the URL I have an entity Id sets on page access to load an entity and outject it to the page.
Considering that I have in testPage.page.xml:
<rewrite pattern="/myPageTest-{entityId}.html" /> <rewrite pattern="/myPageTest.html" /> <param name="entityId" converterId="javax.faces.Long" value="#{entityDataLoader.entityId}" />
I have the bean:
@Name("entityDataLoader") public class EntityDataLoader implements IEntityDataLoader { @In private EntityManager entityManager; private Long entityId; public void setEntityId(Long entityId) { this. entityId = entityId; } @Out(required = false) private Entity outjectEntity; @Factory("loadedEntity") public void loadEntity() { if (entityId != null) outjectEntity = entityManager.find(Entity.class,entityId); } }
I myTestPage.xhtml, I am using loadedEntity... The loadEntity() method is correctly called.
Problem description
It's perfectly working if I have already made an access to a page.
For example:
- 1°) Going to home page
- 2°) Then typing http://www.GavinKingIsAGod.com/myPageTest-4.html
- 3°) Perfectly working ! The setMethod is called and the entity loaded...
BUT
- 0°)Reset session (by taking another browser or restart JBoss server)
- 1°)Going direclty to http://www.GavinKingIsAGod.com/myPageTest-4.html The page is found, displayed... But the entity is not loaded... The method setEntityId is not called !
- 2°)Retrying to go to http://www.GavinKingIsAGod.com/myPageTest-4.html Perfectly working...
The problem is only for FIRST access... After, all URL rewriting is working with all parameters...
So the URL is not bookmarkable, because, on first access the entity is not load.
If someone calls the page http://www.GavinKingIsAGod.com/myPageTest-4.html from google for example, the entity won't load directly... If he retries, it works.
Tests I have made
Access with ?entityId
When I access to the page via
http://www.StopBeingNice.com/myPageTest.html?entityId=4
It's working... So I suspect an URL Rewriting problem !
Need getEntityId()
In my bean, I had to add the method
public Long getEntityId()
Otherwise I get the following error:
Property 'entityId' not readable on type java.lang.Long
I don't understand Why... He needs to read the entityId....
Configuration
Component.xml
<web:rewrite-filter view-mapping="*.seam" /> <web:redirect-filter url-pattern="*.seam" /> <web:character-encoding-filter encoding="UTF-16" override-client="true" url-pattern="*.seam" />
Web.xml
<filter> <filter-name>Seam Filter</filter-name> <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class> </filter> <filter-mapping> <filter-name>Seam Filter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>ERROR</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>REQUEST</dispatcher> <dispatcher>INCLUDE</dispatcher> </filter-mapping>
Environment
I'am running on JBoss AS 4.2.3 and JBoss Seam 2.1.1 GA
Log
When JBoss is completely started I have in the console
17:56:25,893 INFO [Initialization] done initializing Seam 17:56:25,896 INFO [SeamFilter] Initializing filter: org.jboss.seam.web.hotDeployFilter 17:56:25,896 INFO [SeamFilter] Initializing filter: org.jboss.seam.web.loggingFilter 17:56:25,896 INFO [SeamFilter] Initializing filter: org.jboss.seam.web.ajax4jsfFilter 17:56:25,927 INFO [CacheManager] Selected [org.ajax4jsf.cache.LRUMapCacheFactory] cache factory 17:56:25,930 INFO [LRUMapCacheFactory] Creating LRUMap cache instance using parameters: {com.sun.faces.injectionProvider=org.jboss.web.jsf.integration.injection.JBossInjectionProvider, facelets.LIBRARIES=/WEB-INF/custom.taglib.xml, facelets.DEVELOPMENT=true, org.richfaces.SKIN=blueSky, javax.faces.DEFAULT_SUFFIX=.xhtml} 17:56:25,930 INFO [LRUMapCacheFactory] Creating LRUMap cache instance of default capacity 17:56:25,949 INFO [CacheManager] Selected [org.ajax4jsf.cache.LRUMapCacheFactory] cache factory 17:56:25,950 INFO [LRUMapCacheFactory] Creating LRUMap cache instance using parameters: {com.sun.faces.injectionProvider=org.jboss.web.jsf.integration.injection.JBossInjectionProvider, facelets.LIBRARIES=/WEB-INF/custom.taglib.xml, facelets.DEVELOPMENT=true, org.richfaces.SKIN=blueSky, javax.faces.DEFAULT_SUFFIX=.xhtml} 17:56:25,950 INFO [LRUMapCacheFactory] Creating LRUMap cache instance of default capacity 17:56:25,950 INFO [SeamFilter] Initializing filter: org.jboss.seam.web.redirectFilter 17:56:25,950 INFO [SeamFilter] Initializing filter: org.jboss.seam.web.exceptionFilter 17:56:25,950 INFO [SeamFilter] Initializing filter: org.jboss.seam.web.multipartFilter 17:56:25,950 INFO [SeamFilter] Initializing filter: org.jboss.seam.web.identityFilter 17:56:25,950 INFO [SeamFilter] Initializing filter: org.jboss.seam.web.rewriteFilter 17:56:25,950 INFO [SeamFilter] Initializing filter: org.jboss.seam.servlet.characterEncodingFilter 17:56:25,950 INFO [SeamFilter] Initializing filter: org.jboss.seam.debug.hotDeployFilter 17:56:25,995 INFO [EARDeployer] Started J2EE application: file:/Applications/Eclipse/jboss-4.2.3.GA/server/default/deploy/BugTest-ear.ear/ 17:56:26,084 INFO [Http11Protocol] Démarrage de Coyote HTTP/1.1 sur http-localhost%2F127.0.0.1-8080 17:56:26,099 INFO [AjpProtocol] Starting Coyote AJP/1.3 on ajp-localhost%2F127.0.0.1-8009 17:56:26,108 INFO [Server] JBoss (MX MicroKernel) [4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)] Started in 1m:10s:332ms
On first access I get this in the console:
17:56:26,108 INFO [Server] JBoss (MX MicroKernel) [4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)] Started in 1m:10s:332ms 17:57:00,267 INFO [Contexts] starting up: org.jboss.seam.web.session 17:57:00,268 INFO [Contexts] starting up: org.jboss.seam.security.ruleBasedPermissionResolver 17:57:00,269 INFO [Contexts] starting up: org.jboss.seam.security.identity 17:57:01,102 ERROR [STDERR] 29 avr. 2009 17:57:01 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/Applications/Eclipse/jboss-4.2.3.GA/server/default/deploy/BugTest-ear.ear/BugTest.war/WEB-INF/lib/jboss-seam-mail.jar!/META-INF/seam-mail.taglib.xml 17:57:01,107 ERROR [STDERR] 29 avr. 2009 17:57:01 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/Applications/Eclipse/jboss-4.2.3.GA/server/default/deploy/BugTest-ear.ear/BugTest.war/WEB-INF/lib/jboss-seam-pdf.jar!/META-INF/seam-pdf.taglib.xml 17:57:01,125 ERROR [STDERR] 29 avr. 2009 17:57:01 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/Applications/Eclipse/jboss-4.2.3.GA/server/default/deploy/BugTest-ear.ear/BugTest.war/WEB-INF/lib/jboss-seam-ui.jar!/META-INF/s.taglib.xml 17:57:01,146 ERROR [STDERR] 29 avr. 2009 17:57:01 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/Applications/Eclipse/jboss-4.2.3.GA/server/default/deploy/BugTest-ear.ear/BugTest.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jsf-core.taglib.xml 17:57:01,152 ERROR [STDERR] 29 avr. 2009 17:57:01 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/Applications/Eclipse/jboss-4.2.3.GA/server/default/deploy/BugTest-ear.ear/BugTest.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jsf-html.taglib.xml 17:57:01,168 ERROR [STDERR] 29 avr. 2009 17:57:01 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/Applications/Eclipse/jboss-4.2.3.GA/server/default/deploy/BugTest-ear.ear/BugTest.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jsf-ui.taglib.xml 17:57:01,187 ERROR [STDERR] 29 avr. 2009 17:57:01 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/Applications/Eclipse/jboss-4.2.3.GA/server/default/deploy/BugTest-ear.ear/BugTest.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jstl-core.taglib.xml 17:57:01,192 ERROR [STDERR] 29 avr. 2009 17:57:01 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/Applications/Eclipse/jboss-4.2.3.GA/server/default/deploy/BugTest-ear.ear/BugTest.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jstl-fn.taglib.xml 17:57:01,208 ERROR [STDERR] 29 avr. 2009 17:57:01 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/Applications/Eclipse/jboss-4.2.3.GA/server/default/deploy/BugTest-ear.ear/BugTest.war/WEB-INF/lib/richfaces-ui-3.3.0.GA.jar!/META-INF/a4j.taglib.xml 17:57:01,216 ERROR [STDERR] 29 avr. 2009 17:57:01 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/Applications/Eclipse/jboss-4.2.3.GA/server/default/deploy/BugTest-ear.ear/BugTest.war/WEB-INF/lib/richfaces-ui-3.3.0.GA.jar!/META-INF/ajax4jsf.taglib.xml 17:57:01,225 ERROR [STDERR] 29 avr. 2009 17:57:01 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/Applications/Eclipse/jboss-4.2.3.GA/server/default/deploy/BugTest-ear.ear/BugTest.war/WEB-INF/lib/richfaces-ui-3.3.0.GA.jar!/META-INF/jsp.taglib.xml 17:57:01,272 ERROR [STDERR] 29 avr. 2009 17:57:01 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/Applications/Eclipse/jboss-4.2.3.GA/server/default/deploy/BugTest-ear.ear/BugTest.war/WEB-INF/lib/richfaces-ui-3.3.0.GA.jar!/META-INF/rich.taglib.xml 17:57:01,285 ERROR [STDERR] 29 avr. 2009 17:57:01 com.sun.facelets.compiler.TagLibraryConfig loadImplicit INFO: Added Library from: jar:file:/Applications/Eclipse/jboss-4.2.3.GA/server/default/deploy/BugTest-ear.ear/BugTest.war/WEB-INF/lib/richfaces-ui-3.3.0.GA.jar!/META-INF/richfaces.taglib.xml
I think something is initialized here that it isn't before...
Thanks to read all... If you need more infos.. just ask