Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JBoss JNDI. What is happening?... DefaultDS?

Reply
Thread Tools

JBoss JNDI. What is happening?... DefaultDS?

 
 
rwfields@yahoo.com
Guest
Posts: n/a
 
      01-19-2007
Greetings Gurus!

I am having difficulty referencing the DefaultDS from a
client running outside the JBoss JVM. Any advice or examples would be
greatly
appreciated. I am running JBoss version 4.0.5GA. I eventually want to
load
and use the datasource in the client application. For simplicity of
example,
I set up a default JBoss install. It seems that I do not have access
to anything in the java: context from outside the JBoss JVM. Are there
security constraints that need to be modified?

Here is my source code:

---

import java.util.*;
import javax.naming.*;

public class JNDI {

public static void main(String[] args) {
try {
Context ic = new InitialContext();

// Print the environment settings
System.out.println("Printing environment keys:");
Hashtable hash = ic.getEnvironment();
Enumeration keys = hash.keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
Object value = hash.get(key);
System.out.println(key + "=" + value);
}

// We can see several bindings, just not the ones we need
System.out.println();
System.out.println("Printing bindings in jmx:");
NamingEnumeration<Binding> b = ic.listBindings("jmx");
while ( b.hasMoreElements() ) {
Object key = b.nextElement();
System.out.println(key);
}

System.out.println();
System.out.println("Get the default datasource:");

// Both of the following lines choke:
// b = ic.listBindings("");
// Context compEnv = (Context) ic.lookup("java:/DefaultDS");
}
catch (Exception e) {
e.printStackTrace();
}
}
}

---

The first few lines of output look like:

Printing environment keys:
jnp.parsedName=
java.naming.factory.initial=org.jnp.interfaces.Nam ingContextFactory
java.naming.provider.url=localhost:1099
java.naming.factory.url.pkgs=org.jboss.namingrg. jnp.interfaces

Printing bindings in jmx:
invoker:
org.jnp.interfaces.NamingContextrg.jnp.interface s.NamingContext@a4e743
rmi:
org.jnp.interfaces.NamingContextrg.jnp.interface s.NamingContext@4aeb52

---

The "listBindings" call throws the following stack dump:

Get the default datasource:
javax.naming.CommunicationException [Root exception is
java.lang.ClassNotFoundException:
org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGen eratorFactory (no
security
manager: RMI class loader disabled)]
at
org.jnp.interfaces.NamingContext.listBindings(Nami ngContext.java:853)
at
org.jnp.interfaces.NamingContext.listBindings(Nami ngContext.java:821)
at
javax.naming.InitialContext.listBindings(InitialCo ntext.java:406)
at JNDI.main(JNDI.java:42)
Caused by: java.lang.ClassNotFoundException:
org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGen eratorFactory (no
security
manager: RMI class loader disabled)
at
sun.rmi.server.LoaderHandler.loadClass(LoaderHandl er.java:371)
at
sun.rmi.server.LoaderHandler.loadClass(LoaderHandl er.java:165)
at
java.rmi.server.RMIClassLoader$2.loadClass(RMIClas sLoader.java:620)
at
java.rmi.server.RMIClassLoader.loadClass(RMIClassL oader.java:247)
at
sun.rmi.server.MarshalInputStream.resolveClass(Mar shalInputStream.java:197)
at
java.io.ObjectInputStream.readNonProxyDesc(ObjectI nputStream.java:1544)
at
java.io.ObjectInputStream.readClassDesc(ObjectInpu tStream.java:1466)
at
java.io.ObjectInputStream.readOrdinaryObject(Objec tInputStream.java:1699)
at
java.io.ObjectInputStream.readObject0(ObjectInputS tream.java:1305)
at
java.io.ObjectInputStream.readObject(ObjectInputSt ream.java:34
at java.rmi.MarshalledObject.get(MarshalledObject.jav a:135)
at
org.jnp.interfaces.MarshalledValuePair.get(Marshal ledValuePair.java:72)
at
org.jnp.interfaces.NamingContext.listBindings(Nami ngContext.java:849)
... 3 more

---

The "ic.lookup("java:/DefaultDS")" throws the following stack trace:

javax.naming.NameNotFoundException: DefaultDS not bound
at
org.jnp.server.NamingServer.getBinding(NamingServe r.java:529)
at
org.jnp.server.NamingServer.getBinding(NamingServe r.java:537)
at org.jnp.server.NamingServer.getObject(NamingServer .java:543)
at org.jnp.server.NamingServer.lookup(NamingServer.ja va:296)
at sun.reflect.GeneratedMethodAccessor105.invoke(Unkn own
Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
sun.rmi.server.UnicastServerRef.dispatch(UnicastSe rverRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:1 53)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport. java:149)
at
sun.rmi.transport.tcp.TCPTransport.handleMessages( TCPTransport.java:466)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandl er.run(TCPTransport.java:707)
at java.lang.Thread.run(Thread.java:595)
at
sun.rmi.transport.StreamRemoteCall.exceptionReceiv edFromServer(StreamRemoteCall.java:247)
at
sun.rmi.transport.StreamRemoteCall.executeCall(Str eamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:1 26)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at
org.jnp.interfaces.NamingContext.lookup(NamingCont ext.java:625)
at
org.jnp.interfaces.NamingContext.lookup(NamingCont ext.java:587)
at javax.naming.InitialContext.lookup(InitialContext. java:351)
at JNDI.main(JNDI.java:43)

---

I am certain that the DefaultDS is up and running since the out of the
box
examples work, however they are all running inside JBoss. I have tried
many
many things to no avail.

---

The XML view from the jboss4guide prints the following
> ant -Dchap=chap2 -Dex=4 run-example


JNDIView Class: org.jboss.mx.modelmbean.XMBean
JNDIView Operations:
+ java.lang.String list(boolean jboss:service=JNDIView)
+ java.lang.String listXML()
+ void create()
+ void start()
+ void stop()
+ void destroy()
+ void jbossInternalLifecycle(java.lang.String jboss:service=JNDIView)
JNDIView.list(true) output:
<h1>Web Applications</h1>
<h2>java:comp namespace of the console-mgr.sar/web-console.war
application:</h2>
<pre>
+- UserTransaction[link -> UserTransaction] (class:
javax.naming.LinkRef)
+- ORB (class: org.jacorb.orb.ORB)
+- env (class: org.jnp.interfaces.NamingContext)
| +- security (class: org.jnp.interfaces.NamingContext)
| | +- realmMapping[link -> java:/jaas/other] (class:
javax.naming.LinkRef)
| | +- subject[link -> java:/jaas/other/subject] (class:
javax.naming.LinkRef)
| | +- securityMgr[link -> java:/jaas/other] (class:
javax.naming.LinkRef)
| | +- security-domain[link -> java:/jaas/other] (class:
javax.naming.LinkRef)
</pre>
<h2>java:comp namespace of the jbossws14.sar/jbossws-context.war
application:</h2>
<pre>
+- UserTransaction[link -> UserTransaction] (class:
javax.naming.LinkRef)
+- ORB (class: org.jacorb.orb.ORB)
+- env (class: org.jnp.interfaces.NamingContext)
| +- security (class: org.jnp.interfaces.NamingContext)
| | +- realmMapping[link -> java:/jaas/other] (class:
javax.naming.LinkRef)
| | +- subject[link -> java:/jaas/other/subject] (class:
javax.naming.LinkRef)
| | +- securityMgr[link -> java:/jaas/other] (class:
javax.naming.LinkRef)
| | +- security-domain[link -> java:/jaas/other] (class:
javax.naming.LinkRef)
</pre>
<h2>java:comp namespace of the jmx-console.war application:</h2>
<pre>
+- UserTransaction[link -> UserTransaction] (class:
javax.naming.LinkRef)
+- ORB (class: org.jacorb.orb.ORB)
+- env (class: org.jnp.interfaces.NamingContext)
| +- security (class: org.jnp.interfaces.NamingContext)
| | +- realmMapping[link -> java:/jaas/jmx-console] (class:
javax.naming.LinkRef)
| | +- subject[link -> java:/jaas/jmx-console/subject] (class:
javax.naming.LinkRef)
| | +- securityMgr[link -> java:/jaas/jmx-console] (class:
javax.naming.LinkRef)
| | +- security-domain[link -> java:/jaas/jmx-console] (class:
javax.naming.LinkRef)
</pre>
<h2>java:comp namespace of the http-invoker.sar/invoker.war
application:</h2>
<pre>
+- UserTransaction[link -> UserTransaction] (class:
javax.naming.LinkRef)
+- ORB (class: org.jacorb.orb.ORB)
+- env (class: org.jnp.interfaces.NamingContext)
| +- security (class: org.jnp.interfaces.NamingContext)
| | +- realmMapping[link -> java:/jaas/other] (class:
javax.naming.LinkRef)
| | +- subject[link -> java:/jaas/other/subject] (class:
javax.naming.LinkRef)
| | +- securityMgr[link -> java:/jaas/other] (class:
javax.naming.LinkRef)
| | +- security-domain[link -> java:/jaas/other] (class:
javax.naming.LinkRef)
</pre>
<h2>java:comp namespace of the jbossweb-tomcat55.sar/ROOT.war
application:</h2>
<pre>
+- UserTransaction[link -> UserTransaction] (class:
javax.naming.LinkRef)
+- ORB (class: org.jacorb.orb.ORB)
+- env (class: org.jnp.interfaces.NamingContext)
| +- security (class: org.jnp.interfaces.NamingContext)
| | +- realmMapping[link -> java:/jaas/other] (class:
javax.naming.LinkRef)
| | +- subject[link -> java:/jaas/other/subject] (class:
javax.naming.LinkRef)
| | +- securityMgr[link -> java:/jaas/other] (class:
javax.naming.LinkRef)
| | +- security-domain[link -> java:/jaas/other] (class:
javax.naming.LinkRef)
</pre>
<h2>java:comp namespace of the jbossmq-httpil.sar/jbossmq-httpil.war
application:</h2>
<pre>
+- UserTransaction[link -> UserTransaction] (class:
javax.naming.LinkRef)
+- ORB (class: org.jacorb.orb.ORB)
+- env (class: org.jnp.interfaces.NamingContext)
| +- security (class: org.jnp.interfaces.NamingContext)
| | +- realmMapping[link -> java:/jaas/jbossmq] (class:
javax.naming.LinkRef)
| | +- subject[link -> java:/jaas/jbossmq/subject] (class:
javax.naming.LinkRef)
| | +- securityMgr[link -> java:/jaas/jbossmq] (class:
javax.naming.LinkRef)
| | +- security-domain[link -> java:/jaas/jbossmq] (class:
javax.naming.LinkRef)
</pre>
<h1>java: Namespace</h1>
<pre>
+- jaas (class: javax.naming.Context)
| +- HsqlDbRealm (class:
org.jboss.security.plugins.SecurityDomainContext)
| +- jmx-console (class:
org.jboss.security.plugins.SecurityDomainContext)
| +- jbossmq (class:
org.jboss.security.plugins.SecurityDomainContext)
| +- JmsXARealm (class:
org.jboss.security.plugins.SecurityDomainContext)
+- TransactionPropagationContextImporter (class:
org.jboss.tm.TransactionPropagationContextImporter )
+- JmsXA (class:
org.jboss.resource.adapter.jms.JmsConnectionFactor yImpl)
+- JBossCorbaNaming (class: org.omg.CosNaming.NamingContextExt)
+- DefaultDS (class: javax.sql.DataSource)
+- StdJMSPool (class: org.jboss.jms.asf.StdServerSessionPoolFactory)
+- TransactionManager (class: org.jboss.tm.TxManager)
+- JBossCorbaPOA (class: org.omg.PortableServer.POA)
+- TransactionPropagationContextExporter (class:
org.jboss.tm.TransactionPropagationContextFactory)
+- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
+- DefaultJMSProvider (class: org.jboss.jms.jndi.JNDIProviderAdapter)
+- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
+- JBossCorbaInterfaceRepositoryPOA (class:
org.omg.PortableServer.POA)
+- Mail (class: javax.mail.Session)
+- JBossCorbaORB (class: org.omg.CORBA.ORB)
+- timedCacheFactory (class: javax.naming.Context)
Failed to lookup: timedCacheFactory,
errmsg=org.jboss.util.TimedCachePolicy
+- SecurityProxyFactory (class:
org.jboss.security.SubjectSecurityProxyFactory)
+- comp (class: javax.naming.Context)
</pre>
<h1>Global JNDI Namespace</h1>
<pre>
+- HASessionState (class: org.jnp.interfaces.NamingContext)
| +- Default (class:
org.jboss.ha.hasessionstate.server.HASessionStateI mpl)
+- TopicConnectionFactory (class: org.jboss.naming.LinkRefPair)
+- jmx (class: org.jnp.interfaces.NamingContext)
| +- invoker (class: org.jnp.interfaces.NamingContext)
| | +- RMIAdaptor (proxy: $Proxy49 implements interface
org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface
org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
| +- rmi (class: org.jnp.interfaces.NamingContext)
| | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class:
javax.naming.LinkRef)
+- HTTPXAConnectionFactory (class:
org.jboss.mq.SpyXAConnectionFactory)
+- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
+- UserTransactionSessionFactory (proxy: $Proxy12 implements
interface org.jboss.tm.usertx.interfaces.UserTransactionSess ionFactory)
+- HTTPConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
+- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
+- invokers (class: org.jnp.interfaces.NamingContext)
| +- dionysus (class: org.jnp.interfaces.NamingContext)
| | +- iiop (class: org.jboss.invocation.iiop.IIOPInvoker)
+- UserTransaction (class:
org.jboss.tm.usertx.client.ClientUserTransaction)
+- UILXAConnectionFactory[link -> XAConnectionFactory] (class:
javax.naming.LinkRef)
+- UIL2XAConnectionFactory[link -> XAConnectionFactory] (class:
javax.naming.LinkRef)
+- HAPartition (class: org.jnp.interfaces.NamingContext)
| +- DefaultPartition (class:
org.jboss.ha.framework.server.HAPartitionImpl)
+- queue (class: org.jnp.interfaces.NamingContext)
| +- A (class: org.jboss.mq.SpyQueue)
| +- testQueue (class: org.jboss.mq.SpyQueue)
| +- ex (class: org.jboss.mq.SpyQueue)
| +- DLQ (class: org.jboss.mq.SpyQueue)
| +- D (class: org.jboss.mq.SpyQueue)
| +- C (class: org.jboss.mq.SpyQueue)
| +- B (class: org.jboss.mq.SpyQueue)
+- topic (class: org.jnp.interfaces.NamingContext)
| +- testDurableTopic (class: org.jboss.mq.SpyTopic)
| +- testTopic (class: org.jboss.mq.SpyTopic)
| +- securedTopic (class: org.jboss.mq.SpyTopic)
+- console (class: org.jnp.interfaces.NamingContext)
| +- PluginManager (proxy: $Proxy50 implements interface
org.jboss.console.manager.PluginManagerMBean)
+- UIL2ConnectionFactory[link -> ConnectionFactory] (class:
javax.naming.LinkRef)
+- HiLoKeyGeneratorFactory (class:
org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGen eratorFactory)
+- UILConnectionFactory[link -> ConnectionFactory] (class:
javax.naming.LinkRef)
+- QueueConnectionFactory (class: org.jboss.naming.LinkRefPair)
+- UUIDKeyGeneratorFactory (class:
org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGen eratorFactory)
</pre>
<h1>HA-JNDI Namespace</h1>
<pre>
</pre>

---

I really want to use JBoss, and eventually lend my support to the
efforts
surrounding what appears to be an awesome project, but I am beginning
to
have doubts in my choice as I have been trying to get this to work for
some time. What am I doing wrong?

I am completely confused. Please advise.

Your help is greatly appreciated,
Randall

 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Arne_Vajh=F8j?=
Guest
Posts: n/a
 
      01-20-2007
wrote:
> I am having difficulty referencing the DefaultDS from a
> client running outside the JBoss JVM. Any advice or examples would be
> greatly
> appreciated. I am running JBoss version 4.0.5GA. I eventually want to
> load
> and use the datasource in the client application.


DataSources are local within the server - you can not share them
with client app.

If you create an entity bean you can access it remotely
from your client app.

Arne
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Internet Application in JBoss Portal on Liferay JBoss LprzemekL Java 0 04-10-2008 12:03 PM
Eclipse/Lomboz/JBoss: Cannot Start JBoss (Debug) Server from Eclipse Using Lomboz Plugin Jubz Java 0 05-30-2006 10:24 PM
jboss 4.0.3 jboss portal 2.2.1 han Java 0 05-08-2006 10:35 AM
XDoclet, JBOSS-AOP Example3 X_AWemner_X Java 0 08-07-2003 04:18 PM
eclipse/tomcat/jboss/mysql Fadzi Ushewokunze Java 0 07-31-2003 05:21 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57