Foros de discusión

liferay-plugin-package.properties & spring.jar

thumbnail
Alexey Kakunin, modificado hace 14 años.

liferay-plugin-package.properties & spring.jar

Liferay Master Mensajes: 621 Fecha de incorporación: 7/07/08 Mensajes recientes
Hi! I'm developing quite simple (for now) portlet. This portlet used struts as view technology. For current moment it has 1 quite-simple spring-bean implemented some logic I've included this bean-definition into portlet-spring.xml (which one is included in service.properties)

Everything works quite fine - my portlet is deployed well, as well as bean initialized and I can use it.

Now, it need to implement spring-specific interface org.springframework.beans.factory.InitializingBean. And here problems started.
Then I'm trying to deploy my portlet, now, I'm receiving error:

Bean 'scmManager'; nested exception is java.lang.NoClassDefFoundError: org/springframework/beans/factory/InitializingBean
        at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
        at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
        at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)


I have solution what helped - I just placed some basic spring jars into my portlet WEB-INF/lib folder like
  • spring-beans.jar
  • spring-context.jar
  • spring-core.jar


But, then I tried to reuse spring.jar, already existed in Liferay. So, I removed these jars, and added spring.jar into portal-dependency-jars property in liferay-plugin-package.properties:

portal-dependency-jars=\
    commons-beanutils.jar,\
    commons-collections.jar,\
    commons-digester.jar,\
    commons-logging.jar,\
    commons-lang.jar,\
    commons-validator.jar,\
    portals-bridges.jar,\
    spring.jar,\
    struts.jar


I hope, it will help, but, it produced another problem during deployment:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionAdvice' defined in ServletContext resource [/WEB-INF/classes/META-INF/base-spring.xml]: Cannot resolve reference to bean 'liferayTransactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liferayTransactionManager' defined in ServletContext resource [/WEB-INF/classes/META-INF/hibernate-spring.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/HibernateException
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
        at java.security.AccessController.doPrivileged(Native Method)

Wow! Now it did not see hibernate! Ok, no problem, lets add hibernate3.jar:

portal-dependency-jars=\
    commons-beanutils.jar,\
    commons-collections.jar,\
    commons-digester.jar,\
    commons-logging.jar,\
    commons-lang.jar,\
    commons-validator.jar,\
    hibernate3.jar,\
    portals-bridges.jar,\
    spring.jar,\
    struts.jar


And finally I've got most strange error during deployment:

11:06:33,049 ERROR [ConnectionProviderFactory:99] Could not instantiate connection provider
java.lang.ClassCastException: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider cannot be cast to org.hibernate.connection.ConnectionProvider
        at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:96)
        at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:79)
        at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:448)
        at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:89)
        at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2101)

Strange - because I'm using both - spring & hibernate from liferay - and they should (I hope) to be compatible, but error saud about ClassCast Exception.

It is not a big problem for me for now, but later, I may need to use more functionality from spring, hibernate or some other library, already included into Liferay. So, question - how can I reuse these jars? Or I need always include own into my portlet's WEB-INF/lib folder?

Thank you for any advice!
Aleix - -, modificado hace 14 años.

RE: liferay-plugin-package.properties & spring.jar

New Member Mensajes: 19 Fecha de incorporación: 18/05/09 Mensajes recientes
Hi, I have exactly the same problem. Have you found any solution??

Thanks!
thumbnail
Alexey Kakunin, modificado hace 14 años.

RE: liferay-plugin-package.properties & spring.jar

Liferay Master Mensajes: 621 Fecha de incorporación: 7/07/08 Mensajes recientes
Actually no, so, I kept spring's jar in my portlet lib folder and avoided reuse of spring.jar, contained in liferay portal.
In this case it works (at least for my portlet) well

But - I'm currently not using Hibernate... not sure how it will work in case I will want to reuse Hibernate jar from portal libs
Mike Ring, modificado hace 13 años.

RE: liferay-plugin-package.properties & spring.jar

New Member Mensajes: 16 Fecha de incorporación: 18/12/07 Mensajes recientes
I hate to revive this ancient thread, but I'm having this exact same error, and this is the only thread that I can find that addresses the problem. Any thoughts on how to get hibernate to work in this situation?
thumbnail
Alexey Kakunin, modificado hace 13 años.

RE: liferay-plugin-package.properties & spring.jar

Liferay Master Mensajes: 621 Fecha de incorporación: 7/07/08 Mensajes recientes
Right now I have one project developed portlet for Liferay 6. We almost not reusing Liferay insfrastrcuture like Service Builder or Hibernate Session Factory provided by Liferay - only DataSource connection.
So, in our portlet we run own spring WebApplication Context, own hibernate session factory, own transation management and so on and so on.
It works (we reusing liferay's jar via including them into liferay-plugin-package.properties) - but very unstable. For example - due to some strange problem we get PermGen after each redeployment of portlet (increasing of PermSize do not help).

So far it looks like for liferay portlet it is better to strongly follow "Liferay" way - use infrastructure provided by liferay via service builder

==
Alexey Kakunin
EmForge: Liferay Based Project Hosting Service
Mike Ring, modificado hace 13 años.

RE: liferay-plugin-package.properties & spring.jar

New Member Mensajes: 16 Fecha de incorporación: 18/12/07 Mensajes recientes
Thanks for the quick response--we're trying to use the Liferay infrastructure, but we're still getting the above errors. Sadly we're stuck on 5.2.3 for the time being. We'll probably have to just muddle through...
mayur Oswal, modificado hace 6 años.

RE: liferay-plugin-package.properties & spring.jar

New Member Mensajes: 8 Fecha de incorporación: 10/05/17 Mensajes recientes
Did you guys find the solution for this.

I want to update default commons-collections-3.2.1.jar to newer version