Announcement Announcement Module
Collapse
No announcement yet.
Adding JNDI configuration to TC Server Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Adding JNDI configuration to TC Server

    Hi,

    Does anyone know how to add a JNDI config section to an application context xml file in TC Server? I am considering just removing this and installing a standalone tomcat because everytime I add my entry to the myapplication.xml context file and then restart the server it has been removed.

    How do I make this value stay in the file instead of getting cleaned down?

    Thanks

  • #2
    Originally posted by paul_ View Post
    Hi,

    Does anyone know how to add a JNDI config section to an application context xml file in TC Server? I am considering just removing this and installing a standalone tomcat because everytime I add my entry to the myapplication.xml context file and then restart the server it has been removed.

    How do I make this value stay in the file instead of getting cleaned down?

    Thanks
    I dont know if I should point out that this is the VMware Vfabric TC Server that ships with STS. In the context.xml file it even has commented out sections which say "Uncomment this for ..." yet if I add anything to this file and restart the server then it has reset the file back to its default again and any changes I have made have been removed.

    Comment


    • #3
      I have managed to at least get my application to start up without any errors although the configuration needed to do this is far from ideal.

      If someone has a way to properly configure a JNDI resource for use in this server the please let me know. What I have discovered so far is that if I edit the application context xml OR the server context.xml file and then rebuild and deploy and restart the server then these changes are lost.

      How do I get either of these config files (myapplication.xml or context.xml) to pick up changes when my project is cleaned and then rebuilt? Do I need to edit some other config file for this server?
      Last edited by paul_; Jul 19th, 2012, 08:53 AM.

      Comment


      • #4
        Hi, Paul.

        This is "as designed" functionality, but there have been enough people bitten by this that we will have to rethink our design. I can't get to it today, and am (probably) going on vacation tomorrow for a few days, but I will take a look at it on Monday at the latest.

        Comment


        • #5
          Originally posted by [email protected] View Post
          Hi, Paul.

          This is "as designed" functionality, but there have been enough people bitten by this that we will have to rethink our design. I can't get to it today, and am (probably) going on vacation tomorrow for a few days, but I will take a look at it on Monday at the latest.
          Hi Kate,

          Thanks for the reply. I have finally worked this out (although probably not the most ideal way to do it I'm sure). I think this could be a pitfall for developers who are used to working with say netbeans (like me) and using a stand alone tomcat installation with the freedom to edit the configuration in any way you like.

          Anyway just in case some one in the future does need to do this, and it may be blatantly obvious to people if you use eclipse or STS all the time (please forgive my ignorance) here is how I did it.

          1) In STS, in the servers tab double click your tomcat or VmFabric server. Check the box in the server options area titled "Publish module contexts to separate XML files". This may be unnecessary but I never add my contexts to the server.xml (this may be fine in development though I dont know) and prefer to have a separate xml file for this. Anyway this will give you the /Catalina/localhost/myapp.xml context file.

          2) Navigate to your workspace for the project you need jndi in. Now browse to the following directory (adjust to your needs) C:\EclipseWorkingFolder\.metadata\.plugins\org.ecl ipse.wst.server.core\tmp1\wtpwebapps\myapp\META-INF

          3) Place a file called context.xml into this directory, again this might not be the best way to do this but it works for me and if there is a better way I would really like to know. The content of this file can contain whatever you would like to embed within your context tags in your tomcat application context: EG

          Code:
          <Context>    
          	<Resource name="jdbc/bspDb" auth="Container" type="javax.sql.DataSource" username="user" password="password" driverClassName="oracle.jdbc.OracleDriver" url="jdbc:oracle:thin:@DEVDB1:1521:DEV1" maxActive="8" maxIdle="4"/>
          </Context>
          4) Redeploy your application to the server and now browse to C:\EclipseWorkingFolder\.metadata\.plugins\org.ecl ipse.wst.server.core\tmp1\conf (tmp1 is where my application is deployed but dependent on how many servers you have deployed you could have more or less directories so it might not be tmp1)

          In the conf directory you should now see your Catalina\localhost directories like in a standard tomcat install which is where you would place your context files

          5) Further drill down into C:\EclipseWorkingFolder\.metadata\.plugins\org.ecl ipse.wst.server.core\tmp1\conf\Catalina\localhost

          You should now see a context xml file there: myapp.xml

          <?xml version="1.0" encoding="UTF-8"?>
          <Context docBase="C:\EclipseWorkingFolder\.metadata\.plugin s\org.eclipse.wst.server.core\tmp1\wtpwebapps\myap p" reloadable="true" source="org.eclipse.jst.j2ee.server:myapp">
          <Resource auth="Container" driverClassName="oracle.jdbc.OracleDriver" maxActive="8" maxIdle="4" name="jdbc/bspDb" password="password" type="javax.sql.DataSource" url="jdbc:oracle:thin:@DEVDB1:1521EV1" username="USER"/>
          </Context>

          Anyway this seems to work for me and gives me the desired results. I know to most its probably quite obvious but to people new to eclipse, STS or to using embedded servers then it might not be so obvious so hopefully this could be of some help to those people.

          Thanks,

          Paul
          Last edited by paul_; Jul 26th, 2012, 05:56 AM.

          Comment


          • #6
            Hey Paul,

            thank you very much for the detailed report. We should clearly improve this to allow people to do this kind of things more easily and straight forward. Thanks again for sharing your results and workaround here!!!

            Cheers,
            -Martin

            Comment


            • #7
              Has anyone worked on enhancements to avoid the workaround?

              Comment

              Working...
              X