我刚刚阅读了"掌握EJB 3.0"的事务章节(10),现在我对嵌套事务感到困惑.
这本书说
"EJB定义的事务管理器不支持嵌套事务;它只需要支持平面事务." (网站278,注)
这个事实不仅在本书中有所描述,我在其他书籍/网站上发现了这一说法.
但是,如果我从a调用一个"Requires New"注释方法,让我们说"必需"注释Methode,我所拥有的是一个嵌套事务,不是吗?我可以回滚内部事务或提交它,而不会影响外部事务.如果我想要中止外部事务,我会抛出一个EJBException,整个事务将被回滚.
那么,只是EJB 3.0规范不要求这种行为,或者我误解了什么?我无法区分嵌套事务和描述的行为.
关心诺曼
根据"使用MySQL群集扩展Web数据库指南",MySQL Cluster 7.3可以在使用同步更新复制时获得99,999%的可用性.这将是CAP定理的一个对立面,因为它表明完美的可用性(99,999%可以看作是这样,没有?)并且在分布式系统中一致性是不可行的.
如果无法访问负责副本的datanode,群集将如何响应更新?对于同步更新复制,它必须阻止,这将影响可用性.
指南指出:
- 数据节点内的数据同步复制到节点组内的所有节点.如果数据节点发生故障,则始终存在至少一个存储相同信息的其他数据节点.
- 如果数据节点发生故障,MySQL服务器或应用程序节点可以使用节点组中的任何其他数据节点来执行事务.应用程序只是重试事务,其余数据节点将成功满足请求.
但是,如果节点组包含两个节点和一个崩溃(例如此处),那么它如何工作呢?根据我的理解,没有Node可以将更新复制到使用同步更新复制时更新失败的内容?!复制是否只是在没有节点写入副本的时候暂停?
我有一个Bean,它有一个对象列表,包含表示数据库中图像的StreamedContent对象(Primefaces Type).现在我想在JSF 2.0页面(使用Primefaces)中遍历此列表,并显示图像.以这种方式只显示一个图像有效:
<p:graphicImage value="#{ImageLoader.oneImage}" title="aImage" alt="no Img"/>
Run Code Online (Sandbox Code Playgroud)
但是,如果我将此标记嵌套在ac:foreach,ui:repeat或p:datatable中,则不会加载图像!而是显示替代文本
<ui:repeat value="#{ImageLoader.allImages}" var="img">
<p:graphicImage value="#{img}" alt="Hier sollte ein Bild sein" />
<br/>
</ui:repeat>
Run Code Online (Sandbox Code Playgroud)
图像加载器Bean:
@Named(value = "ImageLoader")
@Stateless
public class ImageLoader {
@Inject
private ImageFacade imgFacade;
private List<StreamedContent> allImages = new ArrayList <>();
private StreamedContent oneImage;
public StreamedContent getOneImage() {
List<Image> findAll = imgFacade.findAll();
byte[] imagedata = findAll.get(0).getImagedata();
StreamedContent retVal = new DefaultStreamedContent(new ByteArrayInputStream(imagedata));
return retVal;
}
public void setOneImage(StreamedContent oneImage) {
this.oneImage = oneImage;
}
public List<StreamedContent> getAllImages() {
List<Image> …Run Code Online (Sandbox Code Playgroud) 我的节点应用程序的相关Express部分:
/*Route to Product Views*/
app.get('/product/:id', function(req, res){
Product.find({_id: req.params.id}, function (error, data) {
if(error){
console.log(error);
} else {
console.log("DATA :" + data); //correct json object
res.render('product',{
title: 'Product Template',
result: data
}
);
}
});
});
Run Code Online (Sandbox Code Playgroud)
玉模板:
!!! 5
html
head
title #{title}
body
h1 #{result.name}
h2 #{result.unitprice}
p.
#{result.description}
h3 #{result}
Run Code Online (Sandbox Code Playgroud)
所以如果我vistit http://myhost.com/product/51fa8402803244fb12000001,我看到的是h3#{result}的输出,它是:
[{
__v: 0,
_id: 51fa8402803244fb12000001,
description: 'Awesome stuff you really need',
discontinued: false,
name: 'Some product',
unitprice: 5.99
}]
Run Code Online (Sandbox Code Playgroud)
使用JSON.stringify没有区别,除了h3#{result}返回"stringified"JSON.如何正确访问json字符串的字段?
建立:
在登录表单中键入有效的用户凭据后,我将登录并重定向到下一页.但是如果我离开那个页面并转到另一个页面,当然是在允许的url-pattern中,我得到"HTTP状态403-对所请求资源的访问被拒绝".之后我再也无法访问webapp的任何网站了.
如果我将glassfish的server-config/security中的Standard-Realm设置为我自己的领域,那么登录才有效!
我在部署时在服务器日志中收到一条警告:
Warnung: Keine Principals zugeordnet zu Rolle [USER].
(Warning: No principals mapped to role [USER])
Run Code Online (Sandbox Code Playgroud)
如果我使用Chrome Debugger删除JSESSIONID,我可以再次登录.在访问一个允许的网站之后看起来会在服务器端销毁会话?!
我附上了一些相关来源.我认为它与Realm等无关,因为登录机制有效并且没有例外......
web.xml中
<login-config>
<auth-method>FORM</auth-method>
<realm-name>jdbcRealm</realm-name>
<form-login-config>
<form-login-page>/faces/login.xhtml</form-login-page>
<form-error-page>/faces/loginError.xhtml</form-error-page>
</form-login-config>
</login-config>
<security-constraint>
<web-resource-collection>
<web-resource-name>User</web-resource-name>
<url-pattern>/faces/user/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>ADMIN</role-name>
</auth-constraint>
</security-constraint>
Run Code Online (Sandbox Code Playgroud)
glassfish-web-app.xml(手动添加)
<glassfish-web-app>
<security-role-mapping>
<role-name>USER</role-name>
<group-name>USER</group-name>
</security-role-mapping>
</glassfish-web-app>
Run Code Online (Sandbox Code Playgroud)
login.xhtml
<h:form>
<h:outputLabel for="usernameInput">
Username:
</h:outputLabel>
<h:inputText id="usernameInput" value="#{authBackingBean.username}"
required="true" />
<br />
<h:outputLabel for="passwordInput">
Password:
</h:outputLabel>
<h:inputSecret id="passwordInput" value="#{authBackingBean.password}"
required="true" />
<br />
<h:commandButton value="Login"
action="#{authBackingBean.login}" /> …Run Code Online (Sandbox Code Playgroud) jsf-2 ×2
consistency ×1
ejb-3.0 ×1
express ×1
glassfish-3 ×1
iteration ×1
jaas ×1
java-ee ×1
json ×1
mysql ×1
node.js ×1
primefaces ×1
pug ×1
transactions ×1