« Torna a FrontPage

How to use JUnit to test service in portlets

Introduction

There are lots of articles in the internet to explain how to use JUnit to test our own portlets. However, after reading them, I still had lots of issues to run Unit test case. After trying a lot, it is finally successful. To make everyone can play around with it. I will share all necessary information you need to archieve this. By the way, the Eclipse is the IDE. Any feedback or feedback will be appreciated! :)

Steps

1. Create and build the basic portlets with the service.xml:

<service-builder package-path="com.jack">
    <author>jacksun</author>
    <namespace>jn</namespace>

    <entity name="JunitTable" local-service="true">
        <column name="id_" type="long" primary="true"></column>
        <column name="name" type="String"></column>
        <finder return-type="JunitTable" name="id_name">
            <finder-column name="id_"></finder-column>
            <finder-column name="name"></finder-column>
        </finder>
    </entity>
</service-builder>

2. To seperate testing code and source code, you can create another source folder, called testing for example. In this folder, create your own test case java class, here we call JunitTableLocalServiceImplTest:

package com.jack.service;

import java.util.List;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.liferay.portal.kernel.test.TestCase;
import com.liferay.portal.model.User;
import com.liferay.portal.service.UserLocalService;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portal.util.InitUtil;

public class JunitTableLocalServiceImplTest extends TestCase {
    
    private JunitTableLocalService jts;
    private UserLocalService userService;
    
    @Before
    protected void setUp() {
        try{
            System.out.println(">>>SET UP");
            //init the application context and beans for Spring.
            InitUtil.initWithSpring();
            //Get the service for testing
            jts = JunitTableLocalServiceUtil.getService();
            //Test LR services
            userService = UserLocalServiceUtil.getService();
            super.setUp();
        }catch(Exception ex){
            ex.printStackTrace();
            fail("Init failed...");
        }
    }

    @After
    protected void tearDown() throws Exception {
        System.out.println(">>>TEAR DOWN");
        jts = null;
        userService = null;
        super.tearDown();
    }
    
    @Test
    public void testFindById(){
        long id = 1001l;
        try {
            //Test own portlets
            String userName = jts.getJunitTable(id).getName();
            System.out.println(">>>>>my own username: " + userName);
            assertEquals("jack", userName);
            
            //Reading LR objects
            List<User> users = userService.getUsers(-1, -1);
            System.out.println("Number of User:"+ users.size());

            for(User user : users){
                System.out.println("User: " + user.getFullName());
            }
            
        } catch (Exception e) {
            e.printStackTrace();
            fail("Junit Find By Id failed --- ID: " + id);
        }
    }
}

3. To make sure the needed class can be found - InitUtil, you need to include the LR library into your project. The path should be: tomcat_home/webapps/ROOT/WEB-INF/lib.

4. You need to create another java class to replace the PortletHibernateConfiguration, here we call it PortletHibernateTestConfiguration and put into some package, here we put into com.jack.service.persistence package:

package com.jack.service.persistence;

import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.spring.hibernate.PortletHibernateConfiguration;

public class PortletHibernateTestConfiguration extends
        PortletHibernateConfiguration {

     protected ClassLoader getConfigurationClassLoader() {
         System.out.println(">>>>jack configuration hibernate");
          return this.getClass().getClassLoader();
         }
    
     protected String[] getConfigurationResources() {
         String[] configs = PropsUtil.getArray(PropsKeys.HIBERNATE_CONFIGS);
         for(String config : configs){
         System.out.println(config);
         }
         return configs;
         }
}

5. Write one portal-ext.properties file and put it into src folder path. e.g. docroot/WEB-INF/src/, especially the "META-INF/portlet-hbm.xml" in the file, if you didn't have it, it will throw exception tell you your hibernate entity cannot be found! Double check the following attributes and make your adjustment.

jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost/lfportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=root
jdbc.default.password=123

hibernate.cache.use_query_cache=false
hibernate.cache.use_second_level_cache=false
hibernate.cache.use_minimal_puts=false
hibernate.cache.use_structured_entries=false

# Disable the scheduler for Unit testing
ehcache.portal.cache.manager.jmx.enabled=false

value.object.listener.com.liferay.portal.model.LayoutSet=

resource.repositories.root=C:/LR/liferay-portal-6.0.6/tomcat-6.0.29/webapps/ROOT

# Disable the scheduler for Unit testing
scheduler.enabled=false

hibernate.configs=\
META-INF/mail-hbm.xml,\
META-INF/portal-hbm.xml,\
META-INF/ext-hbm.xml,\
META-INF/portlet-hbm.xml

6. Write your own Spring config file and modify some auto-created spring files. Our own spring file should be named as ext-spring.xml and the three xml files I changed are: hibernate-spring.xml, infrastructure-spring.xml and portlet-spring.xml. However, I think even not modify those three files, it should also work.

And these files need to be put into META-INF folder under your src folder. Double check the following attributes and make your adjustment.
 

ext-spring.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans default-destroy-method="destroy" default-init-method="afterPropertiesSet"
    xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
    <bean
        class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy"
        id="liferayDataSource">
        <property name="targetDataSource">
            <bean class="com.liferay.portal.dao.jdbc.util.DataSourceFactoryBean">
                <property name="propertyPrefix" value="jdbc.default.">
                </property>
            </bean>
        </property>
    </bean>
    
    <bean id="basePersistence" abstract="true">
        <property name="dataSource" ref="liferayDataSource" />
        <property name="sessionFactory" ref="liferaySessionFactory" />
    </bean>

    <bean id="com.jack.service.JunitTableLocalService" class="com.jack.service.impl.JunitTableLocalServiceImpl" >
    </bean>
    <bean id="com.jack.service.JunitTableLocalServiceUtil" class="com.jack.service.JunitTableLocalServiceUtil">
        <property name="service" ref="com.jack.service.JunitTableLocalService" />
    </bean>
    <bean id="com.jack.service.JunitTableService" class="com.jack.service.impl.JunitTableServiceImpl">
    </bean>
    <bean id="com.jack.service.JunitTableServiceUtil" class="com.jack.service.JunitTableServiceUtil">
        <property name="service" ref="com.jack.service.JunitTableService" />
    </bean>
    <bean id="com.jack.service.persistence.JunitTablePersistence" class="com.jack.service.persistence.JunitTablePersistenceImpl" parent="basePersistence" />
    

    <bean class="com.liferay.portal.spring.transaction.TransactionManagerFactory"
        factory-method="createTransactionManager" id="liferayTransactionManager">
        <constructor-arg ref="liferayHibernateSessionFactory">
        </constructor-arg>
        <constructor-arg ref="liferayDataSource">
        </constructor-arg>
    </bean>
    <bean class="com.jack.service.persistence.PortletHibernateTestConfiguration"
        id="liferayHibernateSessionFactory">
        <property name="dataSource" ref="liferayDataSource">
        </property>
    </bean>
    <bean class="com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil"
        id="com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil">
        <property name="dynamicQueryFactory">
            <bean class="com.liferay.portal.dao.orm.hibernate.DynamicQueryFactoryImpl">
            </bean>
        </property>
    </bean>
    <bean class="com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil"
        id="com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil">
        <property name="restrictionsFactory">
            <bean class="com.liferay.portal.dao.orm.hibernate.RestrictionsFactoryImpl">
            </bean>
        </property>
    </bean>
    <bean class="com.liferay.portal.kernel.util.InfrastructureUtil"
        id="com.liferay.portal.kernel.util.InfrastructureUtil">
        <property name="dataSource" ref="liferayDataSource">
        </property>
        <property name="transactionManager" ref="liferayTransactionManager">
        </property>
    </bean>
</beans>

hibernate-spring.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans
    default-destroy-method="destroy"
    default-init-method="afterPropertiesSet"
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
>
    <bean id="liferayHibernateSessionFactory" class="com.jack.service.persistence.PortletHibernateTestConfiguration">
        <property name="dataSource" ref="liferayDataSource" />
    </bean>
    <bean id="liferaySessionFactory" class="com.liferay.portal.dao.orm.hibernate.SessionFactoryImpl">
        <property name="sessionFactoryClassLoader" ref="portletClassLoader" />
        <property name="sessionFactoryImplementor" ref="liferayHibernateSessionFactory" />
    </bean>
     <bean
    class="com.liferay.portal.spring.transaction.TransactionManagerFactory" factory-method="createTransactionManager" id="liferayTransactionManager">
    <constructor-arg ref="liferayDataSource">
     </constructor-arg>
     <constructor-arg ref="liferayHibernateSessionFactory">
    </constructor-arg>
   </bean>
</beans>

infrastructure-spring.xml:

<?xml version="1.0" encoding="UTF-8"?>

<beans
    default-destroy-method="destroy"
    default-init-method="afterPropertiesSet"
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
>
    <bean class="com.liferay.portal.kernel.util.InfrastructureUtil" id="com.liferay.portal.kernel.util.InfrastructureUtil">
    <property name="dataSource" ref="liferayDataSource">
    </property>
    <property name="transactionManager" ref="liferayTransactionManager">
    </property>
   </bean>
   
    <bean class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy" id="liferayDataSource">
        <property name="targetDataSource">
            <bean class="com.liferay.portal.dao.jdbc.util.DataSourceFactoryBean">
                <property name="propertyPrefix" value="jdbc.default.">
                </property>
            </bean>
        </property>
    </bean>   
</beans>

portlet-spring.xml:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" default-destroy-method="destroy" default-init-method="afterPropertiesSet" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
    <bean id="com.jack.service.JunitTableLocalService" class="com.jack.service.impl.JunitTableLocalServiceImpl" >
    </bean>
    <bean id="com.jack.service.JunitTableLocalServiceUtil" class="com.jack.service.JunitTableLocalServiceUtil">
        <property name="service" ref="com.jack.service.JunitTableLocalService" />
    </bean>
    <bean id="com.jack.service.JunitTableService" class="com.jack.service.impl.JunitTableServiceImpl">
    </bean>
    <bean id="com.jack.service.JunitTableServiceUtil" class="com.jack.service.JunitTableServiceUtil">
        <property name="service" ref="com.jack.service.JunitTableService" />
    </bean>
    <bean id="com.jack.service.persistence.JunitTablePersistence" class="com.jack.service.persistence.JunitTablePersistenceImpl" parent="basePersistence" />
    
    <bean class="com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil" id="com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil">
    <property name="dynamicQueryFactory">
        <bean class="com.liferay.portal.dao.orm.hibernate.DynamicQueryFactoryImpl">
        </bean>
    </property>
   </bean>
   
   <bean class="com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil" id="com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil">
    <property name="restrictionsFactory">
        <bean class="com.liferay.portal.dao.orm.hibernate.RestrictionsFactoryImpl">
        </bean>
    </property>
   </bean>
</beans>

7. Now, you can run your test case in your IDE. If you met the error: PermGen space(OOM exception), you could run your test case as configuration and in the argument(VM) field input:

-server -Xms800m -Xmx800m  -XX:PermSize=64M -XX:MaxNewSize=256m -XX:MaxPermSize=128m -Djava.awt.headless=true

1 Allegato
27726 Visualizzazioni
Media (2 Voti)
La media del punteggio è 5.0 stelle su 5.
Commenti
Commenti Autore Data
Hi All, I've been waiting for such an article... Ivo Neskovic 1 marzo 2012 8.31
Allright, managed to overcome the error... Ivo Neskovic 1 marzo 2012 14.58
How can i run test if i am not using Spring in... Gautam Sharma 24 maggio 2012 2.33
Can you please share the complete code of the... Hari Dhanakoti 31 luglio 2012 23.32
Hi, 1) In JUnit Example which is mentioned... Althaf Hussain Shaik 13 dicembre 2012 5.12
I got the same output (Using dialect null ) ,... Kailas Lokhande 3 gennaio 2013 21.25
is it mandatory to change generated Spring... Kailas Lokhande 3 gennaio 2013 21.28
I managed to solve this problem . In... Kailas Lokhande 3 gennaio 2013 21.40
I am following this post for JUNIT , but I got ... Kailas Lokhande 8 gennaio 2013 6.47
I have the same error in liferay 6.2. The only... Charalampos Chrysikopoulos 27 giugno 2014 7.13
I am following your post on JUnit but i am... Nithin KV 17 gennaio 2013 7.11
Anyone has a working example to share? I have... Huage Chen 12 giugno 2013 5.17
It is working fine for me.But when i try ... pankaj kumar 11 agosto 2014 3.05

Hi All,

I've been waiting for such an article for a veryyyy long time. I got a bit further with your instructions than with my tries but I am unable to run the tests!

I am getting an exception: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/aop]

Question 1) Do you have any idea how to solve it?
Question 2) Can you provide your sample project as a downloadable to this wiki entry so I can compare my code?

Best,
I
Inviato il 01/03/12 8.31.
Allright, managed to overcome the error (missing dependencies, there were ALOT) but now I encounter the PermGen space errror, even after adding the above line to my MAVEN_OPTS env. variable.

Help?

emoticon
Inviato il 01/03/12 14.58 in risposta a Ivo Neskovic.
How can i run test if i am not using Spring in my project
Inviato il 24/05/12 2.33 in risposta a Ivo Neskovic.
Can you please share the complete code of the junit test and its configuraiton. Here in the example mentioned here has no class definition "JunitTablePersistenceImpl"
Inviato il 31/07/12 23.32 in risposta a Gautam Sharma.
Hi,

1) In JUnit Example which is mentioned above has one attachment of snap shot of package structure for referrence but in that structure MyActiion.Java is mentioned but in this example it is missing, please provide me that class.

2) I have tried this above example but when i run the JUnit Test it is throwing lot of exceptions, the first paragraph of exception is as follows:
Loading jar:file:/D:/ProjectLR/plugins-sdk/portlets/TestJunit-portlet/docroot/WEB-INF/li­b/portal-impl.jar!/portal.properties
Loading file:/D:/ProjectLR/plugins-sdk/portlets/TestJunit-portlet/docroot/WEB-INF/classe­s/portal-ext.properties
>>>> configuration hibernate
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/ProjectLR/plugins-sdk/portlets/TestJunit-portlet/docroot/WEB-INF/l­ib/slf4j-log4j12-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/ProjectLR/plugins-sdk/portlets/TestJunit-portlet/docroot/WEB-INF/l­ib/slf4j-simple-1.6.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/ProjectLR/plugins-sdk/portlets/TestJunit-portlet/docroot/WEB-INF/l­ib/util-java.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/ProjectLR/server/tomcat-7.0.27/webapps/ROOT/WEB-INF/lib/util-java.­jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
META-INF/mail-hbm.xml
META-INF/portal-hbm.xml
META-INF/ext-hbm.xml
META­-INF/portlet-hbm.xml
>>>> configuration hibernate
>>>> configuration hibernate
>>>> configuration hibernate
>>>> configuration hibernate
12:49:38,565 INFO [DialectDetector:71] Determine dialect for MySQL 5
12:49:38,588 INFO [DialectDetector:136] Found dialect org.hibernate.dialect.MySQLDialect
12:49:38,589 INFO [DBFactoryImpl:56] Using dialect null
12:49:38,591 ERROR [DBFactoryImpl:65] java.lang.NullPointerException
java.lang.NullPointerException
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at com.liferay.portal.kernel.util.InstanceFactory.newInstance(InstanceFactory.java:­52)
at com.liferay.portal.kernel.util.InstanceFactory.newInstance(InstanceFactory.java:­27)
at com.liferay.portal.kernel.util.InstanceFactory.newInstance(InstanceFactory.java:­68)
at com.liferay.portal.dao.db.DBFactoryImpl.getDB(DBFactoryImpl.java:59)
at com.liferay.portal.kernel.dao.db.DBFactoryUtil.getDB(DBFactoryUtil.java:25)
at com.liferay.portal.spring.hibernate.PortalHibernateConfiguration.newConfiguratio­n(PortalHibernateConfiguration.java:125)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(L­ocalSessionFactoryBean.java:549)
at com.liferay.portal.spring.hibernate.PortalHibernateConfiguration.buildSessionFac­tory(PortalHibernateConfiguration.java:65)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet­(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.inv­okeInitMethods(AbstractAutowireCapableBeanFactory.java:1479)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.ini­tializeBean(AbstractAutowireCapableBeanFactory.java:1419)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doC­reateBean(AbstractAutowireCapableBeanFactory.java:518)

Hope you are getting my questions...
Regards,
Althaf Hussain.
Inviato il 13/12/12 5.12.
I got the same output (Using dialect null ) , anybody got any solution for this issue?

I am using Liferay 6.1 CE... Please Help
Inviato il 03/01/13 21.25 in risposta a Althaf Hussain.
is it mandatory to change generated Spring files? (portlet-spring.xml,hibernate-spring.xml,infrastructure-spring.xml) . Will it work without modifing these files and just adding extra file i.e. ext-spring.xml?
Inviato il 03/01/13 21.28.
I managed to solve this problem .

In PortletHibernateTestConfiguration class we should extend it by
PortalHibernateConfiguration class.

If we use PortletHibernateConfiguration class it wont set DB with any dialect, because its setDB method does not do anything.

Correct me if I am wrong anywhere
Inviato il 03/01/13 21.40 in risposta a Kailas Lokhande.
I am following this post for JUNIT , but I got exception :

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.liferay.portal.kernel.spring.util.SpringFactoryUtil#0' defined in class path resource [META-INF/base-spring.xml]: Cannot resolve reference to bean 'serviceAdvice' while setting constructor argument with key [TypedStringValue: value [methodInterceptor], target type ]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceAdvice' defined in class path resource [META-INF/base-spring.xml]: Cannot resolve reference to bean 'serviceMonitorAdvice' while setting constructor argument with key [TypedStringValue: value [nextMethodInterceptor], target type ]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceMonitorAdvice' defined in class path resource [META-INF/base-spring.xml]: Cannot resolve reference to bean 'asyncAdvice' while setting constructor argument with key [TypedStringValue: value [nextMethodInterceptor], target type ]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'asyncAdvice' defined in class path resource [META-INF/base-spring.xml]: Cannot resolve reference to bean 'threadLocalCacheAdvice' while setting constructor argument with key [TypedStringValue: value [nextMethodInterceptor], target type ]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'threadLocalCacheAdvice' defined in class path resource [META-INF/base-spring.xml]: Cannot resolve reference to bean 'bufferedIncrementAdvice' while setting constructor argument with key [TypedStringValue: value [nextMethodInterceptor], target type ]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bufferedIncrementAdvice' defined in class path resource [META-INF/base-spring.xml]: Cannot resolve reference to bean 'indexableAdvice' while setting constructor argument with key [TypedStringValue: value [nextMethodInterceptor], target type ]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'indexableAdvice' defined in class path resource [META-INF/base-spring.xml]: Cannot resolve reference to bean 'transactionAdvice' while setting constructor argument with key [TypedStringValue: value [nextMethodInterceptor], target type ]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionAdvice' defined in class path resource [META-INF/base-spring.xml]: Cannot resolve reference to bean 'transactionAttributeSource' while setting constructor argument with key [TypedStringValue: value [transactionAttributeSource], target type ]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionAttributeSource' defined in class path resource [META-INF/base-spring.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public static java.lang.Object com.liferay.portal.kernel.spring.util.SpringFactoryUtil.newBean(java.lang.String­) throws com.liferay.portal.kernel.spring.util.SpringFactoryException] threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveRef­erence(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveVal­ueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveMan­agedMap(BeanDefinitionValueResolver.java:378)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveVal­ueIfNecessary(BeanDefinitionValueResolver.java:161)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructor­Arguments(ConstructorResolver.java:630)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFa­ctoryMethod(ConstructorResolver.java:441)


any idea??
Inviato il 08/01/13 6.47 in risposta a Kailas Lokhande.
I am following your post on JUnit but i am getting the below error.Kindly help me if you are aware of it...

java.lang.NoSuchMethodError: com.liferay.portal.kernel.util.PropsUtil.setProps(Lcom/liferay/portal/kernel/uti­l/Props;)V
at com.liferay.portal.util.InitUtil.init(InitUtil.java:90)
at com.liferay.portal.util.InitUtil.initWithSpring(InitUtil.java:170)
at com.liferay.portal.util.InitUtil.initWithSpring(InitUtil.java:145)
at test.com.elm.service.TestPuneetLocalUtil.setUp(TestPuneetLocalUtil.java:14)
at junit.framework.TestCase.runBare(TestCase.java:132)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at­ org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReferen­ce.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
a­t org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner­.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner­.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java­:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.jav­a:197)
Inviato il 17/01/13 7.11.
Anyone has a working example to share? I have the same trouble in integrating it to my project.
Inviato il 12/06/13 5.17 in risposta a Nithin KV.
I have the same error in liferay 6.2. The only think I have done is to generate an entity with service builder and initialise spring with InitUtil.initWithSpring(). Running the test generates the above error as described by Kailas.
Inviato il 27/06/14 7.13 in risposta a Kailas Lokhande.
It is working fine for me.But when i try

JournalArticleLocalServiceUtil.search(companyID,groupID,0,"",template.getTemplat­eId(),"",journalParams,-1,-1,sort));

I am getting below warning
WARN [IndexerRegistryImpl:50] No indexer found for com.liferay.portlet.journal.model.JournalArticle

Any idea how to overcome on this.
Inviato il 11/08/14 3.05.