`
kylinsoong
  • 浏览: 240091 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Jboss Reference Exception Gallery

阅读更多

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();

 

0
4
分享到:
评论

相关推荐

    JBoss Portal Reference Manual

    《JBoss Portal参考手册》是针对企业级Java应用服务器JBoss Portal的重要技术文档,它提供了全面的指南,帮助开发者和管理员深入理解并有效利用该平台。JBoss Portal是一款开源的企业级门户解决方案,它允许组织创建...

    jbossaop_reference.pdf

    本文将基于“jbossaop_reference.pdf”文档的内容,对JBoss AOP的核心概念、实施细节及配置方法进行深入剖析。 ### 一、术语与概述 JBoss AOP框架的核心概念包括切面(Aspect)、连接点(Join Point)、通知...

    JBOSS,JBoss安装部署

    【JBOSS,JBoss安装部署】 JBoss是Red Hat公司开发的一款开源的应用服务器,它基于Java EE(Enterprise Edition)规范,提供了全面的企业级应用程序部署和管理解决方案。本篇文章将详细讲解JBoss的安装和部署过程,...

    Jboss项目部署文档

    Jboss 项目部署文档 Jboss 项目部署文档是指在 Jboss 服务器上部署项目的详细步骤,包括环境变量的配置、项目打包、配置文件的修改、JNDI 的配置等。以下是 Jboss 项目部署文档的详细知识点: 一、环境变量配置 ...

    Jboss Errai_Reference_Guide_3.2.0.pdf

    JBoss Errai是一个开源的Java框架,它基于CDI(Contexts and Dependency Injection for the Java EE platform)标准,为基于Web的应用程序提供了实时通信和集成解决方案。它主要用于将GWT(Google Web Toolkit)应用...

    jboss 下载(httpwww.jboss.org)

    【JBoss 应用服务器详解】 JBoss 是一个开源的、基于 J2EE(Java 2 Platform, Enterprise Edition)的应用服务器,由全球开发者社区共同维护和开发。它最初以 LGPL 许可协议发布,允许商业应用免费使用。2006年,...

    jboss7.1 linux版本

    JBoss AS 7.1.0.Final是在Linux环境下运行的一款开源Java应用服务器,由Red Hat公司维护。这个版本发布于2012年,它引入了许多改进和新特性,旨在提供更快的启动速度、更高的性能以及更好的模块化。在这个环境中,...

    JavaEE源代码 jboss-common

    JavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-...

    MyEclipse中配置JBoss

    【标题】:“MyEclipse中配置JBoss” 在IT行业中,MyEclipse是一款深受开发者喜爱的集成开发环境(IDE),尤其对于Java EE项目开发来说,它提供了强大的支持。而JBoss则是一个开源的应用服务器,广泛用于部署和管理...

    在jboss上部署web应用

    【JBoss 概述】 JBoss 是一个开源的、基于Java的、全面实现了J2EE规范的应用服务器。它提供了企业级的功能,如EJB(Enterprise JavaBeans)、JMS(Java Message Service)、JTS/JTA(Java Transaction Service / ...

    JBoss5.pdf

    JBoss EAP 5 Hibernate EntityManager Reference Guide是一份指南文档,用于指导开发者如何在JBoss EAP 5的环境中使用Hibernate EntityManager。它详细描述了JBoss EAP 5中Hibernate EntityManager的配置和使用方法...

    在IntelliJ idea8中部署Jboss服务器图解

    "在IntelliJ IDEA 8中部署Jboss服务器图解" IntelliJ IDEA 8是 JetBrains 公司开发的一款功能强大且灵活的集成开发环境(IDE),它支持多种programming语言,包括Java、Python、Ruby、PHP等。Jboss则是一款流行的...

    jboss配置入门,jboss的初级配置

    jboss配置入门 jboss系统是一种基于Java的应用服务器,具有高性能、可扩展、安全性强等特点。在本文中,我们将对jboss的基本配置进行介绍,包括其文件夹结构、配置文件、负载均衡配置等。 jboss文件夹结构 jboss的...

    jboss热部署配置

    JBoss是一款著名的开源Java应用服务器,它提供了许多企业级服务,包括事务管理、安全性和集群功能。在开发过程中,为了提高效率,我们通常希望在不中断应用服务的情况下更新部署的应用程序,这就是所谓的“热部署”...

    jboss-eap-7.2.6-patch

    【JBoss EAP 7.2.6 补丁包详解】 JBoss Enterprise Application Platform (EAP) 是 Red Hat 提供的一款开源中间件,用于构建、部署和管理企业级 Java 应用程序。JBoss EAP 7.2.6 版本是一个重要的更新,包含了多个...

    jboss-4.0.5.GA.zip

    JBoss是著名的开源Java应用服务器,它基于Java EE(Enterprise Edition)规范,为开发者提供了全面的中间件服务。4.0.5.GA版本是JBoss的一个稳定版本,发布于2006年,适用于那些需要可靠且成熟的Java应用程序部署的...

    JBoss启动 JBoss启动

    JBoss,作为一款开源的应用服务器,是Java EE(现在称为Jakarta EE)应用程序的重要运行环境。它由Red Hat公司维护,提供了对Web服务、EJB(Enterprise JavaBeans)、JMS(Java Message Service)等标准的全面支持。...

Global site tag (gtag.js) - Google Analytics