Search code examples
jax-wsejb-3.0apache-tomee

javax.naming.NameNotFoundException in tomee plume ejb 3.0 and webservices


I have one webservice project and one EJB 3.0 project deployed in Tomee plume in same EAR. From webservice class i'm calling EJB bean class using remote interface. i have used multiple InitialContextFactory object, but nothing seems to work . Each time i'm getting

javax.naming.NameNotFoundException: Name "TestRemote" not found

while deployment, this log is coming in server.

08-Sep-2017 16:23:09.587 INFO [main] org.apache.openejb.assembler.classic.JndiBuilder.bind Jndi(name=TestRemote) --> Ejb(deployment-id=Test)

Here is the code from my webservice class

        Properties properties = new Properties();
        properties.put("java.naming.factory.initial", "org.apache.openejb.core.OpenEJBInitialContextFactory");
        properties.put("java.naming.provider.url", "http://localhost:8081");
        InitialContext ic = new InitialContext(properties);
        TestRemote PSBR = (TestRemote) ic.lookup("TestRemote");

Apart from OpenEJBInitialContextFactory, i have tried org.apache.openejb.core.LocalInitialContextFactory and RemoteInitialContextFactory but getting the same error each time.


Solution

  • i used this code and did change in system.properties and it got solved.

        properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
    properties.put(Context.PROVIDER_URL, "http://127.0.0.1:8081/tomee/ejb"); 
    

    and change in system.properties.

    # allowed packages to be deserialized, by security we denied all by default, tune tomee.serialization.class.whitelist packages to change it
    tomee.remote.support = true
    tomee.serialization.class.whitelist = *
    tomee.serialization.class.blacklist = -