-
JNDI problem in JBoss (15 messages)
- Posted by: kala praveen
- Posted on: November 05 2004 06:36 EST
Greetings..!
I am trying use a SQL Server Data Source object through JBoss server but getting so many errors.
I think I have all the required jar files in CLASSPATH.
I have copied the mssql-ds.xml to JBOSS_DIST\server\default\deploy directory and modified it in the following way:
<datasources>
<local-tx-datasource>
<jndi-name>MSSQLDS</jndi-name>
<connection-url>
jdbc:microsoft:sqlserver://172.20.37.219:1433;DatabaseName=master
</connection-url>
<driver-class>
com.microsoft.jdbc.sqlserver.SQLServerDriver
</driver-class>
<user-name>sa</user-name>
<password>welcome</password>
</local-tx-datasource>
</datasources>
I also had standardjaws.xml modified and copied to E:\jboss-3.2.4\server\default\conf directory.
while starting up the server shows the following confirmation:
14:11:00,780 INFO [MSSQLDS] Bound connection factory for resource adapter for ConnectionManager 'jboss.jca:service=LocalTxCM,name=MSSQLDS to JNDI name 'java:/MSSQLDS'
But, when I execute the following client code on the same machine, it is giveing runtime error:
**after setting the env props into HashTable ht..
Context ic=new InitialContext(ht);
DataSource ds=(DataSource)ic.lookup("java:comp/env/jdbc/MSSQLDS");
Error:
Exception in thread "main" javax.naming.NameNotFoundException: comp not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
at org.jnp.server.NamingServer.lookup(NamingServer.java:253)
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:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:534)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:528)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at TestJdbcJBoss.main(TestJdbcJBoss.java:21)
*** I have also tried the above look up statement with java:/MSSQLDS, java:/env/MSSQLDS and all the possible combinations.
It is not detecting whatever that comes after "java: "
I am really tiered with this error...Writing here with a ray of hope..plz help me.Threaded Messages (15)
- JNDI problem in JBoss by Gennady Evstratov on November 05 2004 07:39 EST
- JNDI problem in JBoss by kala praveen on November 05 2004 08:28 EST
-
It really works to the point you specified?! by Gennady Evstratov on November 09 2004 01:39 EST
-
Jndi issue by kala praveen on November 19 2004 10:11 EST
- Jndi issue by the novice on March 05 2005 01:25 EST
-
Jndi issue by kala praveen on November 19 2004 10:11 EST
-
It really works to the point you specified?! by Gennady Evstratov on November 09 2004 01:39 EST
- JNDI problem in JBoss by kala praveen on November 05 2004 08:28 EST
- first by Alon Agmon on November 07 2004 01:19 EST
- unless by Alon Agmon on November 07 2004 08:12 EST
-
HI i m facing the same problem by mahak agarwal on October 11 2007 05:57 EDT
- Re: HI i m facing the same problem by zhao baisheng on November 24 2007 11:21 EST
-
HI i m facing the same problem by mahak agarwal on October 11 2007 05:57 EDT
- unless by Alon Agmon on November 07 2004 08:12 EST
- JNDI problem in JBoss by vic liu on November 23 2004 21:22 EST
- thank you vic liu ! by Alper ULUSOY on April 18 2005 15:27 EDT
- same problem solved thanks to vic liu by roy aa on July 17 2005 08:07 EDT
- A BIG THANK YOU :) by rohan honwade on March 23 2010 01:49 EDT
- Similar problem by Federico Andino on June 29 2005 16:38 EDT
- How do you solve that problem? by aye the ei wah thaw on August 24 2010 23:19 EDT
-
JNDI problem in JBoss[ Go to top ]
- Posted by: Gennady Evstratov
- Posted on: November 05 2004 07:39 EST
- in response to kala praveen
what jndi.properties file is used by jvm that runs your client? you should use one that is in $JBOSS_HOME/server/default/conf
also, if client code is running in webapp deployed in JBoss, you should use put appropriate sestions in jboss-web.xml and web.xml files in order to use that JNDI resource -
JNDI problem in JBoss[ Go to top ]
- Posted by: kala praveen
- Posted on: November 05 2004 08:28 EST
- in response to Gennady Evstratov
Hi Gennady,
Thank you so much for your quick reply.
I am not using any properties files, but directly putting the required fields in the following way.
Hashtable ht=new Hashtable();
ht.put(InitialContext.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
ht.put(InitialContext.PROVIDER_URL,"jnp://localhost:1099");
ht.put(InitialContext.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");
InitialContext ic=new InitialContext(ht);
if(ic!=null)
System.out.println("success");/*I am getting success as output here*/
DataSource ds=(DataSource)ic.lookup("java:comp/env/jdbc/MSSQLDS");
/*this is where it's failing*/
if(ds!=null)
System.out.println("success");
*
*
*
I am not using any web server and this is a simple java client program.Please also confirm onething that, can we access DataSource Object from a stand alone program? Or Must it be used only by the internal components of JBoss like EJBs?
Will be waiting for your reply...
Thanks again.
Best Regards,
Kala.
God is real unless declared integer.... -
It really works to the point you specified?![ Go to top ]
- Posted by: Gennady Evstratov
- Posted on: November 09 2004 01:39 EST
- in response to kala praveen
Are you sure?
You should provide CLASS name, not an interface for java.naming.factory.initial enviroment property...
Code you supplied in last post falls on instantiating initial context factory, because interface can not be instantiated ;)
So, if it falls in some other place in your case, it means that jvm uses some other properties, not the ones you have supplied.
Double check all configuration files, and, IMHO, you should keep JNDI configuration in jndi.properties (just because you dont need to recompile code for changing JNDI provider).
Let me now if you have solved your problem.
Regards.
G. -
Jndi issue[ Go to top ]
- Posted by: kala praveen
- Posted on: November 19 2004 10:11 EST
- in response to Gennady Evstratov
Hi Gennady,
Sorry for late response.I was on vacation. As per the
JBOSS specification, there r 2 ways of entering into the context of the JBOSS naming service. One is using the properties file n other is the one I used above.
With the same naming code, I am able to access the EJBs that I have deployed in JBOSS.
At some anonymous website, I read that only the components that are listed under global name space are accessible by the programs that are running in a different JVM or different context.
Interestingly, when I deploy EJBs in JBOSS, they r falling under global JNDI space and are accessible from stand alone client programs. But, the datasources are falling under java:comp name space that are not accessible from outside. However, I could successfully use the datasources in EJB code to database operations.
I have only tried this with MS SQLSERVER datasource. I have no idea of other datasource objects.
Any research and sharing of knowledge in this regard is greatly appreciated.
Thank you so much for all your interest and time.
Have a good time.
Kala. -
Jndi issue[ Go to top ]
- Posted by: the novice
- Posted on: March 05 2005 01:25 EST
- in response to kala praveen
Hi Kala, how did you solve the problem you had on naming exception - jdbc not found with jboss and mysql ... kindly explain.. -
first[ Go to top ]
- Posted by: Alon Agmon
- Posted on: November 07 2004 01:19 EST
- in response to kala praveen
Jboss DataSources are not bound to java:comp
they are bound to java:/datasource , you saw it yourself
"..
14:11:00,780 INFO [MSSQLDS] Bound connection factory for resource adapter for ConnectionManager 'jboss.jca:service=LocalTxCM,name=MSSQLDS to JNDI name -->'java:/MSSQLDS'<--
.." -
unless[ Go to top ]
- Posted by: Alon Agmon
- Posted on: November 07 2004 08:12 EST
- in response to Alon Agmon
unless you added it as a resource in the bean's descriptors -
HI i m facing the same problem[ Go to top ]
- Posted by: mahak agarwal
- Posted on: October 11 2007 05:57 EDT
- in response to Alon Agmon
Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); env.put(Context.PROVIDER_URL,"localhost"); env.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces"); Context context = new InitialContext(env); if(context!=null) System.out.println("context: success"); CartRemote cart = (CartRemote)context.lookup("CartBean"); if(cart!=null) System.out.println("cart: success"); This is a simple java client program output is printed as: context:success but after that run-main: context: success javax.naming.NameNotFoundException: CartBean 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 org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587) at javax.naming.InitialContext.lookup(InitialContext.java:392) at ejb_stateful.CartClient.main(CartClient.java:32) BUILD SUCCESSFUL (total time: 0 seconds) Please give me the solution??????? -
Re: HI i m facing the same problem[ Go to top ]
- Posted by: zhao baisheng
- Posted on: November 24 2007 11:21 EST
- in response to mahak agarwal
jboss jndiview Global JNDI Namespace +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory) +- TopicConnectionFactory (class: org.jboss.naming.LinkRefPair) +- EventDispatcher (class: org.jboss.ws.eventing.mgmt.DispatcherDelegate) +- UserTransactionSessionFactory (proxy: $Proxy42 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory) +- UIL2ConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef) +- UIL2XAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef) +- QueueConnectionFactory (class: org.jboss.naming.LinkRefPair) +- topic (class: org.jnp.interfaces.NamingContext) | +- testDurableTopic (class: org.jboss.mq.SpyTopic) | +- testTopic (class: org.jboss.mq.SpyTopic) | +- securedTopic (class: org.jboss.mq.SpyTopic) +- 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) +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory) +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction) +- jmx (class: org.jnp.interfaces.NamingContext) | +- invoker (class: org.jnp.interfaces.NamingContext) | | +- RMIAdaptor (proxy: $Proxy36 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) +- UILXAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef) +- UILConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef) we can ses it "TopicConnectionFactory" but when i code like following public static void main(String[] args)throws javax.naming.NamingException { Context ctx=null; TopicConnectionFactory conFactory=null; TopicConnection con=null; TopicSession session=null; Topic topic=null; try { Properties p = new Properties( ); p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); p.put(Context.URL_PKG_PREFIXES, " org.jboss.naming:org.jnp.interfaces"); p.put(Context.PROVIDER_URL, "jnp://localhost:1099"); ctx= new javax.naming.InitialContext(p); System.out.println("ctx:"+ctx); conFactory=(TopicConnectionFactory)ctx.lookup("TopicConnectionFactory"); System.out.println("Factory:"+conFactory); Enumeration enumeration = ctx.listBindings(""); for(;enumeration.hasMoreElements();) System.out.println(enumeration.nextElement().toString()); conFactory=(TopicConnectionFactory)ctx.lookup("ConnectionFactory"); topic=(Topic)ctx.lookup("topic/testTopic"); con=conFactory.createTopicConnection(); session=con.createTopicSession(false,Session.AUTO_ACKNOWLEDGE); TopicPublisher pub=session.createPublisher(topic); TextMessage msg=session.createTextMessage("first mestaage at :"+new Date() ); pub.send(msg); } catch(Exception e) { System.out.println(e.getMessage()); } finally { if (con != null) { try { con.close(); } catch (JMSException e) {} } } } output: ctx:javax.naming.InitialContext@157f0dc null when u replace "TopicConnectionFactory" by "topic/testTopic" output: ctx:javax.naming.InitialContext@157f0dc javax.naming.Reference u can get refernce both "TopicConnectionFactory" and "topic/testTopic" are in Global JNDI Namespace list how can i get TopicConnectionFactory reference? plz help me, thanks -
JNDI problem in JBoss[ Go to top ]
- Posted by: vic liu
- Posted on: November 23 2004 21:22 EST
- in response to kala praveen
Jboss just bind the datasourc in local jndi namespace, so
you cannot retrieve it out of jboss jvm. If you want that,
you should bind the datasource to the global namespace :
In XX-ds.xml, under <jndi-name>, add this:
<use-java-context>false</use-java-context>
test again ! :)
btw, you must use jboss4.0 -
thank you vic liu ![ Go to top ]
- Posted by: Alper ULUSOY
- Posted on: April 18 2005 15:27 EDT
- in response to vic liu
vic liu! you kindly solved my problem:
local/global namespaces.. of jboss
i just siged-up here to
THANK YOU. -
same problem solved thanks to vic liu[ Go to top ]
- Posted by: roy aa
- Posted on: July 17 2005 08:07 EDT
- in response to vic liu
Not sure why it's like that, but vic liu's advice solved it for me. I'm accessing the oracle DS through the JNDI, but doing so from the SAME JVM, so I don't really see why the global namespace is necessary ... well, it worked, so it's good enough for me.
Thanks! -
A BIG THANK YOU :)[ Go to top ]
- Posted by: rohan honwade
- Posted on: March 23 2010 01:49 EDT
- in response to vic liu
Thanks a lot vic liu.. just signed in to thank you:) -
Similar problem[ Go to top ]
- Posted by: Federico Andino
- Posted on: June 29 2005 16:38 EDT
- in response to kala praveen
Hi!
I have a similar problem with a module under Jboss.
I have a remote Jboss server, which uses an oracle-services.xml pool to connect to a database locally.
Now, I want to access to that same database remotely, so I copied the oracle-services.xml file to the jboss/default/deploy directory, but it gives me the following message:
17:27:02,639 WARN [ServiceController] Problem starting service jboss.jca:service=LocalTxCM,name=hsqldbDS
org.jboss.deployment.DeploymentException: Could not bind ConnectionFactory into jndi: java:/DefaultDS
I think I haven´t defined the address to look for the database (hsqldbDS is also set to localhost). Which tag should I modify?
Thanks a lot! -
How do you solve that problem?[ Go to top ]
- Posted by: aye the ei wah thaw
- Posted on: August 24 2010 23:19 EDT
- in response to Federico Andino
I want to discuss about my changes. I got that error when I encrypted the password for DB and changed at mssql-ds.xml file.
<datasources>
<local-tx-datasource>
<jndi-name>DefaultDS</jndi-name>
<connection-url>jdbc:sqlserver://dbserver:1433;DatabaseName=dbname</c onnection-url><!--Replace with security domain below -->
<security-domain>EncryptDBPassword</security-domain><!-- sql to call when connection is created
<new-connection-sql>some arbitrary sql</new-connection-sql> --><!-- sql to call on an existing pooled connection when it is obtained from pool
<check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
--><!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>MS SQLSERVER2000</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>And I changed the login-config.xml file below steps:
<application-policy name="EncryptDBPassword">
<authentication>
<login-module code="org.jboss.resource.security.SecureIdentityLoginModule" flag="required">
<module-option name="username">user name</module-option>
<module-option name="password">5dfc52b51bd355532e231e5701be9001</module-option>
<module-option name="managedConnectionFactoryName">jboss.jca:name=DefaultDS,service=LocalTxCM</module-option>
</login-module>
</authentication>
</application-policy>
Error in server.log.1.
1. [org.jboss.resource.connectionmanager.ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI name 'java:DefaultDS' …
[org.jboss.security.auth.spi.UsersRolesLoginModule] Failed to load users/passwords/role files
- 2. [org.jboss.ejb.plugins.jms.JMSContainerInvoker] JMS provider failure detected:
When I restarted the JBoss server, I got the error same with no 2 and others below errors.
- 2010-08-24 10:15:00,176 INFO [org.jboss.resource.connectionmanager.ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI name 'java:DefaultDS'2010-08-24 10:15:00,208 ERROR [org.jboss.security.auth.spi.UsersRolesLoginModule] Failed to load users/passwords/role files state: FAILED
- [org.jboss.system.ServiceController] Problem starting service jboss.mq:service=StateManagerjava.lang.SecurityException: Invalid authentication attempt, principal=null
- ERROR [org.jboss.security.auth.spi.UsersRolesLoginModule] Failed to load users/passwords/role files
java.io.IOException: No properties file: users.properties or defaults: defaultUsers.properties found
What is mentioned for defaultUsers.properties file?
- ERROR [org.jboss.deployment.MainDeployer] Could not create deployment: file:/D:/Adobe/LiveCycle8/jboss/server/all/deploy/adobe-ds.xml org.jboss.deployment.DeploymentException: Trying to install an already registered mbean: jboss.jca:service=LocalTxCM,name=IDP_DS
Same error with DefaultDS datasource I think.
- ERROR [org.jboss.deployment.MainDeployer] Could not create deployment: file:/D:/Adobe/LiveCycle8/jboss/server/all/deploy/mssql-ds.xml org.jboss.deployment.DeploymentException: Trying to install an already registered mbean: jboss.jca:service=LocalTxCM,name=DefaultDS