- 浏览: 3476983 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
wanglf1207:
EJB的确是个不错的产品,只是因为用起来有点门槛,招来太多人吐 ...
weblogic-ejb-jar.xml的元素解析 -
qwfys200:
总结的不错。
Spring Web Flow 2.0 入门 -
u011577913:
u011577913 写道也能给我发一份翻译文档? 邮件437 ...
Hazelcast 参考文档-4 -
u011577913:
也能给我发一份翻译文档?
Hazelcast 参考文档-4 -
songzj001:
DbUnit入门实战
Discussion
By default JBoss (prior to version 3.2) uses a flat class loading model that avoids the need to redundantly include classes in different layers. WAR files would only have the web contents and servlets, EJBs their interfaces, implementations and types, etc. Canonical packaging works correctly with this model.
However, if you have applications that cannot share classes because of version conflicts, then you need to isolate the classes from other deployments. Without isolation, common errors seen are ClassCastException ? , IllegalAccessErrors ? , VerifyErrors ? and in general, strange behavior that changes as new deployments are added and removed.
There are two levels of scoping, isolation from other deployments, and isolation that overrides the loading of JBoss server classes. With nested modules, only the top level file may specify class loader scoping. If you have a .ear file containing other modules, only scoping specified in the .ear 's META-INF/jboss-app.xml is used. This also applies for any other deployment which contains sub-deployments. For example, if a .sar contains a .war deployment, only the .sar META-INF/jboss-service.xml scoping has effect.
Specifying Isolation
For .ear files, in your jboss-app.xml , add the following descriptor fragment construct to enabled scoped class loading:
<jboss-app> <loader-repository> com.example:archive=unique-archive-name </loader-repository> </jboss-app>
For .war files, in your jboss-web.xml , the following template applies:
<jboss-web> <class-loading> <loader-repository> com.example:archive=unique-archive-name </loader-repository> </class-loading> </jboss-web>
Note: As of at least JBoss 4.2.1, the <class-loading> tag appears to no longer be supported as isolation is ignored. Instead, the following configuration appears to accomplish the same goal:
<jboss-web> <loader-repository> com.example:archive=unique-archive-name </loader-repository> </jboss-web>Interestingly enough, 4.0.5 seems to support both configurations.
For .sar files, in your jboss-service.xml , the following template applies:
<server> <loader-repository> com.example:archive=unique-archive-name </loader-repository> </server>
The <loader-repository> elements must be correctly placed within the respective <jboss-app> , <jboss> and <jboss-web> XML elements. Check the corresponding DTD found in the docs/dtd directory of the distribution for the complete content model.
The com.example:archive=unique-archive-name strings are JMX ObjectName strings. These have no particular significance other than that they must be unique. It might be useful to use the same name as used for the .ear , .war , or .sar file. For example, for a petstore.ear file, use: com.example:loader=petstore.ear as the repository name.
The loader-repository ObjectName will appear in the JMX-Console (http://localhost:8080/jmx-console/ ). This MBean is great for debugging any class-loading issues which might arise. The hierarchical loaders created from the repository wll appear together under the loader-repository domain name, com.example in the example.
Isolation with Overriding Server Classes
Use the following constructs to enabled scoped class loading with the deployment classes overriding the server classes.
For jboss-app.xml :
<jboss-app> <loader-repository> com.example:archive=unique-archive-name <loader-repository-config> java2ParentDelegation=false </loader-repository-config> </loader-repository> </jboss-app>
For jboss-web.xml :
<jboss-web> <class-loading java2ClassLoadingCompliance="false"> <loader-repository> com.example:archive=unique-archive-name <loader-repository-config>java2ParentDelegation=false</loader-repository-config> </loader-repository> </class-loading> ...Note: See comment above regarding web class loader isolation.
For jboss-service.xml :
<server> <loader-repository> com.example:archive=unique-archive-name <loader-repository-config>java2ParentDelegation=false</loader-repository-config> </loader-repository> ...
The isolated EAR or WAR repository will load its libraries in this order:
- WEB-INF/lib (for WARs)
- libraries in server/default/lib
- tomcat-libraries in server/default/deploy/jbossweb-tomcat50.sar (jboss-3.2.6).
The Web Container
In jboss-3.2.3, the jbossweb-tomcat41.sar is configured to use a unified class loader as the web application class loader. This is controlled by the UseJBossWebLoader attribute in the jbossweb-tomcat41.sar/META-INF/jboss-service.xml descriptor. The use of a unified class loader means that the classes available in the war inside of the WEB-INF/classes and WEB-INF/lib are incorporated into the default shared class loader repository. This may not be what you want as its contrary to the default servlet 2.3 class loading model and can result in sharing of classes/resources between web applications. You can disable this by setting this attribute to false.
The Web Container from 4.0.2
From 4.0.2 JBoss has changed to the Servlet spec classloading model, i.e. it uses the Tomcat classloader. See the related JIRA Task
Simplified Configuration from 3.2.4
From JBoss-3.2.4 the EAR deployer provides a simplified version of the isolation. You can configure all your ears to be in isolated classloader spaces using call by value for remote interfaces.
The EARDeployer is configured in conf/jboss-service.xml for versions 3.x and in deploy/ear-deployer.xml for versions 4.x+
<!-- EAR deployer, remove if you are not using Web layers --> <mbean code="org.jboss.deployment.EARDeployer" name="jboss.j2ee:service=EARDeployer"> <!-- Isolate all ears in their own classloader space --> <attribute name="Isolated">true</attribute> <!-- Enforce call by value to all remote interfaces --> <attribute name="CallByValue">true</attribute> </mbean>
Accessing EJBs in isolated ears
If you want to make JNDI lookups across EARs that are isolated, you need to force marshalling of the lookup, e.g. if you have the following ejb-ref in your ejb-jar.xml that references an EJB in an isolated WAR
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd"> <ejb-jar> <enterprise-beans> <session> <ejb-name>SessionA</ejb-name> <home>org.jboss.test.isolation.interfaces.a.SessionAHome</home> <remote>org.jboss.test.isolation.interfaces.a.SessionA</remote> <ejb-class>org.jboss.test.isolation.ejb.a.SessionAEJB</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> <ejb-ref> <ejb-ref-name>ejb/SessionB</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <home>org.jboss.test.isolation.interfaces.b.SessionBHome</home> <remote>org.jboss.test.isolation.interfaces.b.SessionB</remote> </ejb-ref> </session> </enterprise-beans> </ejb-jar>
In jboss.xml use the full scheme to define the lookup:
<?xml version="1.0" encoding="UTF-8"?> <jboss> <enterprise-beans> <session> <ejb-name>SessionA</ejb-name> <ejb-ref> <ejb-ref-name>ejb/SessionB</ejb-ref-name> <jndi-name>jnp://${jboss.bind.address:localhost}:1099/SessionB</jndi-name> </ejb-ref> </session> </enterprise-beans> </jboss>
You can also use the full scheme in lookups from non-EJB clients such as standalone applications or JSP pages. In this case you would be encoding deployment knowledge into the code - the applications will always use call-by-value even if your needs change. If you are retro-fitting classloader isolation you may also have a lot of lookup code to change, although you should probably have used a constant or lookup service to hold the actual name.
An alternative is to force all JNDI lookups to be call-by-value, which you can do in <server>/deploy/naming-service.xml (This used to reference <server>/conf/jboss-service.xml, which is WRONG for 4.0.3) in the section headed JNDI. Change the jboss:service=Naming bean definition so that the CallByValue ? attribute reads:
<mbean code="org.jboss.naming.NamingService" name="jboss:service=Naming" xmbean-dd="resource:xmdesc/NamingService-xmbean.xml"> ... <attribute name="CallByValue">true</attribute> ... </mbean>
This is indiscriminate - JBoss will be unable to optimise any JNDI calls any more, but may be appropriate in some circumstances.
Performance note - Call By Value
The use of call by value and marshalling is very inefficient. It typically means method invocations take 10 times the cpu. Why? Compare Call By Value with Call By Reference
Call By Reference
- caller does ejb.someMethod()
- invocation is passed through ejb container
- container does bean.someMethod()
- result is returned to the caller
Call By Value
- caller does ejb.someMethod()
- invocation is marshalled - the parameters are turned into ObjectStream
?
(a
byte[]
) - container with a different classloader unmarshalls -
byte[]
-> java Objects - including classloading - invocation is passed through ejb container
- container does bean.someMethod()
- result is marshalled - the return value is turned into ObjectStream ?
- result is unmarshalled using the caller's classloader -
byte[]
-> java Object - result is return to the caller
The marshalling and unmarshalling uses a lot of cpu.
Related
JBossClassLoadingUseCasesPreloading classes at startup
Debugging class loading issues
Referenced by
GetClassNotFoundExceptionOrNoClassDefFoundErrorHowCanIDynamicallyLoadClassesWithinAnMBean
JBoss5AndMyFaces
JBossESBDeploymentStrategies
JBossFrequentlyAskedQuestions
Main
RulesTomcat
cant di this in 3.2.7
发表评论
-
字符串分割--java中String.split()用法
2013-03-06 14:25 74107在java.lang包中有String.sp ... -
用 HttpServletResponseWrapper 实现 Etag 过滤器
2012-07-09 16:58 3713原文出处:http://blog.chenlb.com/200 ... -
Fitnesse使用
2012-05-05 13:27 23431Fitnesse 的使用 一,介绍 Fitnesse是一种 ... -
Customizing the new FitNesse parser
2012-05-05 13:13 2096FitNesse began its life using ... -
java application中内嵌ActiveX控件
2011-11-14 15:57 5472我这里用的是SWT/JFace开发application,SW ... -
Google Java Developer Tools Downloads
2011-08-09 00:04 2314WindowBuilder Pro原来叫WindowB ... -
Jalita
2011-08-06 00:49 1529Jalita (Java light terminal ada ... -
【转】用Java写字符终端界面
2011-07-29 13:13 2085终端界面GUI开源项目charva。 这个框架让你可以用开发 ... -
[转]mybatis下的分页,支持所有的数据库
2011-07-21 13:21 14794大 家都知道,mybatis的自带分页方法只是逻 ... -
Java framework for text- & console-based forms?
2011-07-21 01:06 1684charva jcurses JNA , ... -
JNA(Java Native Access)学习入门
2011-07-21 01:04 22540Java Native Access 项目 在 ... -
JAVA上加密算法的实现用例
2011-06-25 12:38 4843来源:www.ibm.com ... -
如何将GlassFish作为Windows服务运行
2011-05-18 23:21 2319本文档来自GlassFish官方网站,详细介绍了将 G ... -
JAVA UDP打洞必备知识点---NAT
2011-05-05 12:56 8617一、引言 RFCl631 ... -
Keystore概念,Keytool工具使用
2011-04-28 16:20 2872近来由于项目需要做Single Sign On, 研究了一 ... -
利用Eclipse Profile Plugin监控分析Tomcat性能
2011-04-18 16:14 3676目前新版本的Eclipse在启动应用服务器的时候有一个新的选 ... -
m2eclipse: Eclipse is running in a JRE, but a JDK is required
2011-02-04 23:43 2516Eclipse 安装了Maven插件,启动Eclipse ... -
利用JNative实现Java调用动态库
2010-10-18 00:43 2066由于项目要求,需要用J ... -
RHEL5支持大内存
2010-10-08 16:19 2959安装 RHEL 5 ,硬件为 4G 内存,安装完成 ... -
Windows Server 2003 和 Windows 2000 提供大内存支持
2010-10-08 16:19 1824本文介绍物理地址扩展 ...
相关推荐
JBoss完全实现了J2EE的服务栈: EJB (Enterprise JavaBeans) JMS (Java Message Service) JTS/JTA (Java Transaction Service / Java Transaction API) Servlet and JSP (JavaServer Pages) JNDI (Java Naming and ...
JavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-...
JBOSS,JBoss安装部署 JBOSS,JBoss安装部署
JBoss启动JBoss启动JBoss启动JBoss启动JBoss启动JBoss启动JBoss启动JBoss启动 JBoss启动
赠送jar包:jboss-logging-3.3.2.Final.jar; 赠送原API文档:jboss-logging-3.3.2.Final-javadoc.jar; 赠送源代码:jboss-logging-3.3.2.Final-sources.jar; 赠送Maven依赖信息文件:jboss-logging-3.3.2.Final....
某大牛写的jboss-exp 1. 查看系统名称 java -jar jboss_exploit_fat.jar -i http://192.168.7.84:10081/invoker/JMXInvokerServlet get jboss.system:type=ServerInfo OSName 2. 查看系统版本 java -jar jboss_...
jboss 下载(httpwww.jboss.org)
赠送jar包:jboss-threads-3.1.0.Final.jar; 赠送原API文档:jboss-threads-3.1.0.Final-javadoc.jar; 赠送源代码:jboss-threads-3.1.0.Final-sources.jar; 赠送Maven依赖信息文件:jboss-threads-3.1.0.Final....
赠送jar包:jboss-logging-3.4.1.Final.jar; 赠送原API文档:jboss-logging-3.4.1.Final-javadoc.jar; 赠送源代码:jboss-logging-3.4.1.Final-sources.jar; 赠送Maven依赖信息文件:jboss-logging-3.4.1.Final....
帮你设置jboss安全性问题。Jboss安全设置 jboss安全性 jboss设置安全性Jboss安全设置 jboss安全性 jboss设置安全性
Jboss项目部署文档
JBOSS使用指南JBOSS使用指南JBOSS使用指南JBOSS使用指南JBOSS使用指南JBOSS使用指南JBOSS使用指南JBOSS使用指南
jboss热部署,jboss热部署,jboss热部署,jboss热部署,jboss热部署,jboss热部署,jboss热部署,jboss热部署,jboss热部署,jboss热部署,jboss热部署,jboss热部署
linux 环境jboss 7.1 (注jdk不要用1.8 否则不能启动)
之前学习jboss rules 只能自己一点点的啃英文用户指南,后来终于找到了中文版的翻译版本,真是高兴,立即奉献给大家,让对规则引擎感兴趣的朋友也能一堵为快。 内容摘要:JBoss Rules 的前身是Codehaus的一个开源...
如何在MyEclipse配置Jboss
jboss jbpm 5.0 最新版jboss jbpm 5.0 最新版jboss jbpm 5.0 最新版jboss jbpm 5.0 最新版jboss jbpm 5.0 最新版jboss jbpm 5.0 最新版jboss jbpm 5.0 最新版
资源名称:JBoss 管理与开发核心技术:第三版内容简介:本书的主要目的是从配置和架构这两个角度弄清楚标准JBoss 3.2.x的架构组件。使用JBoss的开发者将理解如何配置标准的组件。其中,需要开发者注意的是,本书不是...
jboss服务器配置https环境的详细方法