DB_LOCK_DEADLOCK: Using BerkeleyDB Xml in a threaded environment

Hello,
I'm having problems running a Berkeley DB application in a threaded environment. In summary, this is what I'm doing:
I implemented the following class:
ref class MyTestClass
private:
     DbEnv* env;
     XmlManager* man;
     unsigned int ctr;
public:
     MyTestClass()
          ctr = 0;
          env = new DbEnv(0);
          env->set_cachesize(0, 64*1024, 1);
          env->set_lk_max_lockers(1000);
          env->set_lk_max_locks(1000);
          env->set_lk_max_objects(1000);
          env->open("c:\\temp\\SampleDb",
DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG |
DB_INIT_MPOOL | DB_INIT_TXN | DB_THREAD | DB_PRIVATE, 0);
          man = new XmlManager(env, DBXML_ALLOW_AUTO_OPEN);
     void MyTestWriter()
          while(true)
               DbXml::XmlQueryContext *ctx;
               DbXml::XmlTransaction *txn;
               DbXml::XmlResults *res;
               try
                    ctx = new XmlQueryContext(man->createQueryContext(XmlQueryContext::LiveValues, XmlQueryContext::Lazy));
                    txn = new XmlTransaction(man->createTransaction());
                    res = new XmlResults(man->query(*txn, "for $v in collection('test.dbxml')/sessions return insert nodes <A/> into$v", *ctx, DB_RMW));
                    txn->commit(DB_TXN_SYNC);
               catch(XmlException& e)
               finally
                    delete res;
                    delete txn;
                    delete ctx;
     void DeadlockUnblocker()
          while(true)
               int ret;
               env->lock_detect(0, DB_LOCK_DEFAULT, &ret);
               Sleep(5000);
Basically I create a shared MyTestClass object and then spawn 4 threads: 3 of them execute the MyTestWriter method and 1 executes the DeadlockUnblocker method.
What happens is that the 3 threads block even before completing the first write. After 5 seconds the DeadlockUnblocker is executed and 1 thread is unblocked and throws a "DB_LOCK_DEADLOCK: Locker killed to resolve a deadlock" which is trapped by my catch block. However, the other threads are still hanging on the execution and the entire flow of the application is stopped.
Anybody can tell me what I'm doing wrong ??
Thanks
Matteo

Matteo,
First, the C++ API works best if you avoid new/delete of Xml* objects. There are relatively few cases where that's necessary. Using scoped objects ensures their destruction.
As for your hang the best tool to use is "db_stat -CA" in the environment directory at the time of the hang to find out what is going on. You'll have to not use DB_PRIVATE in the DbEnv::open() flags for it to work. While a deadlock thread is reasonable if you expect a lot of deadlocks (and concurrent write will do that) it is best to use DbEnv::set_lk_detect() to get immediate detection.
Regards,
George

Similar Messages

  • Using iTunes SDK in multi thread environment

    I'd like to use the Windows iTunes COM SDK in a multithread manor.
    Ex. create the iTunes COM object in thread A and use it again in thread B.
    How it the COM interface for iTunes defined (MULTITHREADED, APPERTMENT THREAD, SINGLETHREADED)
    Can I then marshall the interface, between interfaces, without deadlocking my app? (I hate frozen apps, so I use threads as much as possible).

    Annoyingly the SDK hasn't been updated in over three years. I've had a casual look via Visual Studio's object inspector to see if I can spot any new methods or properties that could be useful but if they are there then they are hidden well. Media Kind, for example, was introduced in iTunes 9, I think, but can't be read from code.
    I don't know what tasks you're hoping to automate, but you might find some of my scripts useful either in their own right or as food for thought.
    tt2

  • Using store.sync in threaded environment

    Dear All,
    I just wanted to know what will happen during this condition.
    I have been using berkeley DB java edition for a while.
    I have this environment set
    private Environment myEnv;
    private EntityStore store;
    private PrimaryIndex pk;
    private SecondaryIndex sk;
    EnvironmentConfig myEnvConfig = new EnvironmentConfig();
    myEnvConfig.setAllowCreate(true);
    myEnvConfig.setSharedCache(true);
    myEnv = new Environment(envHome, myEnvConfig);
    StoreConfig storeConfig = new StoreConfig();
    storeConfig.setAllowCreate(true);
    storeConfig.setDeferredWrite(true);
    store = new EntityStore(myEnv, storeName, storeConfig);
    As you can see I have set deferredwrite as true .
    Due to this I have to use sync.store whenever inserts and delete take place.
    I have threaded environment . I just wanted to know .
    Due to the above setting during inserts and delete happening in together will my berkeley db cache ever get corrupted .
    I have not yet seen any issue .
    Is there by any chance cache would be corrupted. Please update me on this
    Regards
    Ashwin

    Ashwin,
    When you use deferred write, you are (a) running without transactions, and (b) reducing your durability guarantee. That is, if the environment goes down, you might lose some portion of the operations you were doing with deferred write.
    (b) only applies when the environment crashes and restarts. I think that you are asking about concurrent reads to the deferred write database while the environment is up. In that case, the issues you have to think about are the same as with regular non-transactional updates. Because you are not using transactions, there is a chance that a reading thread will see data that is logically inconsistent. For example, since you have secondary indices, an insert into the store will result in an insert both into the primary and the secondary index. Since the insert is non transactional, those two updates are not atomic, and another thread may happen to read the primary before the secondary index insert has completed.
    However, you should never see a data record that is physically corrupt. Each data record will be correct, which considered on its own.
    Regards,
    Linda

  • Mutli threaded Using Spring XML

    Hi Experts,
    I am very new to Spring and I am trying to make thread pool using Spring (.xml). Using Core Java I was to write a Java class but in spring I need you ppl help.
    I have a Java class one, two three and four.
    I want to execute Java class one, two and three in parallel. Once this parallel task is done I need to execute Java class four.
    How can I write the xml file for this. Please help me in this.
    Regards,
    Kalai

    Who says you can write XML to do that?
    In any case if you want to find some Spring way to do it, read the online Spring manual. Its quite complete you know. If it isn't in there, you probably cannot do it and you'll have to find some other way, like write some code.

  • Multiple Containers read/write access in multi-threaded environment

    I'm been reading the Berkeley DB XML Transaction Processing document and have a few questions. I have a multi-threaded environment (not multi-process).
    1) In the "Summary and Examples" section, there is an example of several worker threads that perform many writes to a shared container. The one container is passed to all the worker threads, rather them having their own instance of the container. In my application, I could potentially have multiple worker threads acting on the same container, is it better to provide some type of connection pool, so each thread has access to the same container? Is their a problem with each thread creating a new instance of the container and writing to that? Is their pros and cons to each approach?
    2) In some specific web applications, they only require read-access and have no intention of writing to the database. If the environment was created with transactions, can these applications open the environment in read-only mode, so as to not suffer the performance penalty of using transactions? Or do they still require transaction support since other threads in other applications might be writing to it. Is it better in this case to
    3) Is there any decent connection pooling framework that work well with BDB XML? If transactions are involved, it seems pretty important to always close the container once you are finished with it, which kind of defeats the purpose of pooling. I see a container somewhat analogous to a JDBC transaction, where in connection pooling these transactions remain open, but in BDB XML, it doesn't seem like this is good practice. So clarification here would be appreciated.
    Thanks in advance...
    Chris

    Chris,
    I'd be careful about trying to draw too many analogies with other sorts of systems. In many ways BDB XML is simpler -- it's just a library, no server process.
    An open container is analogous to an open file handle/descriptor in your operating system. It can safely be shared by all threads within a given process. In fact, you should not create more than one -- while that works, it can just be confusing, and a source of errors (for example, if you use a different path to open the container each time, you'll have problems). So by all means share them. Most Java applications just point them in a class that is accessible to all threads.
    Other objects that can, and should be shared among threads include:
    Environment
    XmlManager
    XmlQueryExpression
    Most others should not. You also mention closing your containers -- there is no reason to close your active container objects until your application needs to shut down. A long-running application will want to use db_checkpoint (or equivalent) to ensure that modified pages are flushed from the transaction log to the database files, but that's about it.
    As for concurrency, you obviously need transactions for concurrent write operations. If you want concurrent read access to the same containers, they should use transactions as well. Even if you don't explicitly use transactions, locks are always taken on pages in transactional containers. You cannot open the same container transactionally and not transactionally at the same time -- bad things could happen.
    Depending on your performance needs, you could using snapshot concurrency, and see how it works for you. While locking does incur some overhead, it may be acceptable.
    You mention creating your own "snapshot" of a container and running read-only on that copy. That's possible to do, but you have to be careful of how you create the snapshot (following hot backup procedures). Also, if you intend to open that "new" container in the same environment or application as the old one, you need to run a program on it to change its internal identification so Berkeley DB won't think it's the same file. That is, you can't just copy a container file to a new name and just open it like it's a new container if it's still in the vicinity of the original. See the -r option for the db_load program.
    Now that you are probably really confused, good luck!
    Regards,
    George

  • Thread: Could not generate the XML in single thread mode

    Hi all,
    I have created a report using PLSQL Procedure method after submitting the request I am getting the following Error.Couldn't sort out why I am getting the error while running the report.
    Error in "Multi threaded or single threaded execution block" of XXRX_REPORT_OUTPUT_PKG.insert_into_nested_table procedure
    ERROR :ORA-20005: Could not generate the XML in single thread mode
    XXRXERROR: XXRX_REPORT_OUTPUT_PKG.run_report SQLERROR: ORA-20005: ORA-20005: Could not generate the XML in single thread mode
    Can someone help me out finding the issue
    Thanks in Advance

    Hi,
    Please read SQL and PL/SQL FAQ
    We cannot guess what is the error if you don't post any part of your code.
    Additionally when you put some code or output please enclose it between two lines starting with {noformat}{noformat}
    i.e.:
    {noformat}{noformat}
    SELECT ...
    {noformat}{noformat}
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Validate xslt against JDK5 so we can remove the 'Use SAP XML Toolkit' flag

    We are working on PI7.1 and have hit an issue with an XSLT mapping. We were getting an error when testing that said:
    TransformerException during XSLT processing:
    javax.xml.transform.TransformerException: com.sun.org.apache.xalan.internal.xsltc.TransletException: com.sun.org.apache.xalan.internal.xsltc.TransletException: java.io.FileNotFoundException
    We found a few threads on SDN pointing us to using the 'Use SAP XML Toolkit' flag, which we'd not even noticed before. Ticking this flag did get us around the problem. Further investigation suggested to us, however, that this flag will not be available in future releases, so I guess our best solution would be to try and resolve the issues in our mapping against the current version of java (JDK5). When we use other tools such as XMLSPY they do not detect a problem with the XSLT. Can anyone point me to a tool that would enable us to validate our XSLT file against JDK5, which will provide us with error messages that will enable us to fix the error and therefore remove the 'Use SAP XML Toolkit' flag?
    thanks,
    Malcolm.

    > Can anyone point me to a tool that would enable us to validate our XSLT file against JDK5, which will provide us with error messages that will enable us to fix the error and therefore remove the 'Use SAP XML Toolkit' flag?
    I am sorry to have to say that even inside SAP nobody can answer this question.
    In principle it will work when it is pure XSLT 1.1 but some commands from XSLT 2.0 might work also.

  • Should Collections be used as return types across threads?

    I am wondering when, if ever, it is appropriate to use a Collection as the return type of a method in a multi-threaded environment. Here is our situation:
    We have four classes -- Widget, WidgetManager, ClientA, and ClientB. ClientA and ClientB are running in different Threads from each other and from the WidgetManager.
    The WidgetManager class that uses a Collection of Widgets internally, and passes the Collection (or an Iterator over it) out as a return value of a method to ClientA, which is running in another thread. ClientA would start to go through it using next() and hasNext() of the Iterator. If the WidgetManager were to get a request from ClientB running in another thread to eliminate a Widget, it would attempt to remove it from the Collection. If ClientA were still looping through the Iterator, this would throw an IllegalStateException b/c the system would be in an inconsistent state. The Iterator given to the ClientA is directly linked to the actual Collection in the WidgetManager (am I right so far?).
    In my opinion, in most cases we don't want to synchronize Collections. In the example above, if we had passed out a synchronized Collection, then the WidgetManager couldn't touch the collection while the client was looping through the Iterator. If the client got hung up while looping, then the WidgetManager would be hung up. In this case, I think that it will be better to use the toArray() method of Collection to just dump out the contents to a plain array of Objects. Actually, the WidgetManager could convert this array of Objects to an array of Widgets before passing it out, which would give us the type checking that we don't get with Containers.
    The condition where you would want to use a synchronized Collection would be when you actually want the client to do some writing or removing from the Collection. I would expect this to be pretty rare since you usually dont want to give clients access to an interal member (the Collection) of a class.
    I think that it is also possible to have read-only Collections, but I think (don't know for sure) that you would still have the same IllegalStateException or synchronization probelms.
    Can someone point out the errors in my thinking? Or should you generally only use Collections as internal members in a multi-threaded environment, and use toArray() whenever you want to pass the Collection's data outside of the class?
    Thanks for any help.
    Keith

    I haven't tested what happens when you synchronize the
    Collection, but I think that you are right. But this
    causes the problem that I mentioned in the first post.
    That is, what happens if your client STARTS running
    through the Iterator, and then stops or gets hung up
    for some reason? I assume that you're still blocked.
    And it's pretty important to me in this case to not
    t be blocked -- WidgetManager is the highest level
    class in the system.
    I'd like to know if anyone has tested this.
    The Iterator implementations used in java.util do not use any synchronization by itself, (which is what you would expect since synchronization over multiple method call will involve much more complications and slower performance) . With iterator, you have to provide the necessary synchronization yourself to maintain thread-safety like this
    Iterator itr = get Iterator from collectionInstance ;
    synchronized(collectionInstance) {
    while(itr.hasNext())
    process itr.next() ...
    As long as your client code gracefully exits the synchronized block on a stop( or hangup, given that it is detected and handled fast enough), it will not be a problem.
    Also, I'd like an example of when you WOULD want to
    return a Collection. I'm specifically interested in
    when you would want to return one in a multi-threaded
    environment, but I'm beginning to wonder when you
    would EVER want to return one from a method.
    Collections are great for internal uses, but you lose
    type-checking and you expose the internals of your
    class to modification when you use them as return
    types. And if you're returning a read-only
    Collection, you might as well return an array, right?Using a read-only proxy will be much faster and space-efficient than toArray().

  • How to use Harvester Only Using HarvesterSettings.xml on aia server

    Hi, I have a problem.
    I can not fix it.
    The following HarvesterSettings.xml I had to use.
    <?xml version="1.0" encoding="UTF-8"?>
    <tns:harvesterSettings xmlns:tns="http://www.oracle.com/oer/integration/harvester"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.oracle.com/oer/integration/harvester Harvester_Settings.xsd ">
    <harvesterDescription>Oracle Enterprise Repository Harvester</harvesterDescription>
    <registrationStatus>Registered</registrationStatus>
    <namespace/>
    <query>
         <fileQuery>
                   <files>E:/Oracle/Middleware/VM3/AIAMetaData/AIAComponents/EnterpriseBusinessServiceLibrary/Core/EBO/ReceivedPayment/V1/ReceivedPaymentEBS.wsdl</files>
    <fileType>.wsdl</fileType>
    </fileQuery>
    </query>
    <introspection>
    <reader>com.oracle.oer.sync.plugin.reader.file.FileReader</reader>
    <writer>com.oracle.oer.sync.plugin.writer.oer.OERWriter</writer>
    </introspection>
    </tns:harvesterSettings>
    The following command I had to use.
    e:\>AIAHarvest.bat -partial true -settings HarvesterSettings.xml -mode AIA
    When I run the command, the following error occurs.
    [main] ERROR com.oracle.aia.AIAHarvester - invalid composite xml
    Exception in thread "main" com.oracle.aia.InvalidCompositeException: invalid composite xml
    at com.oracle.aia.AIACompositeParser.parseXML<AIACompositeParser.java:732>
    at com.oracle.aia.AIAXmlReader.feedToCompositeParser<AIAXmlReader.java:94>
    at com.oracle.aia.AIACompositeMain.main<AIACompositeMain.java:62>
    at com.oracle.aia.AIAHarvester.main<AIAHarvester.java:94>
    E:/Oracle/Middleware/VM3/AIAMetaData/AIAComponents/EnterpriseBusinessServiceLibrary/Core/EBO/ReceivedPayment/V1/ReceivedPaymentEBS.wsdl
    is original file when I install FP

    cvoelker wrote:
    My question is, how you deal with locking of documents saved on the server or how you compare different versions of long documents in case you decide to work on a local copy.
    This question was asked and responded several times: we can't do that.
    Second, are there any third party tools available
    I don't know
    or any future plans on Apples side to extend iWork itself or Mac OS X Server to support locking and versioning in iWork documents for true collaboration?
    Nobody is allowed to write about Apple projects before the official announcement.
    So, if someone is aware of them, he will not respond here !
    On my idisk:
    <http://idisk.me.com/koenigyvan-Public?view=web>
    is a script designed to offer a workaround but I never got complete feedback so I don't know if it behaves correctly (I don't use networks).
    You may download:
    foriWork:iWork_sharing:iWorksharing.zip
    expand it, read the given instructions
    apply them on a copy of a document to check its behaviour.
    Yvan KOENIG (from FRANCE vendredi 5 décembre 2008 14:32:51)

  • Help to design repository using BerkeleyDB

    Hi,
    I am trying to design a repository using BerkeleyDB but not sure what will be the best design.
    Here is the scenario:
    I have one Schema under which we can multiple classes of Java Objects to be stored.
    Eg: Under Schema1, we can store any of the objects from three classes A, B, C.
    Alll have the same schema.
    I want to persist all the objects of any of the class A, B, C coming in the system.
    Key is the time at which they enter the system.
    So key is time and value is Instance of any of the object A, B,C.
    So we can have duplicates i.e. multiple instances coming at the same time.
    A,B,C are POJO Java Objects so I don't have control over their implementation.
    From my understanding
    Schema should map to the Environment.
    Within one Environment, we can have different databases for each A, B, C since they have different class definitions.
    What should I use DPL or Base APIs?
    If using Base API's how to write MyTupleBinding because the definition of the class can be available after system gets configured.
    Is there any way to write a generic TupleBinding class which can convert any Java Object to an Entry and vice versa.
    If using DPL how to define Entity, Persitent Entities etc.
    User can query on any column of a POJO object so we have no information about secondary keys.
    Please provide me your suggestions.

    Hi,
    Key is the time at which they enter the system.So key is time and value is Instance of any of the object A, B,C.
    So we can have duplicates i.e. multiple instances coming at the same time.>
    Instead of using the time only as the key, use a two part key {time, sequence} to make the key unique. That will give you a unique primary key and also allow you to lookup records by time using the first part of the key.
    A,B,C are POJO Java Objects so I don't have control over their implementation.Can you add annotations to these classes? Are they Serializable?
    From my understandingSchema should map to the Environment.
    Within one Environment, we can have different databases for each A, B, C since they have different class definitions.>
    Yes.
    What should I use DPL or Base APIs?If you can add annotations to the classes, use the DPL. If not, and the classes are Serializable, you could use SerialBinding. Otherwise, you'll have to write tuple bindings.
    If using Base API's how to write MyTupleBinding because the definition of the class can be available after system gets configured.Is there any way to write a generic TupleBinding class which can convert any Java Object to an Entry and vice versa.>
    The only way to do that is use Java reflection to discover the fields in the classes. This is a lot of work, but is how such things are done in Java.
    If using DPL how to define Entity, Persitent Entities etc.If you can't add annotations, you could write a custom subclass of EntityModel. But that's an advanced use case, and it won't work if there is no unique primary key field in each class.
    User can query on any column of a POJO object so we have no information about secondary keys.You can do one of the following:
    1) Define no secondary keys and iterate over all records in a database when doing a query (queries are expensive if there are lots of records).
    2) Define every field as a secondary key (writes are expensive and lots of disk space is used if there are lots of fields).
    3) Try to dynamically determine when queries are frequently done on a field, and dynamically add a secondary key at that time (lots of work to implement).
    Please provide me your suggestions.Please answer my questions above and then I'll suggest an approach. If the POJO classes are required to be Seriallizable, your task will be greatly simplified.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Static methods in multi-thread environment.

    Sorry for this silly question, but I have no clue...
    If you're using classes with static methods in a application server environment, would that imply all threads use that same 'one in the jvm' method and would there be a possibility for performance loss?
    Is calling another static method from a static method a good idea in a multi-thread environment, with respect to performance? Somehow I seem to get this java.lang.NoClassDefFoundError. Any ideas? The classes are in the same package. I only get these kind of problems calling static methods from static methods in a multi-thread environmnent. The static methods are pure utility functions and of course do not use class state.
    Thanks for your help.

    Sorry for this question, wasn't thinking straight. I have the answer, won't post question on multiple forums.

  • VB6 & XML Datasource using Native XML Driver

    We used to use reports that used ADO XML dataset, and in VB 6 we easily told the report which XML file to use by:
    Dim objCRReport As CRAXDRT.Report
    Set objCRReport = objCRApplication.OpenReport(App.path & "\crystal\" + rptName)
    objCRReport.DiscardSavedData
    objCRReport.Database.Tables.Item(1).Location = xmlFile
    where xmlFile was the fully qualified path to the xml data to pass to the report.
    Now we are trying to do this with a new report which uses a XML Native driver as its connection method. In VB6, how can we pass different xml files to use?
    We looked at objCRReport.Database.SetDataSource, but it expects some parameters that I don't understand ( data , { data type } , { table number  } )
    Is there an example anywhere of how to switch your datasource in code while using the XML Native Driver?

    See [this|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes.do] note.
    I would also recommend that you read the following regarding distribution of the runtime. This is important as the xml driver (crdb_xml.dll) uses Java:
    Apart from the regular deployment procedure for COM/RDC/NET applications, you have to follow the additional below-given steps in the client machines.
    Install the Java (JVM) 2 Runtime Environment (this is essentially the Java Framework needed to launch the crdb_xml native driver 1.4.2 from the java sun web site at:
    http://java.sun.com/j2se/1.4.2/download.html.
    Create a java folder inside the " C:Program FilesBusiness ObjectsCommon3.0";.
    Copy over the Crconfig.xml(C:Program FilesCommon FilesBusiness Objects3.0java) file from the development machine to the deployed machine in at the following path "C:Program FilesCommon FilesBusiness Objects3.0java" path. Open the crconfig.xml ; this file in Notepad and search for the line <JavaDir>. If JRE is installed to C:Program FilesJavaj2re1.4.2_12 in then the value should be look like this <JavaDir> C:Program FilesJavaj2re1.4.2_12 in</JavaDir>.
    Create a folder called lib in the "C:Program FilesCommon FilesBusiness Objects3.0java".
    Copy over the entire contents of the lib folder (especially the external folder) from the development machine to the newly created lib machine on the deployed machine. The point of this is to ensure that the crconfig.xml file contains all the files here which exist at the correct path which they now should because we copied over the lib and external directories.
    Copy crdb_xml.dll, crdb_xml_res_en, and all the files with "crdb_xml_res_xx from your development machine to the deployment machine (C:Program FilesCommon FilesBusiness Objects3.0 in).
    Restart your machine and try accessing your web application. The reports will show up the data without any issue.
    The above is written for CR XI release 1. You may have to adjust the path given above as you do not specify the version of Crystal reports you are using.
    Ludek

  • Using Berkeley XML DB in a servlet

    h2. Problem:
    I have a servlet using Berkeley XML DB as listed in the code snippet below. For simplicity I have removed the exception handling from the code snippet. When I invoke the servlet several times, the memory usage goes high and gets released only when the application is undeployed i.e when the destroy() method is called.
    h2. Questions:
    1. Is this the best way to use Berkeley XML DB in a servlet?
    2. What other techniques can be adopted to release memory held by XmlManager, XmlContainer and Environment?
    Please help!
    Thanks,
    Madhav
    h2. Code Snippet:
    public class MyServlet extends HttpServlet {
    String containerName = "mycontainer";
    String content = "<hello>Hello World</hello>";
    String environmentDir = ".";
    XmlManager mgr = null;
    XmlContainer cont = null;
    Environment env = null;
    public void init(ServletConfig config) throws ServletException {
    EnvironmentConfig config = new EnvironmentConfig();
    env = new Environment( new File(envHome), config);
    XmlManagerConfig mconfig = new XmlManagerConfig();
    mgr = new XmlManager(env, mconfig);
    XmlContainerConfig cconfig = new XmlContainerConfig();
    cont = mgr.createContainer(containerName, cconfig);
    public void destroy() {
    try {
    if (cont != null)
    cont.delete();
    if (mgr != null)
    mgr.delete();
    if (env != null)
    env.close();
    } catch (Exception e) {
    // ignore exceptions in cleanup
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    for (int i =; i < 5000; i++) {
    XmlTransaction txn = mgr.createTransaction();
    cont.putDocument(txn, newDocName, content);
    txn.commit();
    }

    Hi,
    I guess you posted not all code since I can't see for example configuring an environment for transaction support.
    Is your servlet doing only what is described in the doGet() method?
    Did you try to launch a stand-alone application and execute method doGet() multiple times? What happens with memory?
    Maybe you are using in-memory logging?
    Vyacheslav
    UPD: Probably you don't want to create and commit a txn for every small document. Grouping some of documents in the scope of a single transaction might help. I'm not sure about memory, but in terms of efficiency it's faster
    Edited by: detonator413 on Nov 13, 2009 11:38 PM
    Edited by: detonator413 on Nov 14, 2009 12:38 AM

  • Execute C# in PowerShell: errors with " using System.XML "

    Hi , I'm trying to execute C# code in Power Shell 2.0 .
    My problem is for the references  at the beginning of the code:
    $code = @"
    using System;
    using System.Collections;
    using System.IO;
    using System.Linq;
    using System.Xml;
    using System.Xml.Linq;
       public class Program
            static void Main()
            {  /* the code wich works*/
    Add-Type  -TypeDefinition $code -Language "CSharpVersion3"
    Powershell give me an error saying that " The type or namespace Linq doesn't exist" , and the same for Xml. I have Visual studio express 2013 .
    How can add or import correctly those references? or what is my error?

    Hi Rebegg,
    As this issue is related to Visual Studio, I suggest you create a new thread on Visual Studio forum, more experts will assist you with this issue.
    Visual Studio forum:
    http://social.msdn.microsoft.com/Forums/en-US/home?category=visualstudio
    In addition, about this issue, you have to add your  assemblies to your PowerShellsession before you can reference them to you C# Code, you can use the script like:
    $Assem = (
    ...add referenced assemblies here...
    $Source = @"
    ...add C# source code here...
    Add-Type -ReferencedAssemblies $Assem -TypeDefinition $Source -Language CSharp
    Here are some similar posts for your reference:
    http://ruudvanderlinden.com/2010/10/19/running-inline-c-with-custom-assemblies-in-powershell-2-0/
    http://powershell.com/cs/media/p/133.aspx
    http://blogs.technet.com/b/stefan_gossner/archive/2010/05/07/using-csharp-c-code-in-powershell-scripts.aspx
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • Overriding web.xml using Plan.xml

    Hi,
    I want to override certain values (MAX_ROW_FETCH_SIZE)  in web.xml using Plan.xml for a servlet deployed on weblogic server.
    My web.xml looks like this.
    <?xml version = '1.0' encoding = 'windows-1252'?>
    <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
             version="2.5">
      <servlet>
        <servlet-name>trial</servlet-name>
        <servlet-class>oracle.apps.cmi.sv.fwk.webui.trial</servlet-class>
        <init-param>
          <param-name>MAX_ROW_FETCH_SIZE</param-name>
          <param-value>50</param-value>
        </init-param>
        <init-param>
          <param-name>JDBC_MAX_FETCH_SIZE</param-name>
          <param-value>20</param-value>
        </init-param>
      </servlet>
      <servlet-mapping>
        <servlet-name>trial</servlet-name>
        <url-pattern>/trial</url-pattern>
      </servlet-mapping>
    </web-app>
    My Plan.xml looks like this
    <?xml version='1.0' encoding='UTF-8'?>
    <deployment-plan xmlns="http://xmlns.oracle.com/weblogic/deployment-plan" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/deployment-plan http://xmlns.oracle.com/weblogic/deployment-plan/1.0/deployment-plan.xsd">
      <application-name>SPUF</application-name>
      <variable-definition>
        <variable>
          <name>SessionDescriptor_timeoutSecs_13708393894780</name>
          <value>3602</value>
        </variable>
        <variable>
          <name>MAX_ROW_FETCH_SIZE</name>
          <value>3</value>
        </variable>
        <variable>
          <name>JDBC_MAX_FETCH_SIZE</name>
          <value>2</value>
        </variable>       
      </variable-definition>
      <module-override>
        <module-name>SPUF.war</module-name>
        <module-type>war</module-type>
        <module-descriptor external="false">
          <root-element>weblogic-web-app</root-element>
          <uri>WEB-INF/weblogic.xml</uri>
          <variable-assignment>
            <name>SessionDescriptor_timeoutSecs_13708393894780</name>
            <xpath>/weblogic-web-app/session-descriptor/timeout-secs</xpath>
          </variable-assignment>
        </module-descriptor>
        <module-descriptor external="false">
          <root-element>web-app</root-element>
          <uri>WEB-INF/web.xml</uri>
          <variable-assignment>
            <name>MAX_ROW_FETCH_SIZE</name>
            <xpath>/web-app/servlet/init-param/[param-name="MAX_ROW_FETCH_SIZE"]/param-value</xpath>
            <operation>replace</operation>
          </variable-assignment>
          <variable-assignment>
            <name>JDBC_MAX_FETCH_SIZE</name>
            <xpath>/web-app/servlet/init-param/[param-name="JDBC_MAX_FETCH_SIZE"]/param-value</xpath>
            <operation>replace</operation>
           </variable-assignment>                     
        </module-descriptor>
        <module-descriptor external="true">
          <root-element>wldf-resource</root-element>
          <uri>META-INF/weblogic-diagnostics.xml</uri>
        </module-descriptor>
      </module-override>
      <config-root>/home/oracle/ebssdk2</config-root>
    </deployment-plan>
    I can see new value reflected for "Session TimeOut" for service configuration.
    However when I use service to query certain data while considering "MAX_ROW_FETCH_SIZE" parameter, It is still querying 50 rows (Value in web.xml) at a time instead of 3 (As defined in Plan.xml)
    I am using servlet init method to get init parameters in my java file.
    Can someone help me to overcome from this issue or have any suggestion?

    You could use Apache Ant and create 2 separate WAR files , one for development and one for production.
    Normally I don't create a WAR file for the development environment. WAR file is made only for production.
    This is how my Ant task runs currently.
    1) For the development environment the ant task runs only to compile Java classes and nothing else, web.xml is that for development environment.
    2) When the app is ready for production , I run Ant to copy all files from my dev folder to a temporary build folder - during this copy I filter out the .java files (since there's no longer a need for them in production) only class files are moved.
    3) Then I treat the above temporary folder as the source folder, and run the Jasper pre-compiler which significantly alters the web.xml file .
    But the good part is that my original development web.xml stays unaltered since it is in it's own folder.
    4) Then finally I run a WAR task on the processed contents of the temporary build folder which contains the modified web.xml
    This way each environment has it's own web.xml .

Maybe you are looking for

  • How to refresh the list of select one choice which is inside a table?

    Hello I am using Jdeveloper Version 11.1.2.1.0. The table is a normal table that is made to look like a treeTable. For some rows are or can be parents with Parent_vo_group_id = null and other are children with parent_vo_group_id = vo_group_id of the

  • Problem in unzipping the zip files

    Hi, I have created a program to unzip the zip files. But when i try to zip it is creating the zipped files outside the folder where it is to be zipped. what is wrong with my code. if the zip file is migration.zip if the path inside the zip file shows

  • Itunes freezes when synced to windows itunes

    It's been a long time since I've synced my phone and when i did it today it freezes up. I'm using an iphone 5 and i've updated my phone and my itunes but it still freezes everytime i tried to sync my photos or my music. The itunes backs up my files b

  • Mapping repeated (identical) elements to SQL columns based on element attribute

    Given this XML data, is it possible to generate the table shown?  If it's relatively easy, could someone please demonstrate.  If it's involved, then just suggesting references which are pertinent to solving this particular problem would be greatly ap

  • Problem in block property (delete allowed)

    hi friends, i have created a form having two blocks with non-isolated relation in them. i have set the delete allowed property to true for child block and false for master block. But when i run the form it will not allow me to delet the record from t