"UID=olivier_DBA;PWD=***;Server=DB_numberOne_srv;DBN=DB_numberOne_db;DBF=/home/olivier/Documents/SQLAnywhere_files/DB_numberOne.db"
java -Dorg.omg.CORBA.ORBInitialHost=localhost\
-Dorg.omg.CORBA.ORBInitialPort=3700\ -classpath
/home/olivier/applications/glassfish-3.1/glassfish/lib/appserv-rt.jar:/home/olivier/applications/glassfish-3.1/glassfish/lib/javaee.jar\
-jar
/home/olivier/NetBeansProjects/YAPS3_and_another_one/dist/YAPS3_and_another_one.jar
Hello, I created projects from the book of A.Goncalves about javaee5.
j'ai un projet EJB (contient des EJBs, des classes JPA), un projet EAR
(Enterprise application, je précise que j'utilise netbeans) qui possède une
référence à l'EJB (en fait je ne sais pas si ce projet EAR est
nécessaire), un projet class library qui contient les interfaces remote des
EJBs (il y en a 3).
I have an EJB project (which contains some EJB, and some JPA classes), an EAR
project(for Enterprise Application Project, in netbeans) which contains a
reference to the EJB(in fact I do not know if the EAR project is necessary),
and a class library project which contains the remote interfaces of the EJBs
(there are 3 EJB classes).
a client (see after)have a reference to the class library (for the remote
interfaces).
The whole projects must be a sell site(excuse my poor english), a commercial
site which sell pets.There are two clients :
- a local client which is the web client, for the CLIENTS
- a swing client, which access to the remote interfaces, for the EMPLOYEES of
the shop
I focus on the swing client, which use the InitialContext constructor.
the server is glassfish 3.1, and when I launch my client from netbeans all is
good (I mean the JNDI call wich a lookup runs fine) but when I launch the
client from the command line I have this error :
[CODE]
access_to_yaps.ServiceLocatorException:
javax.naming.NoInitialContextException: Need to specify class name in
environment or system property, or as an applet parameter, or in an
application resource file: java.naming.factory.initial
erreur :java.lang.NullPointerException
access_to_yaps.ServiceLocatorException:
javax.naming.NoInitialContextException: Need to specify class name in
environment or system property, or as an applet parameter, or in an
application resource file: java.naming.factory.initial
Exception in thread "main" java.lang.NullPointerException
at
access_to_yaps.CustomerDelegate.findCustomers(CustomerDelegate.java:51)
at
yaps3_and_another_one.YAPS3_and_another_one.main(YAPS3_and_another_one.java:43)
[olivier_at_localhost dist]$ java -jar
"/home/olivier/NetBeansProjects/YAPS3_and_another_one/dist/YAPS3_and_another_one.jar"
Début ...
access_to_yaps.ServiceLocatorException:
javax.naming.NoInitialContextException: Need to specify class name in
environment or system property, or as an applet parameter, or in an
application resource file: java.naming.factory.initial
erreur :java.lang.NullPointerException
access_to_yaps.ServiceLocatorException:
javax.naming.NoInitialContextException: Need to specify class name in
environment or system property, or as an applet parameter, or in an
application resource file: java.naming.factory.initial
Exception in thread "main" java.lang.NullPointerException
at
access_to_yaps.CustomerDelegate.findCustomers(CustomerDelegate.java:51)
at
yaps3_and_another_one.YAPS3_and_another_one.main(YAPS3_and_another_one.java:43)
[/CODE]
here is the callers code:
[CODE]
private ServiceLocator() throws ServiceLocatorException {
try {
Properties props = new
Properties();
props.load(new
FileInputStream("jndi.properties"));
initialContext = new
InitialContext(props);
cache = new HashMap<String,
Object>();
} catch (Exception e) {
throw new
ServiceLocatorException(e.toString());
}
}
public Object getRemoteInterface(String jndiName)
throws ServiceLocatorException {
Object remoteInterface = cache.get(jndiName);
if (remoteInterface == null) {
try {
remoteInterface = initialContext.lookup(jndiName);
cache.put(jndiName, remoteInterface);
} catch (Exception e) {
throw new
ServiceLocatorException(e.toString());
}
}
return remoteInterface;
}
}
[/CODE]
The JNDI file is here :
http://www.developpez.net/forums/d446460/java/serveurs-conteneurs-java-ee/glassfish/parametres-jndi-glassfish/,
here is the glassfish's log:
[CODE]
[#|2011-04-21T00:00:17.794+0200|SEVERE|glassfish3.1|javax.enterprise.system.tools.deployment.org.glassfish.deployment.common|_ThreadID=55;_ThreadName=Thread-1;|Exception
while invoking class org.glassfish.ejb.startup.EjbDeployer load method
java.lang.RuntimeException: EJB Container initialization error
at
org.glassfish.ejb.startup.EjbApplication.loadContainers(EjbApplication.java:246)
at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:290)
at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:101)
at org.glassfish.internal.data.ModuleInfo.load(ModuleInfo.java:186)
at
org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:249)
at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:460)
at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at
org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:370)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1067)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1247)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
at
com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:465)
at
com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:222)
at
com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
at
com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:234)
at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.RuntimeException: Error while binding JNDI name
ejbs.CustomerRemote__3_x_Internal_RemoteBusinessHome__ for EJB : CustomerBean
at
com.sun.ejb.containers.BaseContainer.initializeHome(BaseContainer.java:1550)
at
com.sun.ejb.containers.StatelessSessionContainer.initializeHome(StatelessSessionContainer.java:202)
at
com.sun.ejb.containers.ContainerFactoryImpl.createContainer(ContainerFactoryImpl.java:167)
at
org.glassfish.ejb.startup.EjbApplication.loadContainers(EjbApplication.java:234)
... 32 more
Caused by: javax.naming.NameAlreadyBoundException [Root exception is
org.omg.CosNaming.NamingContextPackage.AlreadyBound:
IDL:omg.org/CosNaming/NamingContext/AlreadyBound:1.0]
at
com.sun.jndi.cosnaming.ExceptionMapper.mapException(ExceptionMapper.java:75)
at com.sun.jndi.cosnaming.CNCtx.callBindOrRebind(CNCtx.java:595)
at com.sun.jndi.cosnaming.CNCtx.bind(CNCtx.java:620)
at com.sun.jndi.cosnaming.CNCtx.bind(CNCtx.java:658)
at javax.naming.InitialContext.bind(InitialContext.java:400)
at
com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.publishCosNamingObject(GlassfishNamingManagerImpl.java:226)
at
com.sun.ejb.containers.BaseContainer$JndiInfo.publish(BaseContainer.java:5606)
at
com.sun.ejb.containers.BaseContainer.initializeHome(BaseContainer.java:1535)
... 35 more
Caused by: org.omg.CosNaming.NamingContextPackage.AlreadyBound:
IDL:omg.org/CosNaming/NamingContext/AlreadyBound:1.0
at
org.omg.CosNaming.NamingContextPackage.AlreadyBoundHelper.read(AlreadyBoundHelper.java:60)
at
org.omg.CosNaming._NamingContextStub.bind(_NamingContextStub.java:67)
at com.sun.jndi.cosnaming.CNCtx.callBindOrRebind(CNCtx.java:584)
... 41 more
|#]
[#|2011-04-21T00:00:17.798+0200|SEVERE|glassfish3.1|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=55;_ThreadName=Thread-1;|Exception
while loading the app|#]
[#|2011-04-21T00:00:17.802+0200|INFO|glassfish3.1|org.eclipse.persistence.session.file:/home/olivier/NetBeansProjects/YAPS3_EAR/dist/gfdeploy/YAPS3_EAR/YAPS3_EJB_jar/_YAPS3_pu|_ThreadID=26;_ThreadName=Thread-1;|file:/home/olivier/NetBeansProjects/YAPS3_EAR/dist/gfdeploy/YAPS3_EAR/YAPS3_EJB_jar/_YAPS3_pu
logout successful|#]
[#|2011-04-21T00:00:17.805+0200|SEVERE|glassfish3.1|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=55;_ThreadName=Thread-1;|Exception
while loading the app : EJB Container initialization error
java.lang.RuntimeException: Error while binding JNDI name
ejbs.CustomerRemote__3_x_Internal_RemoteBusinessHome__ for EJB : CustomerBean
at
com.sun.ejb.containers.BaseContainer.initializeHome(BaseContainer.java:1550)
at
com.sun.ejb.containers.StatelessSessionContainer.initializeHome(StatelessSessionContainer.java:202)
at
com.sun.ejb.containers.ContainerFactoryImpl.createContainer(ContainerFactoryImpl.java:167)
at
org.glassfish.ejb.startup.EjbApplication.loadContainers(EjbApplication.java:234)
at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:290)
at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:101)
at org.glassfish.internal.data.ModuleInfo.load(ModuleInfo.java:186)
at
org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:249)
at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:460)
at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at
org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:370)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1067)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1247)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
at
com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:465)
at
com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:222)
at
com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
at
com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:234)
at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:662)
Caused by: javax.naming.NameAlreadyBoundException [Root exception is
org.omg.CosNaming.NamingContextPackage.AlreadyBound:
IDL:omg.org/CosNaming/NamingContext/AlreadyBound:1.0]
at
com.sun.jndi.cosnaming.ExceptionMapper.mapException(ExceptionMapper.java:75)
at com.sun.jndi.cosnaming.CNCtx.callBindOrRebind(CNCtx.java:595)
at com.sun.jndi.cosnaming.CNCtx.bind(CNCtx.java:620)
at com.sun.jndi.cosnaming.CNCtx.bind(CNCtx.java:658)
at javax.naming.InitialContext.bind(InitialContext.java:400)
at
com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.publishCosNamingObject(GlassfishNamingManagerImpl.java:226)
at
com.sun.ejb.containers.BaseContainer$JndiInfo.publish(BaseContainer.java:5606)
at
com.sun.ejb.containers.BaseContainer.initializeHome(BaseContainer.java:1535)
... 35 more
Caused by: org.omg.CosNaming.NamingContextPackage.AlreadyBound:
IDL:omg.org/CosNaming/NamingContext/AlreadyBound:1.0
at
org.omg.CosNaming.NamingContextPackage.AlreadyBoundHelper.read(AlreadyBoundHelper.java:60)
at
org.omg.CosNaming._NamingContextStub.bind(_NamingContextStub.java:67)
at com.sun.jndi.cosnaming.CNCtx.callBindOrRebind(CNCtx.java:584)
... 41 more
|#]
[/CODE]
What I understood is that there is something present in the server and due to
this there is a conflict.
I saw the EJB 's name in the management page of glassfish, all seems to be
fine.
can you help me ?
maybe this could help :
http://www.webspheretools.com/sites/webspheretools.nsf/docs/org%20omg%20CosNaming%20NamingContextPackage%20NotFound%20javax%20naming%20NameNotFoundException,
but I don't understand very well this.
I must verify some "resources" but which ones?
also I searched if there not was a classpath's problem, so I tested this :
[CODE]
java -Dorg.omg.CORBA.ORBInitialHost=localhost\
-Dorg.omg.CORBA.ORBInitialPort=3700\ -classpath
/home/olivier/applications/glassfish-3.1/glassfish/lib/appserv-rt.jar:/home/olivier/applications/glassfish-3.1/glassfish/lib/javaee.jar\
-jar
/home/olivier/NetBeansProjects/YAPS3_and_another_one/dist/YAPS3_and_another_one.jar
[/CODE]
but without success
(look at this help :
http://old.nabble.com/Remote-standalone-EJB-client-td20225310.html.
olivier
--
[Message sent by forum member 'lolveley']
View Post: http://forums.java.net/node/796244