2016-12-05 55 views
0

我已經部署在MACHINE1安全EJB,當我運行在同一臺機器上的客戶端代碼,它工作正常。但是當我在任何其他機器上運行客戶端代碼時,它會引發錯誤。它粘貼在下面。javax.naming.NamingException中的WebSphere和連接拒絕

在錯誤就可以看出,它不是將該IP:即提供而是它會在客戶端機器本身。客戶端代碼中的問題在哪裏,或者我在WebSphere中缺少一些設置。

package org.was.tutorial.security.client; 

import java.util.Properties; 

import javax.naming.Context; 
import javax.naming.InitialContext; 

import org.was.tutorial.security.bean.Calculator; 

public class Client 
{ 
    public static void main(String[] args) throws Exception 
    { 
     //Establish the proxy with an incorrect security identity 
     Properties env = new Properties(); 

     //username and password 
     //String username="teacher1"; 
     //String password="teacher"; 


     String username="student1"; 
     String password="student"; 

     //setting up environment properties.. 
     env.setProperty(Context.SECURITY_PRINCIPAL, username); 
     env.setProperty(Context.SECURITY_CREDENTIALS, password); 
     env.setProperty(javax.naming.Context.PROVIDER_URL, "iiop://10.94.13.18:2809"); 
     env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory"); 
     InitialContext ctx = new InitialContext(env); 
     //javax.rmi.PortableRemoteObject.narrow(ctx.lookup("CalculatorBean/remote"), Calculator.class); 

     Calculator calculator =null; 
     try{ 
     calculator = (Calculator)javax.rmi.PortableRemoteObject.narrow(ctx.lookup("CalculatorBean/remote"), Calculator.class); 
     if(calculator==null){ 
      System.out.println("This is not going anywhere"); 
     }else 
      System.out.println("Good. we made a progress."); 

     }catch (Exception e) { 
      e.printStackTrace(); 
     } 

     System.out.println("User "+username); 
     System.out.println("Addition can be performed by all"); 

     try 
     { 
     System.out.println("1 + 1 = " + calculator.add(1, 1)); 
     } 
     catch (Exception ex) 
     { 
     System.out.println("Saw expected SecurityException: " + ex.getMessage()); 
     } 

     System.out.println("Subtraction- can be performed by students only."); 
     try 
     { 
     System.out.println("16- 4 ="+calculator.subtract(16, 4)); 
     }catch (Exception ex) 
     { 
     System.out.println(ex.getMessage()); 
     } 

     System.out.println("Division- can be performed by teachers only.");  
     try 
     { 
     System.out.println("16/4 ="+calculator.divide(16, 4)); 
     }catch (Exception ex) 
     { 
     System.out.println(ex.getMessage()); 
     } 
    ///cool 


    } 
} 

錯誤:

Exception in thread "P=13152:O=0:CT" javax.naming.NamingException: Error getting WsnNameService properties [Root exception is org.omg.CORBA.TRANSIENT: initial and forwarded IOR inaccessible vmcid: IBM minor code: E07 completed: No] 
at com.ibm.ws.naming.util.WsnInitCtxFactory.mergeWsnNSProperties(WsnInitCtxFactory.java:1552) 
at com.ibm.ws.naming.util.WsnInitCtxFactory.getRootContextFromServer(WsnInitCtxFactory.java:1042) 
at com.ibm.ws.naming.util.WsnInitCtxFactory.getRootJndiContext(WsnInitCtxFactory.java:962) 
at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:614) 
at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:128) 
at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:765) 
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:164) 
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:179) 
at javax.naming.InitialContext.lookup(InitialContext.java:423) 
at com.temenos.services.ofsconnector.ejb.IntegrationFrameworkServiceClient.main(IntegrationFrameworkServiceClient.java:50) 
Caused by: org.omg.CORBA.TRANSIENT: initial and forwarded IOR inaccessible vmcid: IBM minor code: E07 completed: No 
at com.ibm.rmi.corba.ClientDelegate.createRequest(ClientDelegate.java:1109) 
at com.ibm.CORBA.iiop.ClientDelegate.createRequest(ClientDelegate.java:1463) 
at com.ibm.rmi.corba.ClientDelegate.createRequest(ClientDelegate.java:1001) 
at com.ibm.CORBA.iiop.ClientDelegate.createRequest(ClientDelegate.java:1429) 
at com.ibm.rmi.corba.ClientDelegate.request(ClientDelegate.java:1618) 
at com.ibm.CORBA.iiop.ClientDelegate.request(ClientDelegate.java:1385) 
at org.omg.CORBA.portable.ObjectImpl._request(ObjectImpl.java:458) 
at com.ibm.WsnBootstrap._WsnNameServiceStub.getProperties(_WsnNameServiceStub.java:38) 
at com.ibm.ws.naming.util.WsnInitCtxFactory.mergeWsnNSProperties(WsnInitCtxFactory.java:1549) 
... 9 more 
Caused by: org.omg.CORBA.COMM_FAILURE: CONNECT_FAILURE_ON_SSL_CLIENT_SOCKET - JSSL0130E: java.io.IOException: Signals that an I/O exception of some sort has occurred. Reason: Connection refused: connect Remote Host: 127.0.0.1 Remote Port: 9403 vmcid: 0x49421000 minor code: 80 completed: No 
at com.ibm.ws.security.orbssl.WSSSLClientSocketFactoryImpl.tryToCreateConnectedSSLSocket(WSSSLClientSocketFactoryImpl.java:357) 
at com.ibm.ws.security.orbssl.WSSSLClientSocketFactoryImpl.createSSLSocket(WSSSLClientSocketFactoryImpl.java:219) 
at com.ibm.ws.orbimpl.transport.WSSSLTransportConnection.createSocket(WSSSLTransportConnection.java:236) 
at com.ibm.CORBA.transport.TransportConnectionBase.connect(TransportConnectionBase.java:348) 
at com.ibm.ws.orbimpl.transport.WSTransport$1.run(WSTransport.java:503) 
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118) 
at com.ibm.ws.orbimpl.transport.WSTransport.getConnection(WSTransport.java:500) 
at com.ibm.CORBA.transport.TransportBase.getConnection(TransportBase.java:181) 
at com.ibm.rmi.iiop.TransportManager.get(TransportManager.java:97) 
at com.ibm.rmi.iiop.GIOPImpl.getConnection(GIOPImpl.java:134) 
at com.ibm.rmi.iiop.GIOPImpl.locate(GIOPImpl.java:230) 
at com.ibm.rmi.corba.ClientDelegate.locate(ClientDelegate.java:1696) 
at com.ibm.rmi.corba.ClientDelegate._createRequest(ClientDelegate.java:1721) 
at com.ibm.rmi.corba.ClientDelegate.createRequest(ClientDelegate.java:1023) 
at com.ibm.rmi.corba.ClientDelegate.createRequest(ClientDelegate.java:1105) 
... 17 more 

更新

Port Details

我曾嘗試使用下面的腳本創建的節點和配置文件:

文件1:集UpEnv.bat

set WAS_HOME=C:\IBM\WebSphere\AppServer 
set HOST_NAME=localhost 
set PROFILE_NAME=AppSrv01 

set NODE_NAME=%PROFILE_NAME%Node01 
set CELL_NAME=%NODE_NAME%Cell 
set SERVER_NAME=server1 

set DMGR_USER=user1 
set DMGR_PASSWORD=123456 
set DMGR_HOST=localhost 
set DMGR_PORT=8879 

文件2:

CALL ./setUpEnv.bat 
set WAS_HOME=C:\IBM\WebSphere\AppServer 
CALL %WAS_HOME%\bin\manageprofiles.bat -create -profileName %PROFILE_NAME% -  profilePath %WAS_HOME%\profiles\%PROFILE_NAME% -templatePath %WAS_HOME%\profileTemplates\default -serverName %SERVER_NAME% -cellName %CELL_NAME% -nodeName %NODE_NAME% -hostName %HOST_NAME% -enableAdminSecurity true -adminUserName %DMGR_USER% -adminPassword %DMGR_PASSWORD% 

回答

2

的9403是用於RMI/IIOP SSL通信(CSIV2_ SSL_ SERVERAUTH_ LISTENER_ ADDRESS)正確的端口。可能會發生這樣的情況:您使用localhost錯誤地安裝了WAS,並且它將本地主機的重定向發送給客戶端,而不是其主機名。

仔細檢查WAS例如通過Web控制檯配置,服務器 - >管理 - >端口部分。

如果您使用的是WAS本地主機安裝,你將不得不改變主機或重新provile(如果你是新來是第二個可能是更容易)。

+0

請看到的,更新的,我也有一個問題要問you.So,要解決這個問題,我需要改變profie名和主機名,我希望我的代碼,以IP的,而不是一些字符..所以怎麼辦我做到了。所以我的真正的EJB,將被許多機器引用。 – User27854

+0

我對你的另一個問題是:如果我改變主機名稱。客戶如何知道。它應該尋找哪臺機器? – User27854

+1

@ user2900314我不完全明白你的問題。就在你創建配置文件時,使用你的服務器機器的真實主機名而不是本地主機。一切都應該工作。您必須將該主機名放入DNS中,或使用映射在客戶端上創建/ etc/hosts文件。當然你也可以在創建配置文件時直接使用IP而不是主機名,但通常不建議這樣做,因爲IP可能會改變。 – Gas