1

I know there are some similar questions here, but I still can not find a solution. I have two JBoss AS 7.0 servers running in the same machine, namely A and B.

A, is the server and provides this service:

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, 
                ....

                )
                {

                ...

                }
                ...

}

finally, the interface IQuartzManagerRemote

@Remote
@WebService
public interface IQuartzManagerRemote {


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


}

On the server B, I need to make a remote acces to this EJB. I tried several approaches, like this

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

or this

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

or this

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

or this

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

etc....

in the end, I need to perform a lookup and, again, I tried different ways.

QuartzManagerRemote quartzWSClient = (IQuartzManagerRemote) context.lookup("ejb:" + "Foo-Batch" + "/" + "Foo-Services" + "/" + "/" +"QuartzManagerBean" + "!" +IQuartzManagerRemote.class.getName());

or with java: or java:exported/ probably all combinations..

The result is almost always the same. If I use the lookup started with java: I get the

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"

on the other hand, If I use the lookup started with 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

Note I can access this bean using SOAP-UI and the generated WSDL as webservice, so the service is up. However, my intention is to access using EJB.

X-Pippes
  • 1,170
  • 7
  • 25
  • if it works with SoapUI, then you have the correct endpoint defined there, use that. – wxyz Nov 06 '13 at 16:35
  • @wxyz, SOAP-UI access through webservice. I need to access to EJB. In my case, this bean is a 2in1. – X-Pippes Nov 06 '13 at 16:41

1 Answers1

0

Solved! I quit to access to a remote EJB and access to WS without create stubs, etc.. Thus, I need to create a method where I get the port to comunicate.

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

and in my method just make a simple call

.... myMethod() {

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

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

}

Everything looks perfect

More information here:

Reference - JBoss Web Services Part I

X-Pippes
  • 1,170
  • 7
  • 25