You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by ch...@r-it.at on 2005/08/03 16:08:28 UTC

Problem with repository.xml outside war-File

Hi all,

I have the following problem:

We use OJB 1.0.1 in a web-app under JBOSS 3.2.6 and with Oracle 9i.
If I pack repository.xml into the war-File, all works fine.

But in production the database-settings are changed one or two times a
year. For example, if they change the password of the db-user, which we use
to connect, we have to change and deploy the web-app.

Therefore the production requires, that all database-configuration have to
be outside of the jars, ears, wars etc.
But if I copy repository.xml to a folder, which is in classpath of JBOSS,
but outside of the app-war-File, OJB does not find the connection-settings.

Which changes have to be made in repository.xml in this case ?

My repository.xml looks like that (all xml-file-contents are copied into
this file because our xmlparser in JBOSS does resolve the placeholders):

............................

<descriptor-repository isolation-level="read-uncommitted"
    proxy-prefetching-limit="50" version="1.0">

    <!-- include all used database connections -->
<jdbc-connection-descriptor
      jcd-alias="xsrace00"
      default-connection="false"
      platform="Oracle"
      jdbc-level="2.0"
      driver="oracle.jdbc.driver.OracleDriver"
      protocol="jdbc"
      subprotocol="oracle:oci8"
      dbalias="@VDEV"
      username="CPT"
      password="CPT"
    eager-release="false"
    batch-mode="false"
    useAutoCommit="1"
    ignoreAutoCommitExceptions="false"
>

    <object-cache
class="org.apache.ojb.broker.cache.ObjectCacheEmptyImpl"/>

      <connection-pool maxActive="21" validationQuery="" />

      <sequence-manager
className="org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl">
          <attribute attribute-name="autoNaming" attribute-value="true"/>
      </sequence-manager>

</jdbc-connection-descriptor>

<jdbc-connection-descriptor
      jcd-alias="xsvgnp01"
      default-connection="false"
      platform="Oracle"
      jdbc-level="2.0"
      driver="oracle.jdbc.driver.OracleDriver"
      protocol="jdbc"
      subprotocol="oracle:oci8"
      dbalias="@VPROD"
      username="CPT"
      password="CPT"
    eager-release="false"
    batch-mode="false"
    useAutoCommit="1"
    ignoreAutoCommitExceptions="false"
>

    <object-cache
class="org.apache.ojb.broker.cache.ObjectCacheEmptyImpl"/>

      <connection-pool maxActive="21" validationQuery="" />

      <sequence-manager
className="org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl">
          <attribute attribute-name="autoNaming" attribute-value="true"/>
      </sequence-manager>

</jdbc-connection-descriptor>

    <!-- include ojb internal mappings here -->
    <!-- OJB INTERNAL MAPPINGS START HERE, DO NOT EDIT -->

..............

and my OJB.properties-File looks like that:

.................................
#----------------------------------------------------------------------------------------
# repository file settings
#----------------------------------------------------------------------------------------
# The repositoryFile entry tells OJB to use this file as as its standard
mapping
# repository. The file is looked up from the classpath.
#
repositoryFile=repository.xml
#
# If the useSerializedRepository entry is set to true, OJB tries to load a
# serialized version of the repository for performance reasons.
...................................

Please help.

Thanks in advance for your support.

Regards,

Christine

Re: Problem with repository.xml outside war-File

Posted by Bobby Lawrence <ro...@jlab.org>.
Look in OJB.properties.
There is a setting in that file stating the location of the repository file.
--Bobby


christine.gerstenmayer@r-it.at wrote:

>Hi all,
>
>I have the following problem:
>
>We use OJB 1.0.1 in a web-app under JBOSS 3.2.6 and with Oracle 9i.
>If I pack repository.xml into the war-File, all works fine.
>
>But in production the database-settings are changed one or two times a
>year. For example, if they change the password of the db-user, which we use
>to connect, we have to change and deploy the web-app.
>
>Therefore the production requires, that all database-configuration have to
>be outside of the jars, ears, wars etc.
>But if I copy repository.xml to a folder, which is in classpath of JBOSS,
>but outside of the app-war-File, OJB does not find the connection-settings.
>
>Which changes have to be made in repository.xml in this case ?
>
>My repository.xml looks like that (all xml-file-contents are copied into
>this file because our xmlparser in JBOSS does resolve the placeholders):
>
>............................
>
><descriptor-repository isolation-level="read-uncommitted"
>    proxy-prefetching-limit="50" version="1.0">
>
>    <!-- include all used database connections -->
><jdbc-connection-descriptor
>      jcd-alias="xsrace00"
>      default-connection="false"
>      platform="Oracle"
>      jdbc-level="2.0"
>      driver="oracle.jdbc.driver.OracleDriver"
>      protocol="jdbc"
>      subprotocol="oracle:oci8"
>      dbalias="@VDEV"
>      username="CPT"
>      password="CPT"
>    eager-release="false"
>    batch-mode="false"
>    useAutoCommit="1"
>    ignoreAutoCommitExceptions="false"
>  
>
>
>    <object-cache
>class="org.apache.ojb.broker.cache.ObjectCacheEmptyImpl"/>
>
>      <connection-pool maxActive="21" validationQuery="" />
>
>      <sequence-manager
>className="org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl">
>          <attribute attribute-name="autoNaming" attribute-value="true"/>
>      </sequence-manager>
>
></jdbc-connection-descriptor>
>
><jdbc-connection-descriptor
>      jcd-alias="xsvgnp01"
>      default-connection="false"
>      platform="Oracle"
>      jdbc-level="2.0"
>      driver="oracle.jdbc.driver.OracleDriver"
>      protocol="jdbc"
>      subprotocol="oracle:oci8"
>      dbalias="@VPROD"
>      username="CPT"
>      password="CPT"
>    eager-release="false"
>    batch-mode="false"
>    useAutoCommit="1"
>    ignoreAutoCommitExceptions="false"
>  
>
>
>    <object-cache
>class="org.apache.ojb.broker.cache.ObjectCacheEmptyImpl"/>
>
>      <connection-pool maxActive="21" validationQuery="" />
>
>      <sequence-manager
>className="org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl">
>          <attribute attribute-name="autoNaming" attribute-value="true"/>
>      </sequence-manager>
>
></jdbc-connection-descriptor>
>
>    <!-- include ojb internal mappings here -->
>    <!-- OJB INTERNAL MAPPINGS START HERE, DO NOT EDIT -->
>
>..............
>
>and my OJB.properties-File looks like that:
>
>.................................
>#----------------------------------------------------------------------------------------
># repository file settings
>#----------------------------------------------------------------------------------------
># The repositoryFile entry tells OJB to use this file as as its standard
>mapping
># repository. The file is looked up from the classpath.
>#
>repositoryFile=repository.xml
>#
># If the useSerializedRepository entry is set to true, OJB tries to load a
># serialized version of the repository for performance reasons.
>...................................
>
>Please help.
>
>Thanks in advance for your support.
>
>Regards,
>
>Christine
>  
>

-- 
----------------------------
Bobby Lawrence
MIS Application Developer

Jefferson Lab (www.jlab.org)

 Email: robertl@jlab.org
Office: (757) 269-5818
 Pager: (757) 584-5818
----------------------------



Re: Problem with repository.xml outside war-File

Posted by Guillaume Laforge <gl...@gmail.com>.
On 03/08/05, christine.gerstenmayer@r-it.at
<ch...@r-it.at> wrote:
> But when I regard this example, it does not solve the problem with the
> password-change of the db-user:
> 
> 
>  <jdbc-connection-descriptor
>      jcd-alias="default"
>      default-connection="true"
>      platform="Sapdb"
>      jdbc-level="2.0"
>      jndi-datasource-name="java:DefaultDS"
>      username="sa"             <-------------
>      password=""               <------------------
>      eager-release="false"
>      batch-mode="false"
>      useAutoCommit="0"
>      ignoreAutoCommitExceptions="false"

I'm by no means an OJB expert, but I think the username and password
attributes shouldn't be placed in the jdbc-connection-descriptor, but
are set in your datasource definition in JNDI or some other
configuration files (depending on your app server).

For instance, under Tomcat 5, you can define a MyWebApp.xml in
TOMCAT_HOME/conf/catalina/localhost where you define your datasource:

<Context path="/MyWebApp" unpackWARs="true" docBase="MyWebApp.war">

<!-- Tomcat 5.5 configuration -->
<!--
	<Resource name="jdbc/Datasource_DS" auth="Container"
type="javax.sql.DataSource"
		maxActive="10" maxIdle="5" maxWait="10000" username="myuser"
password="mypassword"
		driverClassName="oracle.jdbc.driver.OracleDriver" 
		url="jdbc:oracle:thin:@foo:1521:bar" 
		connectionProperties=""/>
-->

<!-- Tomcat 5.0 configuration -->
	<Resource name="jdbc/Datasource_DS" auth="Container"
type="javax.sql.DataSource"/>
	<ResourceParams name="jdbc/Datasource_DS">
		<parameter><name>username</name>             <value>myuser</value></parameter>
		<parameter><name>password</name>            
<value>mypassword</value></parameter>
		<parameter><name>driverClassName</name>     
<value>oracle.jdbc.driver.OracleDriver</value></parameter>
		<parameter><name>url</name>                 
<value>jdbc:oracle:thin:@foo:1521:bar</value></parameter>
		<parameter><name>maxActive</name>            <value>10</value></parameter>
		<parameter><name>maxIdle</name>              <value>5</value></parameter>
		<parameter><name>maxWait</name>              <value>10000</value></parameter>
	</ResourceParams>

</Context>



-- 
Guillaume Laforge
http://glaforge.free.fr/weblog/?catid=2

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with repository.xml outside war-File

Posted by ch...@r-it.at.
Hi Tom, Guillaume, Bobby, Eric,

sorry for the late answer, I was in holiday.

We will use the jndi-datasources as described.

Many thanks for your quick and helpful support !

Christine

PS: Don't worry about the mark "untrusted mail", it's only Lotus Notes :-))

Re: Problem with repository.xml outside war-File

Posted by Bobby Lawrence <ro...@jlab.org>.
Christine -
Tom is correct.  Use a JNDI datasource defined in the repository.xml 
file.  Leave out the username/password and OJB will use the 
username/password configured by you app server (JBoss).
This way, you chance the username/password in the JBoss configuration 
and OJB will have the new username/password combination whenever it 
requests the datasource from the container via JNDI.
--Bobby


christine.gerstenmayer@r-it.at wrote:

>Hi Tom,
>many thanks for the quick answer.
>
>But when I regard this example, it does not solve the problem with the
>password-change of the db-user:
>
>                                                                            
> <jdbc-connection-descriptor                                                
>     jcd-alias="default"                                                    
>     default-connection="true"                                              
>     platform="Sapdb"                                                       
>     jdbc-level="2.0"                                                       
>     jndi-datasource-name="java:DefaultDS"                                  
>     username="sa"             <-------------                               
>     password=""               <------------------                          
>     eager-release="false"                                                  
>     batch-mode="false"                                                     
>     useAutoCommit="0"                                                      
>     ignoreAutoCommitExceptions="false"                                     
> >                                                                          
>                                                                            
> Christine                                                                  
>                                                                            
>                                                                            
>
>tomdzk@gmail.com@inet schrieb am 03.08.2005 16:20:12:
>
>  
>
>>>We use OJB 1.0.1 in a web-app under JBOSS 3.2.6 and with Oracle 9i.
>>>If I pack repository.xml into the war-File, all works fine.
>>>
>>>But in production the database-settings are changed one or two times a
>>>year. For example, if they change the password of the db-user, which we
>>>      
>>>
>use
>  
>
>>>to connect, we have to change and deploy the web-app.
>>>      
>>>
>>The normal way in which webapps handle this, is to use JNDI
>>datasources. These are configured in the server configuration and
>>you'll give OJB only the jndi name (and the repository.xml file stays
>>in the war). Have a look here for an example:
>>
>>http://db.apache.org/ojb/docu/guides/deployment.html#%
>>0A++++++++++++++++++++++++-N1022A
>>
>>Tom
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>    
>>

-- 
----------------------------
Bobby Lawrence
MIS Application Developer

Jefferson Lab (www.jlab.org)

 Email: robertl@jlab.org
Office: (757) 269-5818
 Pager: (757) 584-5818
----------------------------



RE: Problem with repository.xml outside war-File

Posted by Eric Kelm <er...@vsgadmin.com>.
You can pass the username/password to the application at runtime through the
broker.  No need to store it in the repository.xml file. See
http://db.apache.org/ojb/docu/faq.html#userPasswordNeeded

And

http://db.apache.org/ojb/docu/faq.html#differentDBUsers




---------
Eric Kelm
Developer, VSG Worldwide LLC
510 Spur 63
Longview, TX 75601

->-----Original Message-----
->From: christine.gerstenmayer@r-it.at [mailto:christine.gerstenmayer@r-
->it.at]
->Sent: Wednesday, August 03, 2005 9:39 AM
->To: ojb-user@db.apache.org
->Subject: Re: Problem with repository.xml outside war-File
->
->
->Hi Tom,
->many thanks for the quick answer.
->
->But when I regard this example, it does not solve the problem with the
->password-change of the db-user:
->
->
-> <jdbc-connection-descriptor
->     jcd-alias="default"
->     default-connection="true"
->     platform="Sapdb"
->     jdbc-level="2.0"
->     jndi-datasource-name="java:DefaultDS"
->     username="sa"             <-------------
->     password=""               <------------------
->     eager-release="false"
->     batch-mode="false"
->     useAutoCommit="0"
->     ignoreAutoCommitExceptions="false"
-> >
->
-> Christine
->
->
->
->tomdzk@gmail.com@inet schrieb am 03.08.2005 16:20:12:
->
->> > We use OJB 1.0.1 in a web-app under JBOSS 3.2.6 and with Oracle 9i.
->> > If I pack repository.xml into the war-File, all works fine.
->> >
->> > But in production the database-settings are changed one or two times a
->> > year. For example, if they change the password of the db-user, which
->we
->use
->> > to connect, we have to change and deploy the web-app.
->>
->> The normal way in which webapps handle this, is to use JNDI
->> datasources. These are configured in the server configuration and
->> you'll give OJB only the jndi name (and the repository.xml file stays
->> in the war). Have a look here for an example:
->>
->> http://db.apache.org/ojb/docu/guides/deployment.html#%
->> 0A++++++++++++++++++++++++-N1022A
->>
->> Tom
->>
->> ---------------------------------------------------------------------
->> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
->> For additional commands, e-mail: ojb-user-help@db.apache.org
->>


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with repository.xml outside war-File

Posted by ch...@r-it.at.
Hi Tom,
many thanks for the quick answer.

But when I regard this example, it does not solve the problem with the
password-change of the db-user:

                                                                            
 <jdbc-connection-descriptor                                                
     jcd-alias="default"                                                    
     default-connection="true"                                              
     platform="Sapdb"                                                       
     jdbc-level="2.0"                                                       
     jndi-datasource-name="java:DefaultDS"                                  
     username="sa"             <-------------                               
     password=""               <------------------                          
     eager-release="false"                                                  
     batch-mode="false"                                                     
     useAutoCommit="0"                                                      
     ignoreAutoCommitExceptions="false"                                     
 >                                                                          
                                                                            
 Christine                                                                  
                                                                            
                                                                            

tomdzk@gmail.com@inet schrieb am 03.08.2005 16:20:12:

> > We use OJB 1.0.1 in a web-app under JBOSS 3.2.6 and with Oracle 9i.
> > If I pack repository.xml into the war-File, all works fine.
> >
> > But in production the database-settings are changed one or two times a
> > year. For example, if they change the password of the db-user, which we
use
> > to connect, we have to change and deploy the web-app.
>
> The normal way in which webapps handle this, is to use JNDI
> datasources. These are configured in the server configuration and
> you'll give OJB only the jndi name (and the repository.xml file stays
> in the war). Have a look here for an example:
>
> http://db.apache.org/ojb/docu/guides/deployment.html#%
> 0A++++++++++++++++++++++++-N1022A
>
> Tom
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>

Re: Problem with repository.xml outside war-File

Posted by Thomas Dudziak <to...@gmail.com>.
> We use OJB 1.0.1 in a web-app under JBOSS 3.2.6 and with Oracle 9i.
> If I pack repository.xml into the war-File, all works fine.
> 
> But in production the database-settings are changed one or two times a
> year. For example, if they change the password of the db-user, which we use
> to connect, we have to change and deploy the web-app.

The normal way in which webapps handle this, is to use JNDI
datasources. These are configured in the server configuration and
you'll give OJB only the jndi name (and the repository.xml file stays
in the war). Have a look here for an example:

http://db.apache.org/ojb/docu/guides/deployment.html#%0A++++++++++++++++++++++++-N1022A

Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org