- 浏览: 236145 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
akka_li:
学习了!但是为什么后续的没有了?!
EJB4:RMI和RMI-IIOP -
springaop_springmvc:
apache lucene开源框架demo使用实例教程源代码下 ...
Lucene学习笔记(一)Lucene入门实例 -
qepipnu:
求solr 客户端 jar包
Solr学习笔记(三)Solr客户端开发实例 -
zhangbc:
是这问题,赞!
Oracle Start Up 2 Oracle 框架构件、启动、解决一个问题 -
feilian09:
查询 select hibernate jdbc 那个效率快
Hibernate,JDBC性能探讨
1. Unable to locate a login configuration
If you missing the auth.conf file which holding the client side JAAS configuration, you will accepte this Exception:(Only be used to invoke Remote Interface with Security Login):
Exception in thread "main" java.lang.SecurityException: Unable to locate a login configuration at com.sun.security.auth.login.ConfigFile.<init>(ConfigFile.java:97) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at java.lang.Class.newInstance0(Class.java:350) at java.lang.Class.newInstance(Class.java:303) at javax.security.auth.login.Configuration$3.run(Configuration.java:216) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.login.Configuration.getConfiguration(Configuration.java:210) at javax.security.auth.login.LoginContext$1.run(LoginContext.java:237) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.login.LoginContext.init(LoginContext.java:234) at javax.security.auth.login.LoginContext.<init>(LoginContext.java:403) at org.jboss.security.jndi.LoginInitialContextFactory.getInitialContext(LoginInitialContextFactory.java:86) at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247) at javax.naming.InitialContext.init(InitialContext.java:223) at javax.naming.InitialContext.<init>(InitialContext.java:197) at com.staffware.frameworks.ejb.EJBCLientTest.lookupWithSequrity(EJBCLientTest.java:51) at com.staffware.frameworks.ejb.EJBCLientTest.main(EJBCLientTest.java:41) Caused by: java.io.IOException: Unable to locate a login configuration at com.sun.security.auth.login.ConfigFile.init(ConfigFile.java:206) at com.sun.security.auth.login.ConfigFile.<init>(ConfigFile.java:95) ... 20 more
Some More Detailed Analysis:
JAAS authentication is performed in a pluggable fashion, So Customer(Java App) do not need to care about underlying authentication technology, Only thing Customer did need is customize its LoginModule, So we need to define our client LoginModule, JBoss always define its LoginModule in auth.conf file which we can find from JBOSS_HOME\client folder, the content as following:
srp-client { // Example client auth.conf for using the SRPLoginModule org.jboss.security.srp.jaas.SRPLoginModule required password-stacking="useFirstPass" principalClassName="org.jboss.security.SimplePrincipal" srpServerJndiName="SRPServerInterface" debug=true ; // jBoss LoginModule org.jboss.security.ClientLoginModule required password-stacking="useFirstPass" ; // Put your login modules that need jBoss here }; other { // jBoss LoginModule org.jboss.security.ClientLoginModule required ; // Put your login modules that need jBoss here };
what the above section has said, JAAS Login Configuration File is a necessary, we must set this file to JVM, we usually use key-value pattern which the key is 'java.security.auth.login.config', just as the following solution depicted:
Available Solution:
----------------------------------------------------------------------------------------------------------------------------------
Method One:
using the following argument when starting the JVM Can made it work :
-Djava.security.auth.login.config=file:./resource/auth.conf
Note that: Under your project root folder has a resource folder, and under the resource folder the Jboss authrity file has existed.
---------------------------------------------------------------------------------------------------------------------------------
Method Two:
This solution is most used what set JVM property 'java.security.auth.login.config' while JVM is starting up, the property key is 'java.security.auth.login.config', and the key reference value is point to Client-side Configuration File Location, as below code showing:
File authFile = new File("resource/auth.conf"); System.out.println("Client-side Configuration File Location: " + authFile.getAbsolutePath()); System.setProperty("java.security.auth.login.config", "file:///" + authFile.getAbsolutePath());
==========================================================================
2. When EJB Client(J2SE environment) Look up Remote Service, throw a error:java.lang.NoSuchMethodError
Exception in thread "main" java.lang.NoSuchMethodError: org.jboss.security.SecurityAssociation.isServer()Z at org.jboss.aspects.security.SecurityActions.isServer(SecurityActions.java:490) at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:88) at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:108) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:280) at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106) at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82) at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:809) at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:572) at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:373) at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166) at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:174) at org.jboss.remoting.Client.invoke(Client.java:1640) at org.jboss.remoting.Client.invoke(Client.java:554) at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:62) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:53) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:74) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:107) at $Proxy0.fetchOrder(Unknown Source) at com.staffware.frameworks.ejb.EJBCLientTest.lookupWithSequrity(EJBCLientTest.java:71) at com.staffware.frameworks.ejb.EJBCLientTest.main(EJBCLientTest.java:47)
Solution:
this error has stucked me for quite a long time, today i have found what's the fucking wrong reason, it's an jboss-eap-4.3.0.GA_CP01 bug.this version jboss has incompatibly problem. 'java.lang.NoSuchMethodError' is a very barely Error, its can only occur at run time if the definition of a class has incompatibly changed, so I use a Class Search utility found that org.jboss.security.SecurityAssociation has been loaded 3 times if you run server production, that means org.jboss.security.SecurityAssociation exists in 3 jar files(JBOSS_HOME\client\jbossall-client.jar,
JBOSS_HOME\client\jbosssx-client.jar, JBOSS_HOME\server\production\lib\jbosssx.jar), and then i use a Decompile Utility found that JBOSS_HOME\server\production\lib\jbosssx.jar's SecurityAssociation hasn't existed isServer() method, and so far this is the reason why this error has throwed.
The Repair Method:
1. update jboss version from jboss-eap-4.3.0.GA_CP01 to a newer version,(jboss-eap-4.3.0.GA_CP04 has modified this bug);
2. replace the JBOSS_HOME\server\production\lib\jbosssx.jar, use later version's jbosssx.jar replace the old version's jbosssx.jar.
==================================================================
3. InvalidClassException throwed when look up EJB
javax.naming.CommunicationException [Root exception is java.io.InvalidClassException: org.jboss.ejb3.remoting.BaseRemoteProxy; local class incompatible: stream classdesc serialVersionUID = 1126421850898582900, local class serialVersionUID = -2711693270411201590] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:780) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627) at javax.naming.InitialContext.lookup(InitialContext.java:351) at com.staffware.frameworks.order.integration.AbstractTestCase.getFacade(AbstractTestCase.java:502) at com.staffware.frameworks.order.integration.AbstractTestCase.getOrderFacade(AbstractTestCase.java:480) at com.staffware.frameworks.order.integration.AbstractTestCase.<clinit>(AbstractTestCase.java:190)
The Error Reason:
The reason of this exception been throwed is that your classpath jbossall-client.jar not match the jboss you have run.
The Solution:
Copy jbossall-client.jar from you(you want to run)$Jboss_home\client, add this client jar to your application classpath, and to do this, this exception will dispair.
4. ProfileServiceBootstrap build ManagedDeployment throw a Exception.
I try to migrate my Application From Jboss Platform 4.3 to Jboss Platform 5.1, of course, App can work well on Platform 4.3, but it crush at the beginning of Platform 5.1 starting up, the exception as following:
org.jboss.deployers.spi.DeploymentException: Error deploying: file:/C:/jboss-eap-5.1/jboss-as/server/production/conf/bootstrap/vfs.xml at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49) at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataFactoryVisitor.deploy(BeanMetaDataFactoryVisitor.java:136) at org.jboss.system.server.profileservice.ProfileServiceBootstrap.initBootstrapMDs(ProfileServiceBootstrap.java:426) at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:242) at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461) at org.jboss.Main.boot(Main.java:221) at org.jboss.Main$1.run(Main.java:556) at java.lang.Thread.run(Thread.java:619) Caused by: java.lang.IllegalStateException: ClassLoader has not been set at org.jboss.deployers.structure.spi.helpers.AbstractDeploymentUnit.getClassLoader(AbstractDeploymentUnit.java:159) at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataFactoryVisitor.addBeanComponent(BeanMetaDataFactoryVisitor.java:60) at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataFactoryVisitor.deploy(BeanMetaDataFactoryVisitor.java:126)
The same Exception also throwed while deploying 'file:/C:/jboss-eap-5.1/jboss-as/server/production/conf/bootstrap/logging.xml', What's the real happened, I will try to give a solution from now.
5. When lookup Jboss Datasource throw a Exception
Exception in thread "main" javax.naming.NameNotFoundException: OracleDS not bound at org.jnp.server.NamingServer.getBinding(NamingServer.java:581) at org.jnp.server.NamingServer.getBinding(NamingServer.java:589) at org.jnp.server.NamingServer.getObject(NamingServer.java:595) at org.jnp.server.NamingServer.lookup(NamingServer.java:342) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294) at sun.rmi.transport.Transport$1.run(Transport.java:153) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:149) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707) at java.lang.Thread.run(Thread.java:595) at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source) at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source) at sun.rmi.server.UnicastRef.invoke(Unknown Source) at org.jnp.server.NamingServer_Stub.lookup(Unknown Source) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627) at javax.naming.InitialContext.lookup(Unknown Source) at datasource.DataSourceConnection.main(DataSourceConnection.java:17)
I checked in the jmx-console of my application server and OracleDS is listed under java:namespace.
The Error Solution:
Usually J2EE Server do not allow directly connection with its Resource, especially Persistence level resource, however From JBoss-4.0.0 and above, there is support for accessing a DataSource from a remote client. The one change that is necessary for the client to be able to lookup the DataSource from JNDI is to specify use-java-context=false as shown here:
<datasources> <local-tx-datasource> <jndi-name>OracleDS</jndi-name> <use-java-context>false</use-java-context> <connection-url>...</connection-url>
This results in the DataSource being bound under the JNDI name "GenericDS" instead of the default of "java:/OracleDS" which restricts the lookup to the same VM as the jboss server.
Note that:
JBoss does not recommend using this feature on a production environment. It requires accessing a connection pool remotely and this is an anti-pattern as connections are not serializable. Besides, transaction propagation is not supported and it could lead to connection leaks if the remote clients are unreliable (i.e crashes, network failure). If you do need to access a datasource remotely, JBoss recommends accessing it via a remote session bean facade.
So to solve this question we only need to add '<use-java-context>false</use-java-context>' to DataSource configure file. as long as this line here
<use-java-context>false</use-java-context>
has been added, then everthing on the right way, by the way my test code:
Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory"); props.put(Context.PROVIDER_URL, "192.168.1.102:1099"); Context ctx = new InitialContext(props); DataSource datasource = (DataSource) ctx.lookup("OracleDS"); Connection conn = datasource.getConnection();
发表评论
-
JBoss系列专题
2013-10-06 22:18 1481我在CSDN上面写了一些JBoss技术博客,欢迎大家光临指 ... -
Java Nio Usage Demo & A example of use selectableChannel
2011-12-06 21:42 3616Primary purpose of this blog is ... -
JDK Source Code & java.nio
2011-11-10 23:26 2319java.nio is very useful and a p ... -
Oracle - Add Exist Validation Before Create Table
2011-11-07 13:49 1405Usually we need to check the ta ... -
JDK Source Code & java.rmi.server.RMISocketFactory
2011-10-31 23:14 2113Today's Source code analysing s ... -
JMX Architecture & "Hello Word" the JMX way
2011-10-25 20:07 1747JMX Architecture Overview: JMX ... -
Thinking in JDBC
2011-09-22 20:56 1817This blog will beas on a series ... -
Jboss-eap-5.1 Messaging
2011-08-02 21:50 2400This section I will concertate ... -
Jboss-eap-5.1 starting up note
2011-07-26 22:46 2544Jboss enterprise platform 5 hav ... -
EJB Security & JAAS Demo
2011-05-21 19:39 1576PROLOGUE: When deploying ... -
JBoss LoginInitialContext Factory Implementation
2011-05-15 16:05 1466Jboss has a series of imp ... -
Hibernate Annotation 的一个问题,给点意见
2011-03-10 12:43 22问题:org.hibernate.annotations. ... -
大家说说BBC的网站用的是什么技术做的
2011-02-22 05:01 1394最近在英国出差,发现这里的一些网站做的相当有特色,有些网站不是 ... -
Hibernate OneToMany 单向和双向配置对数据存取性能的比较
2011-02-08 17:06 22421. 开篇说明:今天是春 ... -
对Hibernate属性(CascadeType、JoinColumn、JoinTable、ForeignKey等)的研究
2010-12-26 15:45 16604本文列出几个“EJB 学习阶段总结:JBoss下发布一个Toy ... -
EJB 学习阶段总结:JBoss下发布一个Toy企业应用
2010-12-25 12:11 2549解释题目:为什 ... -
EJB7: Message Driven Bean
2010-12-21 22:42 2098在企业系统中需要使用 ... -
EJB6: EntityBean例子
2010-11-26 14:48 1441本例子描述向EJB容器(JBoss)部署http: ... -
JPA dev: 几个问题总结(续)
2010-11-25 18:02 24052. 如何由PoJo类生成数据库中的表 首先可以根据实体间关 ... -
JPA dev: 几个问题总结
2010-11-25 16:56 3351最近工作中遇到几个与JPA相关的问题,本文通过一个例子总结一下 ...
相关推荐
Jboss Errai_Reference_Guide_3.2.0.pdf 官方文档 绝对高清非扫描
jboss portal 参考手册,共同学习,共同进步.
jbossaop_reference.pdf
才翻译完成的2.1的。。。。。 jboss seam 2.1用户手册中文版
JBOSS,JBoss安装部署 JBOSS,JBoss安装部署
JBoss启动JBoss启动JBoss启动JBoss启动JBoss启动JBoss启动JBoss启动JBoss启动 JBoss启动
JavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-...
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 ...
JBOSS使用指南JBOSS使用指南JBOSS使用指南JBOSS使用指南JBOSS使用指南JBOSS使用指南JBOSS使用指南JBOSS使用指南
jboss 下载(httpwww.jboss.org)
Jboss项目部署文档
帮你设置jboss安全性问题。Jboss安全设置 jboss安全性 jboss设置安全性Jboss安全设置 jboss安全性 jboss设置安全性
某大牛写的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_...
如何在MyEclipse配置Jboss
jboss热部署,jboss热部署,jboss热部署,jboss热部署,jboss热部署,jboss热部署,jboss热部署,jboss热部署,jboss热部署,jboss热部署,jboss热部署,jboss热部署
Jboss配置虚拟路径
linux 环境jboss 7.1 (注jdk不要用1.8 否则不能启动)
赠送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服务器配置https环境的详细方法