Search code examples
javajboss7.xfileutils

Java 6 - StackOverflowError when trying to copy and paste a file


Java 6
jboss-as-7.1.1.Final

I need to copy and paste a file. Using org.apache.commons.io.FileUtils and I tried with the following code,

If I invoke sync() from a jsp, getting

... java.lang.StackOverflowError at org.apache.catalina.core.ApplicationHttpRequest.removeAttribute(ApplicationHttpRequest.java:280) [jbossweb-7.0.13.Final.jar:] at org.apache.catalina.core.ApplicationHttpRequest.removeAttribute(ApplicationHttpRequest.java:280) [jbossweb-7.0.13.Final.jar:] at org.apache.catalina.core.ApplicationHttpRequest.removeAttribute(ApplicationHttpRequest.java:280) [jbossweb-7.0.13.Final.jar:]

private void sync() {
    try {
        FileUtils.copyFile(new File("C:/jboss-as-7.1.1.Final/standalone/deployments/admin.war/xml/news_src/compose.xml"), 
        new File("C:/jboss-as-7.1.1.Final/standalone/deployments/admin.war/xml/news_dest/compose.xml"));            
    } 
    catch (IOException e) {
        e.printStackTrace();
    }
}

If I run the same code as a standalone java application, the file gets copied and pasted to destination

public static void main(String s[]) {
    try {
        FileUtils.copyFile(new File("C:/jboss-as-7.1.1.Final/standalone/deployments/admin.war/xml/news_src/compose.xml"), 
        new File("C:/jboss-as-7.1.1.Final/standalone/deployments/admin.war/xml/news_dest/compose.xml"));        
    } 
    catch (IOException e) {
        e.printStackTrace();
    }
}

Why am I getting the StackOverflowError when the code invoked in a JBoss environment whereas executing the same code as java application runs successfully? Thanks.


Solution

  • I found a fix for this problem. The action class configuration in my framework, which is an in house built framework, was not correct, thus resulting in action class being called in a loop. I updated that setting, thus preventing action class execution in a loop.

    This SO post also guided me.