Java JBoss AS 7 Bean查找EJB

Java JBoss AS 7 Bean查找EJB,java,ejb,jboss7.x,remote-access,lookup,Java,Ejb,Jboss7.x,Remote Access,Lookup,我知道这里有一些类似的问题,但我仍然找不到解决办法。 我有两个JBossAS 7.0服务器运行在同一台机器上,即A和B A,是服务器,提供以下服务: 15:49:02,998 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-4) JNDI bindings for session bean named QuartzManager

我知道这里有一些类似的问题,但我仍然找不到解决办法。 我有两个JBossAS 7.0服务器运行在同一台机器上,即A和B

A,是服务器,提供以下服务:

15:49:02,998 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-4) JNDI bindings for session bean named QuartzManagerBean in deployment unit subdeployment "Foo-Services.jar" of deployment "Foo-Batch.ear" are as follows:

java:global/Foo-Batch/Foo-Services/QuartzManagerBean!foo.services.interfaces.IQuartzManagerLocal
java:app/Foo-Services/QuartzManagerBean!foo.services.interfaces.IQuartzManagerLocal
java:module/QuartzManagerBean!foo.services.interfaces.IQuartzManagerLocal
java:global/Foo-Batch/Foo-Services/QuartzManagerBean!foo.services.interfaces.IQuartzManagerRemote
java:app/Foo-Services/QuartzManagerBean!foo.services.interfaces.IQuartzManagerRemote
java:module/QuartzManagerBean!foo.services.interfaces.IQuartzManagerRemote
java:jboss/exported/Foo-Batch/Foo-Services/QuartzManagerBean!foo.services.interfaces.IQuartzManagerRemote
QuartzManagerBean

package foo.services.bean;


@Startup
@Singleton

@Remote(IQuartzManagerRemote.class)


@TransactionManagement(value=TransactionManagementType.BEAN)
@TransactionAttribute(value=TransactionAttributeType.NOT_SUPPORTED)


@WebService(name = "BatchQuartzManagerBean", targetNamespace = "urn:foo", serviceName = "BatchQuartzManagerBean")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED, use = SOAPBinding.Use.LITERAL)

public class QuartzManagerBean implements IQuartzManagerLocal, IQuartzManagerRemote{

...

    public synchronized ReturnType fooMethod(
                String serverName, 
                ....

                )
                {

                ...

                }
                ...

}
最后,界面IQuartzManagerRemote

@Remote
@WebService
public interface IQuartzManagerRemote {


    @WebMethod(operationName = "fooMethod")
    public  ReturnType fooMethod(
            @WebParam(name="serverName") String serverName, 
            ....
            );


}
在服务器B上,我需要远程访问此EJB。 我试过几种方法,像这样

        env.put("endpoint.name","client-endpoint"); 
        env.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
        env.put("remote.connections", "default");
        env.put("remote.connection.default.host","127.0.0.1");
        env.put("remote.connection.default.port","4447");
        env.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
        env.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
        env.put("jboss.naming.client.ejb.context", true);
        context = new InitialContext(env);
还是这个

    Properties jndiProps = new Properties();
    jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
    jndiProps.put(Context.PROVIDER_URL,"rhttp://localhost:8080/Foo-Services/BatchQuartzManagerBean/BatchQuartzManagerBean:4447");
    // This is an important property to set if you want to do EJB invocations via the remote-naming project
    jndiProps.put("jboss.naming.client.ejb.context", true);
    // create a context passing these properties
    Context context = new InitialContext(jndiProps);
    Properties jndiProps = new Properties();
        jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
        jndiProps.put(Context.PROVIDER_URL,"remote://localhost:4447");
        jndiProps.put("jboss.naming.client.ejb.context", true);
        // create a context passing these properties
        InitialContext ctx = new InitialContext(jndiProps);
 Properties p = new Properties();
         p.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
         p.put("remote.connections", "one");
         p.put("remote.connection.one.port", "4447");
         p.put("remote.connection.one.host", "localhost");
         p.put("jboss.naming.client.ejb.context", true);

         EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(p);
         ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc);
         EJBClientContext.setSelector(selector);
还是这个

    Properties jndiProps = new Properties();
    jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
    jndiProps.put(Context.PROVIDER_URL,"rhttp://localhost:8080/Foo-Services/BatchQuartzManagerBean/BatchQuartzManagerBean:4447");
    // This is an important property to set if you want to do EJB invocations via the remote-naming project
    jndiProps.put("jboss.naming.client.ejb.context", true);
    // create a context passing these properties
    Context context = new InitialContext(jndiProps);
    Properties jndiProps = new Properties();
        jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
        jndiProps.put(Context.PROVIDER_URL,"remote://localhost:4447");
        jndiProps.put("jboss.naming.client.ejb.context", true);
        // create a context passing these properties
        InitialContext ctx = new InitialContext(jndiProps);
 Properties p = new Properties();
         p.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
         p.put("remote.connections", "one");
         p.put("remote.connection.one.port", "4447");
         p.put("remote.connection.one.host", "localhost");
         p.put("jboss.naming.client.ejb.context", true);

         EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(p);
         ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc);
         EJBClientContext.setSelector(selector);
还是这个

    Properties jndiProps = new Properties();
    jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
    jndiProps.put(Context.PROVIDER_URL,"rhttp://localhost:8080/Foo-Services/BatchQuartzManagerBean/BatchQuartzManagerBean:4447");
    // This is an important property to set if you want to do EJB invocations via the remote-naming project
    jndiProps.put("jboss.naming.client.ejb.context", true);
    // create a context passing these properties
    Context context = new InitialContext(jndiProps);
    Properties jndiProps = new Properties();
        jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
        jndiProps.put(Context.PROVIDER_URL,"remote://localhost:4447");
        jndiProps.put("jboss.naming.client.ejb.context", true);
        // create a context passing these properties
        InitialContext ctx = new InitialContext(jndiProps);
 Properties p = new Properties();
         p.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
         p.put("remote.connections", "one");
         p.put("remote.connection.one.port", "4447");
         p.put("remote.connection.one.host", "localhost");
         p.put("jboss.naming.client.ejb.context", true);

         EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(p);
         ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc);
         EJBClientContext.setSelector(selector);
或者使用
java:
java:exported/
可能是所有组合

结果几乎总是一样的。如果我使用从
java:
开始的查找,我会得到

ERROR [stderr] (http-/127.0.0.1:8180-6) javax.naming.NameNotFoundException: Foo-Batch/Foo-Services//QuartzManagerBean!foo.services.interfaces.IQuartzManagerRemote -- service jboss.naming.context.java.jboss.exported.Foo-Batch.Foo-Services."QuartzManagerBean!foo.services.interfaces.IQuartzManagerRemote"
另一方面,如果我使用从
ejb…

java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:Foo-Batch, moduleName:Foo-Services, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@4c42ff8
注意我可以使用SOAP-UI和生成的WSDL作为Web服务访问这个bean,因此服务启动了。然而,我的目的是使用EJB进行访问。

解决了! 我退出以访问远程EJB并访问WS而不创建存根,等等。。 因此,我需要创建一个方法,从中获取通信端口

private static IQuartzManagerRemote getPort(String endpointURI) throws MalformedURLException   {
           QName serviceName = new QName("urn:foo", "FooQuartzManagerBean");
           URL wsdlURL = new URL(endpointURI);

           Service service = Service.create(wsdlURL, serviceName);
           return service.getPort(IQuartzManagerRemote.class);
         }
在我的方法中,只需做一个简单的调用

.... myMethod() {

String endpointURI ="http://127.0.0.1:8080/Foo-Services/FooQuartzManagerBean/FooQuartzManagerBean?WSDL";

//call webmethod instatianteJob
getPort(endpointURI).instantiateJob( ....

}
一切看起来都很完美

更多信息请点击此处:


如果它与SoapUI一起工作,那么您在那里定义了正确的端点,请使用它。@wxyz,通过webservice进行SOAP-UI访问。我需要访问EJB。在我的例子中,这个bean是一个2in1。