ninada / full-hibernate-plugin-for-struts2

Automatically exported from code.google.com/p/full-hibernate-plugin-for-struts2
1 stars 0 forks source link

java.lang.StackOverflowError on method SessionTransactionInjectorInterceptor.isCandidadeClass #4

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
First of all, thanks for the plug-in it really makes life easier :-)

What version of the product are you using? On what operating system?
I'm using 1.5 GA plugin version.

Please provide any additional information below.

The application throw an java.lang.StackOverflowError. Debbuging the app i
could see that the action class' annotated property is successfully
receiving a hibernate session object. 
Since i am not extending 'hibernate-default' (i need a custom interceptor
stack instead) i think that, maybe, the problem is related to the
configuration in struts.xml.

My action class extends a class that have the Session property.

Here goes my struts.xml interceptors configuration section

<interceptors>
            <interceptor name="login"
class="br.gov.trems.licitacao.controller.interceptor.LoginInterceptor" />
            <interceptor name="hibernateSession"
class="com.googlecode.s2hibernate.struts2.plugin.interceptors.SessionTransaction
InjectorInterceptor"
/>
            <interceptor-stack name="custom">

                <interceptor-ref name="exception">
                    <param name="logEnabled">true</param>
                    <param name="logLevel">debug</param>
                    <param name="logCategory">util.Logger</param>
                </interceptor-ref>
                <interceptor-ref name="alias"/>
                <interceptor-ref name="params"/>
                <interceptor-ref name="servletConfig"/>
                <interceptor-ref name="prepare"/>
                <interceptor-ref name="i18n"/>
                <interceptor-ref name="chain"/>
                <interceptor-ref name="modelDriven"/>
                <interceptor-ref name="fileUpload" />
                <interceptor-ref name="checkbox"/>
                <interceptor-ref name="staticParams"/>
                <interceptor-ref name="params"/>
                <!--interceptor-ref name="conversionError"/-->
                <interceptor-ref name="validation">
                    <param name="excludeMethods">input,back,cancel</param>
                </interceptor-ref>                
                <interceptor-ref name="workflow">
                    <param name="excludeMethods">input,back,cancel</param>
                </interceptor-ref>                                
                <interceptor-ref name="hibernateSession" />
<!-- Custom security interceptor -->
                <interceptor-ref name="login" />                
            </interceptor-stack>            
        </interceptors>

        <default-interceptor-ref name="custom" />

This is my action class source :

public class HomeAction extends BasicCrudAction {

    private PageParams notificacoes;    

    private NotificacaoDAO notificacaoDAO;

    private Usuario usuario;    

    private Notificacao notificacao;

    public HomeAction() {        
    }    

    @Override
    public String execute(){       

        notificacao.setUsuario(usuario);
        notificacao.setLido(new Boolean(false));
        notificacao.setData(null);

        notificacaoDAO =
DAOFactory.getFactory().createNotificacaoDAO(hibernateSession);
        lista = notificacaoDAO.list(notificacao, lista);

        return SUCCESS;
    }

}

The Session property belongs to BasicCrudAction, and the source code is the
following:

public abstract class BasicCrudAction extends ActionSupport implements
LoginAware, SessionAware, ModelDriven, Preparable {        

    private Map session;    

    protected PageParams lista = new PageParams();

    @SessionTarget
    protected Session hibernateSession;    

    public BasicCrudAction() {
    }

    public void setSession(Map session) {
        this.session = session;
        isReport();
    }

    public Session getHibernateSession() {
        return hibernateSession;
    }

    public void setHibernateSession(Session hibernateSession) {
        this.hibernateSession = hibernateSession;
    }

}

And finally the error message:

exception

javax.servlet.ServletException: Filter execution threw an exception
    org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125)
    org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)

root cause

java.lang.StackOverflowError
    java.util.LinkedHashMap$LinkedHashIterator.<init>(LinkedHashMap.java:345)
    java.util.LinkedHashMap$LinkedHashIterator.<init>(LinkedHashMap.java:345)
    java.util.LinkedHashMap$KeyIterator.<init>(LinkedHashMap.java:383)
    java.util.LinkedHashMap$KeyIterator.<init>(LinkedHashMap.java:383)
    java.util.LinkedHashMap.newKeyIterator(LinkedHashMap.java:396)
    java.util.HashMap$KeySet.iterator(HashMap.java:874)
    java.util.HashSet.iterator(HashSet.java:153)
    com.googlecode.s2hibernate.struts2.plugin.interceptors.SessionTransactionInjectorInterceptor.isCandidadeClass(SessionTransactionInjectorInterceptor.java:351)
    com.googlecode.s2hibernate.struts2.plugin.interceptors.SessionTransactionInjectorInterceptor.injectHibernateCoreSessionByAnnotation(SessionTransactionInjectorInterceptor.java:374)

This last line repeats over fifth times.

Thanks.

Original issue reported on code.google.com by adutr...@gmail.com on 15 Sep 2009 at 7:06

GoogleCodeExporter commented 8 years ago
Are your classes BasicCrudAction and HomeAction at the default package?

Original comment by jyoshiriro on 17 Sep 2009 at 2:06

GoogleCodeExporter commented 8 years ago
No, only config files in the default package.

Original comment by adutr...@gmail.com on 21 Sep 2009 at 3:46

GoogleCodeExporter commented 8 years ago
How is your folders three?

Original comment by jyoshiriro on 21 Sep 2009 at 5:08

GoogleCodeExporter commented 8 years ago
"tree", sorry ^^'

Original comment by jyoshiriro on 21 Sep 2009 at 5:09

GoogleCodeExporter commented 8 years ago
/hibernate.cfg.xml
/struts.xml
/br/gov/trems/util/BasicCrudAction.class
/br/gov/trems/sistema/controller/action/IndexAction.class

IndexAction extends BasicCrudAction wich extends AcctionSupport
The annotation is being used in the BasicCrudAction wich is not an abstract 
class

Original comment by adutr...@gmail.com on 22 Sep 2009 at 4:51

GoogleCodeExporter commented 8 years ago
Sorry, BasicCrudAction is an abstract class :-)

Original comment by adutr...@gmail.com on 22 Sep 2009 at 4:52

GoogleCodeExporter commented 8 years ago
What package is the *LoginAware* interface in? 

Original comment by jyoshiriro on 22 Sep 2009 at 8:19

GoogleCodeExporter commented 8 years ago
The package for LoginAware interface is /br/gov/trems/util/

Original comment by adutr...@gmail.com on 23 Sep 2009 at 5:08

GoogleCodeExporter commented 8 years ago
Please, replace temporarily your struts2-fullhibernatecore-plugin-1.5-GA.jar  
by the
file attached and test it. So, feedback me about the result, ok?

Original comment by jyoshiriro on 23 Sep 2009 at 7:25

Attachments:

GoogleCodeExporter commented 8 years ago
Hi jyoshiriro,  

The problem persists :/

Error message:
java.lang.StackOverflowError
    java.util.HashMap.get(HashMap.java:300)
    java.lang.ClassLoader.getPackage(ClassLoader.java:1442)
    java.lang.Package.getPackage(Package.java:311)
    java.lang.Class.getPackage(Class.java:698)
    com.googlecode.s2hibernate.struts2.plugin.interceptors.SessionTransactionInje
ctorInterceptor.isCandidadeClass(SessionTransactionInjectorInterceptor.java:347)

Original comment by adutr...@gmail.com on 29 Sep 2009 at 5:40

GoogleCodeExporter commented 8 years ago
Could you attach here your source code (all classes) here? You can delete the
business methods of the attached version, if you prefer.

Original comment by jyoshiriro on 29 Sep 2009 at 11:44

GoogleCodeExporter commented 8 years ago
If you prefer, you can only attach or type here your full project tree. The 
last one
was incomplete.

Original comment by jyoshiriro on 30 Sep 2009 at 11:03

GoogleCodeExporter commented 8 years ago

Original comment by jyoshiriro on 29 Oct 2009 at 11:21

GoogleCodeExporter commented 8 years ago
Hello,

Firstly, thanks for your work, the plugin is a helpful piece of code.
I have the same problem as described here, and after some debugging, i found it 
seems
the bug comes with enumerations.
The recursion inside the 2 methods
SessionTransactionInjectorInterceptor.detectAndCloseHibernateCoreSessionByAnnota
tion(Object)
and
SessionTransactionInjectorInterceptor.detectAndCloseHibernateTransactionByAnnota
tion(Object)
never ends as, when campo is an enum constant, the line 'Object subField =
campo.get(targetObject);' sets subField as the constant. Never ending...
So if i replace the 'else' by 'else if(!campo.isEnumConstant())', no more stack
overflow. But i think there may be a more elegant solution.

Best regards,

exovii

Original comment by iiv...@gmail.com on 6 Nov 2009 at 9:43

GoogleCodeExporter commented 8 years ago
Hello, Exovvi. 
Thank you by this tip! Bux fixed in FHP 2.1.
In the version 2.1 the Session/Transaction injection will use a "injection 
cache" for
best performance.

Original comment by jyoshiriro on 6 Nov 2009 at 11:42

GoogleCodeExporter commented 8 years ago

Original comment by jyoshiriro on 6 Nov 2009 at 11:42

GoogleCodeExporter commented 8 years ago
Thanks for the quick fix !
When will you release FHP 2.1 ?

Regards

Original comment by iiv...@gmail.com on 6 Nov 2009 at 12:53

GoogleCodeExporter commented 8 years ago
I hope... Still this month

Original comment by jyoshiriro on 6 Nov 2009 at 3:22

GoogleCodeExporter commented 8 years ago
2.1 GA Released!

Original comment by jyoshiriro on 20 Nov 2009 at 9:53