我在eclipse IDE中重启服务器后使用tomd v7和Weld v2.2.9.Final和myFaces v2.2.7并重新加载页面我收到此错误.我不知道为什么会出现这个错误.它必须与http请求左右连接.如果我打开关闭浏览器它开始工作.
SEVERE: Exception sending request initialized lifecycle event to listener instance of class org.jboss.weld.environment.servlet.Listener
org.jboss.weld.exceptions.IllegalStateException: WELD-000227: Bean identifier index inconsistency detected - the distributed container probably doesn't work with identical applications
at org.jboss.weld.context.http.HttpSessionContextImpl.checkBeanIdentifierIndexConsistency(HttpSessionContextImpl.java:88)
at org.jboss.weld.context.http.HttpSessionContextImpl.associate(HttpSessionContextImpl.java:42)
at org.jboss.weld.context.http.HttpSessionContextImpl.associate(HttpSessionContextImpl.java:19)
at org.jboss.weld.servlet.HttpContextLifecycle.requestInitialized(HttpContextLifecycle.java:217)
at org.jboss.weld.servlet.WeldInitialListener.requestInitialized(WeldInitialListener.java:160)
at org.jboss.weld.servlet.api.helpers.ForwardingServletListener.requestInitialized(ForwardingServletListener.java:42)
at org.apache.catalina.core.StandardContext.fireRequestInitEvent(StandardContext.java:6189)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Run Code Online (Sandbox Code Playgroud) 我有一个CDI托管bean,我想将请求参数设置为托管属性:
import javax.inject.Named;
import javax.enterprise.context.RequestScoped;
@Named
@RequestScoped
public class ActivationBean implements Serializable {
@ManagedProperty(value="#{param.key}")
private String key;
@ManagedProperty(value="#{param.id}")
private Long id;
// Getters+setters
Run Code Online (Sandbox Code Playgroud)
domain/activate.jsf?key=98664defdb2a4f46a527043c451c3fcd&id=5
但是,URL是永远不会设置和保留的属性null
.
这是怎么造成的,我该如何解决?
我知道我可以从ExternalContext
下面手动抓取它们:
Long id = Long.parseLong(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("id"), 10);
String key = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("key");
Run Code Online (Sandbox Code Playgroud)
但是,我宁愿使用注射剂.
jsf cdi managed-bean http-request-parameters managed-property
我有一个JSF,CDI项目的问题.我做了很多研究,我发现在CDI中没有@ViewedScoped
注释.我用对话框解决了基于ajax的页面的问题.我想从datatable传递变量到对话框.为此,我不能使用@RequestedScoped
bean,因为在请求结束后丢弃值.任何人都可以帮我解决吗?我不能用,@SessionScoped
但这是一个不好的做法恕我直言.或者也许只将这一个变量保存到知道的会话中.你们能给我任何提示如何优雅地解决这个问题吗?
import javax.enterprise.context.ApplicationScoped;
@ApplicationScoped
public class ServiceBean implements Serializable {
...
Run Code Online (Sandbox Code Playgroud)
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
@ManagedBean
@ViewScoped
public class SomeBean {
@Inject
ServiceBean serviceBean;
@Postconstruct ...
Run Code Online (Sandbox Code Playgroud)
这是错误消息:
com.sun.faces.mgbean.ManagedBeanCreationException: An error occurred performing resource injection on managed bean warDetailBean
Run Code Online (Sandbox Code Playgroud) 是否可以将JPA中的字母排序更改为自定义?
我在列中有此数据division
:
BRONZE
SILVER
GOLD
DIAMOND
Run Code Online (Sandbox Code Playgroud)
我已经将其映射到实体字段:
public enum Division {
BRONZE,
SILVER,
GOLD,
DIAMOND
}
@Entity
public class MyEntity {
@Enumerated(EnumType.STRING)
private Division division;
...
}
Run Code Online (Sandbox Code Playgroud)
如果我使用默认排序,则会得到字母顺序:
但我想按矿石质量(按枚举顺序)排序。
我目前正在使用PhaseListener
如下方法来执行用户授权.
private PhaseId phaseId = PhaseId.RESTORE_VIEW;
@Override
public void afterPhase(PhaseEvent event) {
FacesContext fc = event.getFacesContext();
boolean isOnAllowedPage = false;
String[] allowedPages = choseRightPages(); // chose pages for role
for (String s : allowedPages) {
if (fc.getViewRoot().getViewId().lastIndexOf(s) > -1) {
isOnAllowedPage = true;
break;
}
}
if (!isOnAllowedPage) {
NavigationHandler nh = fc.getApplication().getNavigationHandler();
nh.handleNavigation(fc, null, "prohibited");
}
}
Run Code Online (Sandbox Code Playgroud)
它做我想要的,但我没有看到它列在如何处理数据库中的用户的身份验证/授权?而这个名为"使用phaselistener问题的授权"的Coderanch主题也提到了以下内容:
您不应该将与JSF紧密相关的授权结合在一起.更好地利用容器管理的身份验证和/或作用于覆盖受保护页面的url模式的简单过滤器.
我并不完全理解在执行用户授权时使用a PhaseListener
而不是a 的限制Filter
.有人可以向我解释一下吗?
在遗留代码中,我解决了嵌套事务的问题.(Spring,CDI等不能只使用纯JPA(EclipseLink))
em.getTransaction().begin();
em.persist(client);
em2.getTransaction().begin();
em2.persist(client1); //saved into DB
em2.getTransaction().commit();
em.getTransaction().rollback();
public void method(){
EntityManager em = entityManagerFactory.createEntityManager();
em.getTransaction().begin();
em.persist(client);
nestedTransactionMethod();
em.getTransaction().rollback();
}
public void nestedTransactionMethod(){
EntityManager em = entityManagerFactory.createEntityManager();
em.getTransaction().begin();
em.persist(client);
em.getTransaction().commit();
}
Run Code Online (Sandbox Code Playgroud)
问题是当我调用inside方法时,在其中打开事务的另一个方法是自我事务,而不是表现为原子.有没有解决方法如何实现这一点而不给出开放的实体经理作为参数?
cdi ×3
jsf ×3
jpa ×2
jsf-2 ×2
eclipselink ×1
hibernate ×1
java ×1
java-ee ×1
managed-bean ×1
postgresql ×1
tomcat ×1
transactions ×1
view-scope ×1
weld ×1