Issues with rewrite and Weld not working

Splash Forums Rewrite Users Issues with rewrite and Weld not working

This topic contains 3 replies, has 2 voices, and was last updated by  Christian Kaltepoth 1 month ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #27741

    maqjav
    Participant

    Hello.

    I tried running rewrite with weld.servlet.shaded 3.0.0.Final and the rewriting of the URL stops working.
    The redirections work, but the URL doesn’t change.

    If I remove from my project WELD, everything works as intended.

    I’m using the next libraries:

    <dependency>
    	<groupId>org.ocpsoft.rewrite</groupId>
    	<artifactId>rewrite-servlet</artifactId>
    	<version>3.4.1.Final</version>
     </dependency>
     <dependency>
    	<groupId>org.ocpsoft.rewrite</groupId>
    	<artifactId>rewrite-integration-faces</artifactId>
    	<version>3.4.1.Final</version>
     </dependency>
     <dependency>
    	<groupId>org.jboss.weld.servlet</groupId>
    	<artifactId>weld-servlet-shaded</artifactId>
    	 <version>3.0.0.Final</version>
     </dependency>

    Here is my HttpConfigurationProvider

    `@RewriteConfiguration
    public class MyConfigurationProvider extends HttpConfigurationProvider {

    @Override
    public Configuration getConfiguration(ServletContext context) {
    ConfigurationBuilder builder = ConfigurationBuilder.begin();
    builder.addRule(Join.path(“/login”).to(/pages/login.xhtml));
    return builder;
    }

    @Override
    public int priority() {
    return 10;
    }

    }`

    As I said, with WELD the redirection works if I write in my browser “/login” it redirects to “/pages/login.xhtml”, however, in my browser I see “/pages/login.xhtml” and not “/login”.

    Thanks.

    #27742

    Try adding rewrite-integration-cdi to your dependencies.

    #27743

    maqjav
    Participant

    Adding that dependency I get the next error:

    org.ocpsoft.rewrite.cdi.manager.BeanManagerUnavailableException: Failed to locate BeanManager using any of these providers: org.ocpsoft.rewrite.cdi.manager.DefaultJndiBeanManagerProvider(10), org.ocpsoft.rewrite.cdi.manager.ServletContainerJndiBeanManagerProvider(11)
    	at org.ocpsoft.rewrite.cdi.manager.BeanManagerLocator.getBeanManager(BeanManagerLocator.java:85)
    	at org.ocpsoft.rewrite.cdi.manager.BeanManagerAware.getBeanManager(BeanManagerAware.java:52)
    	at org.ocpsoft.rewrite.cdi.CdiServiceEnricher.produce(CdiServiceEnricher.java:45)
    	at org.ocpsoft.common.services.ServiceLoader.loadEnriched(ServiceLoader.java:297)
    	at org.ocpsoft.common.services.ServiceLoader.loadClass(ServiceLoader.java:243)
    	at org.ocpsoft.common.services.ServiceLoader.loadService(ServiceLoader.java:234)
    	at org.ocpsoft.common.services.ServiceLoader.loadServiceFile(ServiceLoader.java:196)
    	at org.ocpsoft.common.services.ServiceLoader.reload(ServiceLoader.java:145)
    	at org.ocpsoft.common.services.ServiceLoader.iterator(ServiceLoader.java:394)
    	at org.ocpsoft.common.util.Iterators.asList(Iterators.java:40)
    	at org.ocpsoft.rewrite.servlet.RewriteFilter.init(RewriteFilter.java:87)
    	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
    	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
    	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
    	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4590)
    	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5233)
    	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
    	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    	at java.lang.Thread.run(Thread.java:748)

    However, I have in my context.xml the next configuration:

    <Context allowCasualMultipartParsing="true">
    	<Resource name="BeanManager" 
            auth="Container"
            type="javax.enterprise.inject.spi.BeanManager"
            factory="org.jboss.weld.resources.ManagerObjectFactory" />
    </Context>

    And in my web.xml:

    <resource-env-ref>
    		<resource-env-ref-name>BeanManager</resource-env-ref-name>
    		<resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
    	</resource-env-ref>

    I tried adding this dependency too, but this new error persists:

    <dependency>
    		    <groupId>javax.enterprise</groupId>
    		    <artifactId>cdi-api</artifactId>
    		    <version>2.0</version>
    		</dependency>
    #27744

    Yeah, unfortunately you have to provide a custom BeanManagerProvider if you are on CDI 2.0… That’s sad…

    However, actually I don’t think you really need rewrite-integration-cdi. Not sure what your issue is.

    You wrote that you are redirected to the xhtml version of the URL? Not sure why this is happening. You configuration doesn’t instruct any redirect. It just configures Rewrite to forward the requests.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Comments are closed.