Registering JNDI Data Source in JBuilder6 with Tomcat 4.0.1
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   David_Vinas
Posted On:   Thursday, August 1, 2002 04:15 PM

I am running JBuilder6 Enterprise, and using the Tomcat 4.0.1 which was distributed with it. I have a servlet which connects to a JDBC data source, and I want to migrate this to JNDI. I followed all the steps as in the following article, so I won't repeat it here: How do I have to configure Tomcat 4.0 for using JDBC 2.0 DataSource objects? Anyway, I was getting a NoInitContextException , until I located the following patch on Borland's site, which patches JB6 to turn off the -nonaming flag when it starts Tomcat: CodeCentral: JBuilder 6 Tomcat 4.0 Fix - enable Tomcat's JNDI naming service So by now, I think I have the problem licked. Guess again. It appea   More>>

I am running JBuilder6 Enterprise, and using the Tomcat 4.0.1 which was distributed with it. I have a servlet which connects to a JDBC data source, and I want to migrate this to JNDI.



I followed all the steps as in the following article, so I won't repeat it here:



			How do I have to configure Tomcat 4.0 for using JDBC 2.0 DataSource objects?
		


Anyway, I was getting a NoInitContextException , until I located the following patch on Borland's site, which patches JB6 to turn off the -nonaming flag when it starts Tomcat:



			CodeCentral: JBuilder 6 Tomcat 4.0 Fix - enable Tomcat's JNDI naming service
		


So by now, I think I have the problem licked. Guess again. It appears that every time JBuilder kicks off Tomcat, it creates a file server[ port ].xml in the conf directory under my project directory. It then dynamically maps Tomcat to this file upon startup. So, putting my and tags in the file in Tomcat's conf directory has no effect. Now, I get a NullPointerException when I try to do a lookup on the DataSource, because it's never bound by Tomcat.



I am seriously up against a wall on this one. I've combed Borland's site and the web for the last three hours. Borland is completely lacking in any documentation regarding this topic. I seriously doubt that I'm the only one who has run into this. Can anybody help?

   <<Less

SOLUTION: Registering JNDI Data Source in JBuilder6 with Tomcat 4.0.x

Posted By:   David_Vinas  
Posted On:   Monday, August 12, 2002 09:43 PM

Steps to enable JNDI under JBuilder 6:



1) Download the fix "17777_jbuilder_6_tomcat_4.0_fix_enable_tomcat_s_jndi_naming_service.zip" from Borland and apply.


CodeCentral: JBuilder 6 Tomcat 4.0 Fix - enable Tomcat's JNDI naming service


2) Under the Project Properties->Servers select "Tomcat 4.0 with JNDI naming service"


3) Run the servlet


4) You will get exceptions on startup. Leave the servlet running. Go to /conf directory and make a copy of the file "servlet.xml" (eg. "servlet8080.xml"). I use the default name of "Copy of servlet8080.xml". Now shut down the servlet. Notice that JBuilder deletes the file "servlet8080.xml".


5) Rename the file "Copy of servlet8080.xml" back to "servlet8080.xml".


6) Edit the file in notepad. (You might want to replace all the with to be able to read it clearly.) Notice the two tags. The second one should refer to your actual application. Remove the "/" at the end of the tag, and add a closing tag after the tag. In between these tags, insert your resources. For example:







auth="Container"

type="javax.sql.DataSource"

description="My Oracle Database"/>





driverClassName

oracle.jdbc.driver.OracleDriver





driverName

jdbc:oracle:thin:@[host]:1521:[sid]





user

[scott]





password

[tiger]








(Replace everything in [ ] with your own values.)



7) Now make another copy of the server8080.xml file for safekeeping. JBuilder will try to delete it, which we will try to prevent.


8) Right-click the server8080.xml file, and click Properties. Click "Read only" and press "Apply". Now go to the security tab. Basically, you want to give everyone, including yourself, "Read only" privileges. It's a bit different process, depending on which O/S you're using.


  • If you're using NT, click each visible user group, and select "Read only" in the combo box for each one.


  • If you're using 2000, uncheck the checkbox at the bottom ("Allow inheritable permissions..."), then confirm. Next, click "Deny" for "Full control", and then click "Allow" for "Read & Execute". I know, Microsoft had to go out of their way to make a system this stupid. Just go with it. Press OK on the security dialog.



    You should be able to run your servlet with JNDI/JDBC enabled. You can place any other resources in the server8080.xml file as well. I am binding environment resources, and it works well. See the Tomcat 4.0 JNDI Resources How-to document for more info.



    Good luck!
  • Re: Registering JNDI Data Source in JBuilder6 with Tomcat 4.0.1

    Posted By:   Laurent_Mihalkovic  
    Posted On:   Saturday, August 10, 2002 02:43 AM

    Tomcat 4.0.1 is getting pretty old now, so I'd suggest you update the version of Tomcat that comes with JBuilder to a more recent version. I did that with JBuilder 7, and i took care of a few anoying problems i was having... I basically kept the name if the directory but replaced its content with a newer version (JBuilder 7 was very much attached to the directory name)...

    Let me know if that takes you a step closer to your solution.

    cheers,
    laurent

    About | Sitemap | Contact