Carm2501 / Quarkus

Migrate Application from Widlfly to Quarkus
0 stars 0 forks source link

.jsf is not displayed on Quarkus #1

Open Carm2501 opened 4 years ago

Carm2501 commented 4 years ago

Hi, I'm trying to migrate my application "my-aktion" from wildfly to quarkus. I know that quarkus works differently with CDIs, so I tried to update the code. I also added the jsf extension. When my application is deployed and I'm trying to access the main page http://localhost:8080/listCampaigns.jsf page it says "not found". When trying to access the same page in .xhtml is says the following error:

@Dependent on beans used in EL are currently not supported! Class: class de.dpunkt.myaktion.data.CampaignListProducer

viewId=/listCampaigns.xhtml location=C:\Users\student\ESD\Maven-Projekte\my-aktionQCDI\src\main\resources\META-INF\resources\listCampaigns.xhtml phaseId=RENDER_RESPONSE(6)

Caused by: javax.faces.FacesException - @Dependent on beans used in EL are currently not supported! Class: class de.dpunkt.myaktion.data.CampaignListProducer at org.apache.myfaces.core.extensions.quarkus.runtime.spi.QuarkusCdiELResolver.resolveProxy(QuarkusCdiELResolver.java:110)

I had one @Dependent Annoation in the Code and I replaced it with a @SessionScoped but the error is still there. Regarding the official Quarkus CDI page (https://quarkus.io/guides/cdi-reference) Beans are automatically declared as @Dependent, when there is no specific annotation. But all my beans have a scope annoation.

As I'm new to all of this, can somebody please help? @tandraschko?

My code: https://github.com/Carm2501/Quarkus

tandraschko commented 4 years ago

post your CampaignListProducer

Carm2501 commented 4 years ago

`package de.dpunkt.myaktion.data;

import de.dpunkt.myaktion.model.Campaign; import de.dpunkt.myaktion.services.CampaignService; import de.dpunkt.myaktion.util.Events.Added; import de.dpunkt.myaktion.util.Events.Deleted;

import javax.annotation.PostConstruct; import javax.enterprise.context.SessionScoped; import javax.enterprise.event.Observes; import javax.enterprise.inject.Produces; import javax.inject.Inject; import javax.inject.Named; import java.io.Serializable; import java.util.List;

@SessionScoped public class CampaignListProducer implements Serializable {

private static final long serialVersionUID = -182866064791747156L;
private List<Campaign> campaigns;

@Inject
private CampaignService campaignService;

@PostConstruct
public void init() {
    campaigns = campaignService.getAllCampaigns();
}

@Produces
@Named
public List<Campaign> getCampaigns() {
    return campaigns;
}

public void onCampaignAdded(@Observes @Added Campaign campaign) {
    getCampaigns().add(campaign);
}

public void onCampaignDeleted(@Observes @Deleted Campaign campaign) {
    getCampaigns().remove(campaign);
}

} `

tandraschko commented 4 years ago

looks correct actually i think you need to debug by yourself in QuarkusCdiELResolver and find out why Quarkus thinks its a Dependent

tandraschko commented 4 years ago

Ah - your @Produces doesnt have a scope

Carm2501 commented 4 years ago

Thank you, that fixed the problem!