wood burning stoves*
The moose likes JBoss/WildFly and the fly likes Jboss 5.1 Jndi related problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Jboss 5.1 Jndi related problem" Watch "Jboss 5.1 Jndi related problem" New topic
Author

Jboss 5.1 Jndi related problem

Lalit Awasthi
Greenhorn

Joined: Dec 18, 2012
Posts: 8
Hi All,
I am trying to migrate a java apllication from Websphere 6.0 to JBOSS 5.1.

I have done all the configuration for datasource connection.

I am facing one problem,I tried to do a lot of permutation and combination so that my JNDI will be initialized with Java:comp/env/XXX but I am not able to apend comp/env in my JNDI.

here is oracle-ds.xml

<datasources>
<local-tx-datasource>
<jndi-name>jdbc/abc_datasource</jndi-name>

<connection-url>XX</connection-url>
</local-tx-datasource>
</datasources>

It directly binds jdbc/abc_datasource to java:jdbc/abc_datasource but I want it to bind jdbc/abc_datasource to java:comp/env/jdbc/abc_datasource

Is there any configuration in any xml or any guidance to this will be highly appreciated.


Thanks,
Lalit Awasthi

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10141
    
165

Take a look at this thread where Peter has explained what needs to be done https://community.jboss.org/message/251298#251298

[My Blog] [JavaRanch Journal]
Lalit Awasthi
Greenhorn

Joined: Dec 18, 2012
Posts: 8
Thanks Jaikiran for your quick reply

I have already searched a lot about this topic ..
Everywhere is mentioned about configuring datasource(Jbossweb.xml,web.xml). I am asking about initially when I just configure datasource in oracle-ds.xml and start the server it says

16:59:11,746 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI name 'javaefaultDS'
16:59:11,809 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=jdbc/abc_datasource' to JNDI name 'java:jdbc/abct_datasource'.

So my question is"is there any xml file where we can change the prefix of binding JNDI as now it is adding "Java:" .I just want to add "Java:com/env".

I got few things about but that did not help

Please suggest

Thanks

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10141
    
165

Lalit Awasthi wrote:

So my question is"is there any xml file where we can change the prefix of binding JNDI as now it is adding "Java:" .I just want to add "Java:com/env".


java:comp/env/ namesapce is a reserved namespace for Java EE components. So you will have to use Java EE deployment descriptors like web.xml/jboss-web.xml and/or ejb-jar.xml/jboss.xml to configure that namespace. Peter's post explains how it can be done.
Lalit Awasthi
Greenhorn

Joined: Dec 18, 2012
Posts: 8
Hello Jaikiran

Thanks for your reply again

I have done changes according to Peter's post bit still I am not able to bind the datasource using Java:comp/env prefix

I am posting all the three files

oracle-ds.xml

web.xml

Jboss-web.xml



Please let me know if I am doing anything not coreect

Thanks a lot
Regards
Lalit
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10141
    
165

What exactly do you mean that you are not able to bind it in that namespace? Where are you looking it up from? What does that code look like and what does the exception stacktrace look like?

By the way, while posting code, xml or logs, please use the code block to wrap that content. You can use the Code button in the message editor window to do that. I have edited your previous reply to show how it looks when it's wrapped in code blocks - far more easier to read.
Lalit Awasthi
Greenhorn

Joined: Dec 18, 2012
Posts: 8
Hello Jaikiran

yes exactly I am talking about namespace.mainly I want to bind jdbc/abc_datasource in Java:comp/env/jdbc/abc_datasource namespace but it is not doing so

I can show you the console



[RARDeployment] Required license terms exist, view vfsfile:/C:/Documents%20and%20Settings/All%20Users/jbdevstudio/jboss-eap/
jboss-as/server/web_copy2/deploy/mail-ra.rar/META-INF/ra.xml
18:48:07,855 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS'
to JNDI name 'javaefaultDS'
18:48:07,901 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=abc_datasource'
to JNDI name 'java:jdbc/abc_datasource'
18:48:08,042 INFO [TomcatDeployment] deploy, ctxPath=/admin-console
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10141
    
165

Lalit Awasthi wrote:Hello Jaikiran

yes exactly I am talking about namespace.mainly I want to bind jdbc/abc_datasource in Java:comp/env/jdbc/abc_datasource namespace but it is not doing so

I can show you the console

It will not be printed on the console. You'll have to look it up from the relevant component (like a servlet) from the web application or use the jmx-console's JNDIView MBean to view it (although I'm not 100% sure if it shows the java:comp/env namespace)

Lalit Awasthi
Greenhorn

Joined: Dec 18, 2012
Posts: 8
Hello Jaikiran

Again Thanks for your reply.

As per your suggestion I checked jmx-console's JNDIView MBean and there I found that is bound to jdbc/abc_datasource.

Let me tell you the problem in detail.

Actually I have an application that was working fine with websphere. But now I am migrating it to JBOSS.

There is database(suppose x) in which other datasources(suppose y,z etc) name are given.

I am able to connect to database x.

Initially when I configured my datasource(for y,z) in oracle-ds.xml with

server Directly binds it to Java:jdbc/abc_datasource.

But the origional datasource name that server should lookup is coming from another database(x) and that is java:comp/enc/jdbc/abc_datasource


so when server looks up for datasource it gets Java:jdbc/abc_datasource in place of java:comp/enc/jdbc/abc_datasource

and code is written in such a way that both sould match ..I can not change my database where the name is like java:comp/enc/jdbc/abc_datasource


Thats why I want to bind the datasource in java:comp/enc/jdbc/abc_datasource format in place of Java:jdbc/abc_datasource this format.

I also get one tag <use-java-context> but by using this I can only add or remove Java: ...

Please help .

Thanks
Lalit Awasthi
Greenhorn

Joined: Dec 18, 2012
Posts: 8
Hello All

Please let me know if anyone can help me in this

Thanks!!
 
GeeCON Prague 2014
 
subject: Jboss 5.1 Jndi related problem