Java EJB3调用期间出错

Java EJB3调用期间出错,java,deployment,websphere,ejb-3.0,websphere-8,Java,Deployment,Websphere,Ejb 3.0,Websphere 8,我已经编写了一个简单的Ejb程序,从 这些文件是 package ejb3.test; import javax.ejb.Remote; /** * TODO: Document me! * * @author aprashanth * */ @Remote public interface ITestEJBRemoteInterface { public boolean checkNames(String fsName); } 实现类: package ejb

我已经编写了一个简单的Ejb程序,从

这些文件是

package ejb3.test;
import javax.ejb.Remote;
/**
 * TODO: Document me!
 *
 * @author aprashanth
 *
 */
@Remote 
public interface ITestEJBRemoteInterface { 
    public boolean checkNames(String fsName); 
   }
实现类:

package ejb3.test;

/**
 * TODO: Document me!
 *
 * @author aprashanth
 *
 */
import java.util.Arrays;
import java.util.List;

import javax.ejb.Stateless;
/** * Session Bean implementation class TestEJB */ 
@Stateless 
public class TestEJB implements ITestEJBRemoteInterface { 
    List<String> moListOfNames = Arrays.asList("Kevin","Jiten","Martina","Brian");

    /** * Default constructor. */ 
    public TestEJB() { } 
    /** * Find if the passed name is present in the default list of names * * 
     * 
     * @return */ 
        public boolean checkNames(String fsName) { 
            boolean lboolNamePresent = false; 
            if(fsName != null) 
            { 
                lboolNamePresent = moListOfNames.contains(fsName); 
             } 
            return lboolNamePresent; 
            } 
        }
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd" version="3.1">
  <display-name>TestEJB3 </display-name>
  <ejb-client-jar>TestEJB3Client.jar</ejb-client-jar>
</ejb-jar>
我的项目结构和导入的库如下图所示:

在WAS端,设置步骤如下: 端口

安装步骤

最后是JndI配置

当我运行客户端代码时,我得到以下错误

JSAS1480I: Security is not enabled because the ConfigURL property file is not set.
javax.naming.NamingException: Error getting WsnNameService properties [Root exception is org.omg.CORBA.TRANSIENT: initial and forwarded IOR inaccessible  vmcid: 0x4942f000  minor code: 3591  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:411)
at ejb31.test.TestEJBClient.main(TestEJBClient.java:27)
Caused by: org.omg.CORBA.TRANSIENT: initial and forwarded IOR inaccessible  vmcid: 0x4942f000  minor code: 3591  completed: No
at com.ibm.rmi.corba.ClientDelegate.createRequest(ClientDelegate.java:1276)
at com.ibm.CORBA.iiop.ClientDelegate.createRequest(ClientDelegate.java:1457)
at com.ibm.rmi.corba.ClientDelegate.createRequest(ClientDelegate.java:1164)
at com.ibm.CORBA.iiop.ClientDelegate.createRequest(ClientDelegate.java:1423)
at com.ibm.rmi.corba.ClientDelegate.request(ClientDelegate.java:1886)
at com.ibm.CORBA.iiop.ClientDelegate.request(ClientDelegate.java:1379)
at org.omg.CORBA.portable.ObjectImpl._request(ObjectImpl.java:449)
at com.ibm.WsnBootstrap._WsnNameServiceStub.getProperties(_WsnNameServiceStub.java:38)
at com.ibm.ws.naming.util.WsnInitCtxFactory.mergeWsnNSProperties(WsnInitCtxFactory.java:1549)
... 9 more
Caused by: java.net.ConnectException: connect: Address is invalid on local machine, or port is not valid on remote machine
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:83)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at com.ibm.ws.orbimpl.transport.WSTCPTransportConnection.createSocket(WSTCPTransportConnection.java:313)
at com.ibm.CORBA.transport.TransportConnectionBase.connect(TransportConnectionBase.java:357)
at com.ibm.ws.orbimpl.transport.WSTransport.getConnection(WSTransport.java:437)
at com.ibm.CORBA.transport.TransportBase.getConnection(TransportBase.java:187)
at com.ibm.rmi.iiop.TransportManager.get(TransportManager.java:97)
at com.ibm.rmi.iiop.GIOPImpl.getConnection(GIOPImpl.java:130)
at com.ibm.rmi.iiop.GIOPImpl.locate(GIOPImpl.java:219)
at com.ibm.rmi.corba.ClientDelegate.locate(ClientDelegate.java:1983)
at com.ibm.rmi.corba.ClientDelegate._createRequest(ClientDelegate.java:2008)
at com.ibm.rmi.corba.ClientDelegate.createRequest(ClientDelegate.java:1186)
at com.ibm.rmi.corba.ClientDelegate.createRequest(ClientDelegate.java:1272)
... 17 more
注意:端口和地址正确:

安全屏幕截图

更改入站配置时出现新错误

JSAS1480I: Security is not enabled because the ConfigURL property file is not set.
Exception in thread "P=818203:O=0:CT" java.lang.NullPointerException
at ejb31.test.TestEJBClient.main(TestEJBClient.java:32)
部署的war文件

内部客户端

war文件内部的server.jar内部


嗯,您必须在屏幕截图上看得更清楚,因为可以清楚地看到选中了
启用管理安全

因此,您必须在RMI/IIOP入站传输配置中禁用SSL,或者正确配置客户端以使用SSL

大概是这样的:

<java_install_root>/bin/java  
-classpath com.ibm.ws.ejb.thinclient_8.5.0.jar:<list_of_your_application_jars_and_classes> 
-Djava.naming.provider.url=iiop://<your_application_server_machine_name> 
-Dcom.ibm.SSL.ConfigURL=file:///home/user1/ssl.client.props
-Dcom.ibm.CORBA.ConfigURL=file:///home/user1/sas.client.props
<fully_qualified_class_name_to_run>
使用:


有关详细信息,请参见

您看到了吗?您的服务器上是否已启用安全功能?从全局安全页面添加屏幕截图。@XSurgent,我做了这些更改,现在我得到了一个不同的错误。我已将其附加到上面。@Gas我已粘贴安全屏幕截图。@Gas,安全未启用…我已按照您的建议进行了更改,但仍会收到相同的错误。还有什么可能出错。@user2900314,请更新您的代码和有问题的错误,因为错误不可能是相同的。您是对的,不知道出了什么问题。我重新部署了war并重新启动了服务器,现在一切正常。谢谢,非常感谢
<java_install_root>/bin/java  
-classpath com.ibm.ws.ejb.thinclient_8.5.0.jar:<list_of_your_application_jars_and_classes> 
-Djava.naming.provider.url=iiop://<your_application_server_machine_name> 
-Dcom.ibm.SSL.ConfigURL=file:///home/user1/ssl.client.props
-Dcom.ibm.CORBA.ConfigURL=file:///home/user1/sas.client.props
<fully_qualified_class_name_to_run>
   Object lobj; try { InitialContext ctx = new InitialContext(props); 
   lobj = ctx.lookup("checkName"); 
   if (lobj instanceof ITestEJBRemoteInterface) {   // <##### this is the problem
        loEJB = (ITestEJBRemoteInterface) lobj; 
   } 
lobj = initCtx.lookup(ejbJNDIName);
loEJB = (ITestEJBRemoteInterface)        javax.rmi.PortableRemoteObject.narrow(lobj , ITestEJBRemoteInterface.class);