How to resolve this Exception??? am i missing any jars ?
When i look into the Jboss jmx-console, "santosh " is not available.
EJBTest.java
It contains EJB Remote Interface and its implementation
package com.ramco.santosh.EJB;
import javax.ejb.Stateless;
import org.jboss.annotation.ejb.*;
#Stateless
#RemoteBinding(jndiBinding="santosh")
public class EJBTest implements EJBTestRemote {
public EJBTest(){}
public void doHello()
{
System.out.println("Hello Mr.Santosh");
}
}
Main
It is a Client which access EJBTest.java through EJBTestRemote Interface.
import java.util.*;
import javax.naming.*;
import com.ramco.santosh.EJB.*;
public class Main {
public static void main(String[] args) throws NamingException
{
Hashtable hashtable = new Hashtable();
hashtable.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
hashtable.put("java.naming.provider.url","jnp://localhost:1099");
hashtable.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
InitialContext context = new InitialContext(hashtable);
Object h=context.lookup("santosh");
EJBTestRemote remote=(EJBTestRemote)h;
remote.doHello();
}
}
Exception in thread "main" javax.naming.NameNotFoundException: santosh not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at Main.main(Main.java:27)
I meant change this line
Object h=context.lookup("santosh");
to
Object h=context.lookup("java:santosh");
and let me know if this works
I Solved the problem of
Exception in thread "main" javax.naming.NameNotFoundException: santosh not bound
Jboss server was missing ejb3-persistence.jar file. After adding EJB application is working well.
Related
JBoss Server Version : 7.3
Java Version : 1.8
IDE : eclipse
Exception
Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/logging/Logger
at org.jboss.naming.remote.client.InitialContextFactory.<clinit>(InitialContextFactory.java:64)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at test.Client.main(Client.java:17)
Caused by: java.lang.ClassNotFoundException: org.jboss.logging.Logger
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 10 more
Below mentioned jars are added in build-path even after getting exception. java.lang.ClassNotFoundException: org.jboss.logging.Logger .
jbossall-client.jar
jboss-common-client.jar
jboss-logging-3.3.2.Final.jar
jboss-remote-naming-1.0.7.final.jar
Code
Main.java
public static void main(String[] args) {
try {
InputStream input;
input = new FileInputStream("/lookup.properties");
Properties prop = new Properties();
prop.load(input);
InitialContext initialContext = new InitialContext(getJBossClientProperties());
Object obj = initialContext.lookup(prop.getProperty("lookup"));
System.out.println("Got EJB : "+obj);
} catch (Exception e) {
System.out.println("Error : "+e);
}
}
private static Properties getJBossClientProperties() throws Exception {
InputStream input = new FileInputStream("/config.properties");
Properties prop = new Properties();
prop.load(input);
return prop;
}
lookup.properties
lookup=jndi_lookup
config.properties
java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory
java.naming.provider.url=remote://localhost:4447
jboss.naming.client.ejb.context=true
I tried above in glassfish works fine , i know its jboss...
I found another relevant post here
java.lang.ClassNotFoundException: org.jboss.logging.Logger
grep for;
When I added the jbossall-client.jar from tje jboss installtion path(../jboss-5.1.0.GA\client) and not from the lib folder, it worked.
that could be your answer.....
I ported my Spring Data Neo4j 4 application to Spring Boot 1.5.1. At Embedded Tomcat 8.5.11 everything works fine but fails at Standalone Tomcat 8.5.11 with a following exception:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/example/domain/api/configuration/Neo4jConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
... 117 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 126 common frames omitted
Caused by: java.lang.NullPointerException: null
at org.neo4j.ogm.metadata.DomainInfo.registerDefaultMethodConverters(DomainInfo.java:379)
at org.neo4j.ogm.metadata.DomainInfo.postProcessMethods(DomainInfo.java:215)
at org.neo4j.ogm.metadata.DomainInfo.finish(DomainInfo.java:159)
at org.neo4j.ogm.scanner.ClassPathScanner.scan(ClassPathScanner.java:148)
at org.neo4j.ogm.metadata.DomainInfo.load(DomainInfo.java:338)
at org.neo4j.ogm.metadata.DomainInfo.<init>(DomainInfo.java:62)
at org.neo4j.ogm.MetaData.<init>(MetaData.java:48)
at org.neo4j.ogm.session.SessionFactory.<init>(SessionFactory.java:62)
at com.example.domain.api.configuration.Neo4jConfig.sessionFactory(Neo4jConfig.java:26)
at com.example.domain.api.configuration.Neo4jConfig$$EnhancerBySpringCGLIB$$59f65b77.CGLIB$sessionFactory$0(<generated>)
at com.example.domain.api.configuration.Neo4jConfig$$EnhancerBySpringCGLIB$$59f65b77$$FastClassBySpringCGLIB$$f50f6aaa.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356)
at com.example.domain.api.configuration.Neo4jConfig$$EnhancerBySpringCGLIB$$59f65b77.sessionFactory(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 127 common frames omitted
This is my Neo4Config:
#Configuration
#EnableNeo4jRepositories(basePackages = "com.example.domain.repository")
#EnableTransactionManagement
public class Neo4jConfig {
final static Logger logger = LoggerFactory.getLogger(Neo4jConfig.class);
#Bean
public Neo4jTransactionManager transactionManager() throws Exception {
return new Neo4jTransactionManager(sessionFactory());
}
#Bean
public SessionFactory sessionFactory() {
return new SessionFactory("com.example.domain.model");
}
}
What can be a reason of this and how to solve it ?
UPDATED
Looks like this is an Eclipse incremental build issue. From console(via Maven commands) everything is working fine.
I am trying to run the example given in the official Oracle website of a RMI application.Here is my oldest post where I explain the previous problems I had Running a sample RMI application.
However, I still have this problem :
ComputeEngine exception:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: compute.Compute
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:419)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:267)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at sun.rmi.transport.Transport$1.run(Transport.java:174)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:275)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:252)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:378)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at engine.ComputeEngine.main(ComputeEngine.java:30)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: compute.Compute
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:409)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:267)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at sun.rmi.transport.Transport$1.run(Transport.java:174)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.ClassNotFoundException: compute.Compute
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.rmi.server.LoaderHandler$Loader.loadClass(LoaderHandler.java:1206)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at sun.rmi.server.LoaderHandler.loadClassForName(LoaderHandler.java:1219)
at sun.rmi.server.LoaderHandler.loadProxyInterfaces(LoaderHandler.java:729)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:673)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:610)
at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:646)
at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:311)
at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:255)
at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1556)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1512)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1769)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
... 13 more
This is the content of the ComuteEngine.java (server):
package engine;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
import compute.Compute;
import compute.Task;
public class ComputeEngine implements Compute {
public ComputeEngine() {
super();
}
public <T> T executeTask(Task<T> t) {
return t.execute();
}
public static void main(String[] args) {
if (System.getSecurityManager() == null) {
System.setSecurityManager(new SecurityManager());
}
try {
String name = "Compute";
Compute engine = new ComputeEngine();
Compute stub =
(Compute) UnicastRemoteObject.exportObject(engine, 0);
Registry registry = LocateRegistry.getRegistry();
registry.rebind(name, stub);
System.out.println("ComputeEngine bound");
} catch (Exception e) {
System.err.println("ComputeEngine exception:");
e.printStackTrace();
}
}
}
Does anyone know how to resolve that issue ?
I succeded to launch my program by adding :
LocateRegistry.createRegistry(1099);
before creating the security manager.However, launching simply the rmiregistry from my terminal didn't work. I think because of a communcation problem between the server and the rmiregistry, maybe because I have to add some classes to the classpath but I don't know how to do that properly.
I am seeing the following error, as you can see there is no mention of any of my classes. I have a subclass of MultiViewEditorElement. I am assuming the exception springs from here. Is there anything specific I should do to be able to get rid of the exception ?
Here is the class.
INFO [org.netbeans.core.windows.persistence]: TopComponent MultiView-puml#007Ctext#002Ehistory#007C is not serializable.
java.io.NotSerializableException: org.netbeans.core.windows.RegistryImpl
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
at org.netbeans.core.multiview.MultiViewPeer.peerWriteExternal(MultiViewPeer.java:523)
at org.netbeans.core.multiview.MultiViewCloneableTopComponent.writeExternal(MultiViewCloneableTopComponent.java:213)
at org.openide.windows.TopComponent$Replacer.writeObject(TopComponent.java:1787)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
at org.netbeans.modules.settings.convertors.XMLSettingsSupport.storeSerialData(XMLSettingsSupport.java:274)
at org.netbeans.modules.settings.convertors.XMLSettingsSupport.storeToXML10(XMLSettingsSupport.java:115)
at org.netbeans.modules.settings.convertors.XMLSettingsSupport$Convertor.write(XMLSettingsSupport.java:1174)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.openide.loaders.InstanceDataObject.convertorWriteMethod(InstanceDataObject.java:1617)
at org.openide.loaders.InstanceDataObject.storeThroughConvertor(InstanceDataObject.java:1604)
at org.openide.loaders.InstanceDataObject.storeSettings(InstanceDataObject.java:358)
at org.openide.loaders.InstanceDataObject.access$900(InstanceDataObject.java:92)
at org.openide.loaders.InstanceDataObject$Creator.run(InstanceDataObject.java:1565)
at org.openide.filesystems.EventControl.runAtomicAction(EventControl.java:127)
at org.openide.filesystems.FileSystem.runAtomicAction(FileSystem.java:609)
at org.openide.loaders.DataObjectPool.runAtomicActionSimple(DataObjectPool.java:229)
at org.openide.loaders.InstanceDataObject$Creator.createInstanceDataObject(InstanceDataObject.java:1579)
at org.openide.loaders.InstanceDataObject.create(InstanceDataObject.java:343)
at org.openide.loaders.InstanceDataObject.create(InstanceDataObject.java:319)
[catch] at org.netbeans.core.windows.persistence.PersistenceManager.saveTopComponents(PersistenceManager.java:834)
at org.netbeans.core.windows.persistence.PersistenceManager.saveWindowSystem(PersistenceManager.java:1181)
at org.netbeans.core.windows.PersistenceHandler.save(PersistenceHandler.java:323)
at org.netbeans.core.windows.WindowSystemImpl.save(WindowSystemImpl.java:93)
at org.netbeans.core.NbLifeExit.doStopInfra(NbLifeExit.java:147)
at org.netbeans.core.NbLifeExit.run(NbLifeExit.java:97)
at org.netbeans.core.startup.ModuleSystem$2.run(ModuleSystem.java:343)
at org.netbeans.ModuleManager.shutDownAsync(ModuleManager.java:1971)
at org.netbeans.core.startup.ModuleSystem.shutDownAsync(ModuleSystem.java:349)
at org.netbeans.core.NbLifeExit.doExit(NbLifeExit.java:134)
at org.netbeans.core.NbLifeExit.run(NbLifeExit.java:94)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:682)
at java.awt.EventQueue$3.run(EventQueue.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:691)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
EDIT
Ok, I was able to eliminate the exception by changing persistenceType on DataObject to
persistenceType = TopComponent.PERSISTENCE_NEVER. But I would like to use persistenceType = TopComponent.PERSISTENCE_ONLY_OPENED Is there a tutorial that I could use for DataObject persistence ?
Since MultiviewEditorElement implements Serializable interface, you'll need to implement the Serializable methods in order to use the TopComponent.PERSISTENCE_ONLY_OPENED:
private void writeObject(java.io.ObjectOutputStream out) throws IOException
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException;
I have a stateless ejb.
#Remote
public interface MyService {
...
}
impl
#Stateless
public class MyServiceImpl implements MyService {
...
}
I have another bean which is trying to use MyService, that will be exposed via JMX.
#MXBean
public interface MyJMXBean {
...
}
#Singleton
#Startup
public class MyJMXBeanImpl implements MyJMXBean {
#EJB
MyService service; // this works
#PostConstruct
private void init() { ... }
#PreDestroy
private void cleanup() { ... }
// this doesn't
private MyService doLookup() {
InitialContext ctx = new InitialContext();
return (MyService) ctx.lookup(MyService.class.getName());
}
}
I would like to be able to do a jndi lookup of MyService so I don't have the deployment dependency on the ear that provides MyService. The ears providing MyService and MyJMXBean are different, but deployed to the same container. The exception I'm getting is:
Caused by: javax.naming.CommunicationException: Communication exception for SerialContext[myEnv={java.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:542) ~[glassfish-naming.jar:3.1.2.1-SNAPSHOT]
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455) ~[glassfish-naming.jar:3.1.2.1-SNAPSHOT]
at javax.naming.InitialContext.lookup(InitialContext.java:411) ~[na:1.7.0_15]
at javax.naming.InitialContext.lookup(InitialContext.java:411) ~[na:1.7.0_15]
at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:71) ~[ejb-container.jar:3.1.2.1-SNAPSHOT]
at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:580) ~[glassfish-naming.jar:3.1.2.1-SNAPSHOT]
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:514) ~[glassfish-naming.jar:3.1.2.1-SNAPSHOT]
... 38 common frames omitted
Caused by: org.omg.CORBA.INITIALIZE: can't instantiate default ORB implementation com.sun.corba.ee.impl.orb.ORBImpl
at org.omg.CORBA.ORB.create_impl(ORB.java:314) ~[na:1.7.0_15]
at org.omg.CORBA.ORB.init(ORB.java:353) ~[na:1.7.0_15]
at com.sun.jndi.toolkit.corba.CorbaUtils.getOrb(CorbaUtils.java:203) ~[na:1.7.0_15]
at com.sun.jndi.cosnaming.CNCtx.getDefaultOrb(CNCtx.java:72) ~[na:1.7.0_15]
at com.sun.jndi.cosnaming.CNCtx.initOrbAndRootContext(CNCtx.java:234) ~[na:1.7.0_15]
at com.sun.jndi.cosnaming.CNCtx.<init>(CNCtx.java:105) ~[na:1.7.0_15]
at com.sun.jndi.cosnaming.CNCtxFactory.getInitialContext(CNCtxFactory.java:49) ~[na:1.7.0_15]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684) ~[na:1.7.0_15]
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307) ~[na:1.7.0_15]
at javax.naming.InitialContext.init(InitialContext.java:242) ~[na:1.7.0_15]
at javax.naming.InitialContext.<init>(InitialContext.java:216) ~[na:1.7.0_15]
at com.sun.enterprise.naming.util.IIOPObjectFactory.getObjectInstance(IIOPObjectFactory.java:73) ~[glassfish-naming.jar:3.1.2.1-SNAPSHOT]
at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:580) ~[glassfish-naming.jar:3.1.2.1-SNAPSHOT]
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:514) ~[glassfish-naming.jar:3.1.2.1-SNAPSHOT]
... 44 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.sun.corba.ee.impl.orb.ORBImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:366) ~[na:1.7.0_15]
at java.net.URLClassLoader$1.run(URLClassLoader.java:355) ~[na:1.7.0_15]
at java.security.AccessController.doPrivileged(Native Method) [na:1.7.0_15]
at java.net.URLClassLoader.findClass(URLClassLoader.java:354) ~[na:1.7.0_15]
at java.lang.ClassLoader.loadClass(ClassLoader.java:423) ~[na:1.7.0_15]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) ~[na:1.7.0_15]
at java.lang.ClassLoader.loadClass(ClassLoader.java:356) ~[na:1.7.0_15]
at java.lang.Class.forName0(Native Method) ~[na:1.7.0_15]
at java.lang.Class.forName(Class.java:266) ~[na:1.7.0_15]
at org.omg.CORBA.ORB.create_impl(ORB.java:312) ~[na:1.7.0_15]
... 57 common frames omitted
I'm not quite sure how to resolve the ClassNotFoundException, as everything is running inside Glassfish.
GlassFish V3 supports EJB 3.1 and implements the syntax for portable global session bean JNDI names in EJB 3.1 as below
java:global[/<app-name>]/<module-name>/<bean-name>
<bean-name> corresponds to the session bean's EJB name. It defaults to the unqualified name of the session bean class. It can be explicitly specified using the name attribute of the #Stateless/#Stateful/#Singleton annotation.
What you looked up in the JNDI tree was the qualified name of the EJB class.
You can check out the GlassFish EJB FAQ for details.