Amit Arora

Ranch Hand
+ Follow
since Jun 14, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Amit Arora

Thanks for reply Pawel. I have heard that pom.xml becomes too complex if your project size is getting bigger, moreover you cannot go for scripting in pom.xml (which you may need at some time) and the maven is rigid. All these problems are addressed in Gradle which is groovy based.
12 years ago
Hi,

I am looking to start a new project (web application in Java/J2EE using Spring). I am looking for build tools which are available. I have heard about Maven and Gradle, providing more features compared to Ant like
  • dependency Management,
  • project structure,
  • convention over configuration,
  • versioning
  • But still not able to find out the best tool that can be used. I have gone through lots of discussion, all are saying Gradle is better compared to Maven, but the articles were published in 2009, I have not found out the new article comparing the features of both Gradle and Maven.
    Please suggest the best build tool.


    Amit Arora
    (SCJP, SCWCD)
    12 years ago
    That has been fixed in the new release 3.3
    I am using JPA for persistence and using Hibernate as persistence provider. I want to get XML output from query. This is supported in Hibernate by using following code:



    Where this 'elem' is DOM4J element which is XML element. This is working fine when I am using hbm files for storing meta-data, but whem I am using JPA annotation for storing metadata, code is giving following error.



    What would be the solution for getting the result in XML from JPA entity?
    Hi

    I am doing a project having a lot of modules. Each module is having its own custom defined exception. Say I have IndexExporter and RequestCreator module having IndexExporterException and RequestCreatorException respectively. These are made to have each module its own specific exception.

    The Main module is calling IndexExporter which is calling the RequestCreator. The RequestCreator is having the FileNotFoundException caught using try catch. The exception is wrapped with RequestCreatorEception and thrown. This could be shown in code as:

    Request Creator module:

    try{
    ......
    }catch(FileNotFoundException e){
    throw new RequestCreatorException("File not found, Request Creation Failed", e);
    }

    This exception is propagated to IndexExporter module where it is again caught and wrapped by IndexExporterException and re-thrown which is then caught by main module.

    IndexExporter module:
    try{
    ......
    }catch(RequestCreatorException e){
    throw new IndexExporterException("Index Exporter Failed", e);
    }

    Main moudule:

    try{
    ......
    }catch(IndexExporterException e){
    log.error(e.getMessage(), e);
    System.exit(1);
    }


    If the logging is done in this manner, that produces a complex stack trace. Is this better way to handle the exception?
    Should exception be logged as it is caught for the first time as that gives better stacktrace? Then what is the purpose of wrapping the exception?
    What is the best way to handle the exception?
    Should main catch the exception or it should throw it to JVM?
    15 years ago
    Hi Brad,

    Thanks a lot .
    I have solved the problem. Actually I am encoding the same character again and again while merging the thing. That is giving the OutOfMemoryError. It has been fixed.

    Amit
    15 years ago
    Hi

    I have an XML file which contains UTF8 characters. I have divided it into small chunk (XML) and have transformed that chunk using XSLT into XML and have converted it into object using XMLBeans and serialize it to file and again continue it for the next chunk. Next transformed chunk will be merged with the pervious chunk to get the output. This process continues for number of chunks. I am using STAX for merging. The problem is that for writing the chunk I was using

    Writer file = null;
    try {
    file = new FileWriter(atempDestFileName);
    }
    catch (IOException exception) {
    throw exception;
    }
    That was working fine, but the UTF-8 characters were not encoded properly. So I have used the followng:

    try {
    file = new OutputStreamWriter(new FileOutputStream(atempDestFileName),"UTF-8");
    }
    catch (IOException exception) {
    throw exception;
    }

    It has written some chunk but after some processing the system is giving the OutOfMemoryError for writing the chunk.

    Any help is appreciated.

    Thanks
    Amit
    15 years ago
    The heap size is 512 MB, and I could not increase beyond that.
    Hi

    I have to transform a XML upto 1 GB into another XML. I have used XSLT for the same. But the same is giving the Out of memory error. I have used the TransformerFactory of XALAN (default in JDK 1.6) and SAXON (SXON - 9). But both of these transformers could not be able to transform the data of size more than 100 MB. I have used the Source as SAXSource, STAXSource and result as StreamResult and STAXResult, but could not be able to handle the error.
    I have tried for STX, that language could transform the larger XML (input 1 GB , output 4 GB). But as STX is not a standard, could the same be possible with any other XSLT transformer.

    Thanks And Regards,
    Amit
    SCJP , SCWCD
    Hi Bill,

    I have tried the same. Still the way I have calculated the memory is showing different usage then what was displayed in Task Manager. About 10MB difference with Virtual memory. I want to know is there any other way to calculate the same.

    Thanks and Regards,
    Amit
    SCJP and SCWCD
    16 years ago
    Thanks for your reply

    I have found that the virtual memory usage 2 MB more than the Physical memory usage.
    That was again 10 MB more than what I have calculated (Heap + Non Heap memory) using MemoryMXBean. I am unable to correlate with the Virtual Memory and Physical memory in Task manager
    16 years ago
    Hi

    I have to calculate the memory consumed by my Java program.
    I have used following line in the program to calculate the memory

    MemoryMXBean mbean = ManagementFactory.getMemoryMXBean();
    MemoryUsage usage = mbean.getHeapMemoryUsage();
    MemoryUsage nonHeapusage = mbean.getNonHeapMemoryUsage();
    long total = (usage.getUsed()+nonHeapusage.getUsed())/1024;

    That is displaying the memory consumed in KB.
    But when I look at java.exe process in Task Manager on Windows machine, that was showing more memory consumed (approx 9MB more) than what is displayed by my calculation.

    I have some questions on that:
    1.Is the memory being consumed by some other mechanism other than heap and non heap?
    2.Is there any other way to calculate the memory same as task manager?
    3.What is this NonHeapMemoryUsage, is this same as stack?
    4.The MemoryMXBean is returning the pool of memory by calling ManagementFactory.getMemoryPoolMXBeans(). What are those pools and whether they plays a role in memory consumption?
    I have once added the memory usage by all the pools. That size is much bigger that Task Manager size. And is growing continuously.

    Regards,
    Amit Arora
    SCJP,SCWCD
    16 years ago
    I have completed the certifications SCJP and SCWCD and planing to go for SCDJWS. I have heard that the new version web services may be released. If it is, should I wait for that or I continue with the older version.If it is not please guide me in preparing for the exam. I want to know the exact book which could cover the exam objectives

    Thanks
    Amit
    I have to generate the classes from schema (XSD). Then I have to unmarhsall the XML into objects and then marshall the objects to XML.
    I have looked for various framework supporting that. I have looked for JAXB, Castor, XMLBeans, JIBX, Quick and Zeus.
    The finding are as:

    1. Quick and Zeus does not support the class generation from XSD, only supports class generation from DTD.
    2. JIBX does not support class generation from schema having enumeration or restriction tag.
    3. JAXB supports generation of classes but could not unmarshall the XML (provided to me, although it supports unmarshalling from other XMLs), as XSD have only complex types, so could not generate the classes corresponding to the root element. So failed due to the binding problem with the XML provided to me.
    4. Castor and XMLBeans are working fine. I am confused to use which of the approach. The problem is with the memory. I have run a lot of tests and have found that performance of XMLBeans is far better compared to Castor, but for larger XML (>20MB) the castor works fine but XMLBeans throws OutOfMemory Error. The observations are:

    -------------------------------
    Memory| Castor | XMLBeans
    -------------------------------
    10MB | 10 sec | 3 sec
    22MB | 16 sec | Failed
    32MB | 18 sec | Failed
    42MB | Failed | Failed

    The size of XML could be large, could anyone suggests how to improve the performance of castor or how could XMLBeans supports the much bigger XML? The heap memory allocated is 256MB and that is fixed.
    16 years ago
    Hi

    You could try for STX to be used for XML transformation. It does not load the document in the memory. The heap size would be less. But it is a different language used for transformation.