Recently I worked on
switching from Liferay Ant based SDK to Maven based development environment
project structure. Well, everything was working. However, while building
services using Liferay IDE or Maven command (liferay: build-service), it was
failing with a weird error!
After exploring a
lot, finally, I got some hints from stackoverflow
which states that someone faced similar issue with Ant SDK based Liferay and
fix it by replacing corrupted SDK. Well, I had Maven environment. So I spent my
few hours to do complete setup again by doing fresh download of Liferay IDE,
Liferay Portal and Liferay Maven Plugins. After putting all efforts, I got the
same error at the end. Ahhh, spending time on environment issues is really
frustrating. With few trials, finally I could fix it just by deleting maven
local repository on my machine.
Problem Statement:
The
liferay:build-service with maven fails due to BeanCreationException
[ERROR] Failed to execute goal
com.liferay.maven.plugins:liferay-maven-plugin:6.2.10.13:build-service
(default-cli) on project xyz-portlet: null: MojoExecutionException:
InvocationTargetException: Error creating bean with name
'com.liferay.portal.kernel.language.LanguageUtil' defined in class path
resource [META-INF/util-spring.xml]: Cannot create inner bean
'com.liferay.portal.language.LanguageImpl#7bbd7f69' of type
[com.liferay.portal.language.LanguageImpl] while setting bean property
'language'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'com.liferay.portal.language.LanguageImpl#7bbd7f69' defined in class
path resource [META-INF/util-spring.xml]: Invocation of init method failed;
nested exception is java.lang.NoClassDefFoundError:
javax/servlet/jsp/PageContext: javax.servlet.jsp.PageContext -> [Help 1]
Solution:
I just deleted maven
local repository on my machine (in case of windows, by default, it is this
folder - C:\Users\<username>\.m2\repository). Then, I executed "mvn
clean install" command on a parent module of project, which downloaded all
required dependencies again. Finally, I could run
"liferay:build-service".
Wow, this fixed the
issue. Still I am not sure, which particular dependency in my local maven
repository was corrupted and causing the mentioned problem while using liferay
service builder!!!
Full Error Stack Detail:
>mvn liferay:build-service
[INFO]
Scanning for projects...
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO]
Building XYZ Portlets 1.0-SNAPSHOT
[INFO]
------------------------------------------------------------------------
[INFO]
[INFO]
--- liferay-maven-plugin:6.2.10.13:build-service (default-cli) @ xyz-portlet
---
[INFO]
Building from E:\Projects\xyz-portlet/src/main/webapp/WEB-INF/service.xml
Loading
jar:file:/C:/Users/tirthalp/Downloads/liferay-portal-6.2-ee-sp13/tomcat-7.0.62/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/system.properties
Jan
05, 2016 11:49:42 AM com.liferay.portal.kernel.log.Jdk14LogImpl info
INFO:
Global shared lib directory
/C:/Users/tirthalp/.m2/repository/javax/servlet/servlet-api/2.5/
Jan
05, 2016 11:49:42 AM com.liferay.portal.kernel.log.Jdk14LogImpl info
INFO:
Global lib directory
/C:/Users/tirthalp/Downloads/liferay-portal-6.2-ee-sp13/tomcat-7.0.62/lib/ext/
Jan
05, 2016 11:49:42 AM com.liferay.portal.kernel.log.Jdk14LogImpl info
INFO:
Portal lib directory
/C:/Users/tirthalp/Downloads/liferay-portal-6.2-ee-sp13/tomcat-7.0.62/webapps/ROOT/WEB-INF/lib/
Jan
05, 2016 11:49:43 AM com.liferay.portal.kernel.log.Jdk14LogImpl info
INFO:
Properties for portal loaded from
[jar:file:/C:/Users/tirthalp/Downloads/liferay-portal-6.2-ee-sp13/tomcat-7.0.62/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/com/liferay/portal/tools/dependencies/portal-tools.properties,
jar:file:/C:/Users/tirthalp/Downloads/liferay-portal-6.2-ee-sp13/tomcat-7.0.62/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/portal-patched.properties,
jar:file:/C:/Users/tirthalp/Downloads/liferay-portal-6.2-ee-sp13/tomcat-7.0.62/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/portal.properties]
Loading
jar:file:/C:/Users/tirthalp/Downloads/liferay-portal-6.2-ee-sp13/tomcat-7.0.62/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/portal.properties
Loading
jar:file:/C:/Users/tirthalp/Downloads/liferay-portal-6.2-ee-sp13/tomcat-7.0.62/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/portal-patched.properties
Loading
jar:file:/C:/Users/tirthalp/Downloads/liferay-portal-6.2-ee-sp13/tomcat-7.0.62/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/com/liferay/portal/tools/dependencies/portal-tools.properties
[INFO]
------------------------------------------------------------------------
[INFO]
BUILD FAILURE
[INFO]
------------------------------------------------------------------------
[INFO]
Total time: 10.798 s
[INFO]
Finished at: 2016-01-05T11:49:51+05:30
[INFO]
Final Memory: 24M/241M
[INFO]
------------------------------------------------------------------------
[ERROR] Failed to execute goal
com.liferay.maven.plugins:liferay-maven-plugin:6.2.10.13:build-service
(default-cli) on project xyz-portlet: null: MojoExecutionException:
InvocationTargetException: Error creating bean with name
'com.liferay.portal.kernel.language.LanguageUtil' defined in class path
resource [META-INF/util-spring.xml]: Cannot create inner bean
'com.liferay.portal.language.LanguageImpl#7bbd7f69' of type
[com.liferay.portal.language.LanguageImpl] while setting bean property
'language'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'com.liferay.portal.language.LanguageImpl#7bbd7f69' defined in class
path resource [META-INF/util-spring.xml]: Invocation of init method failed;
nested exception is java.lang.NoClassDefFoundError:
javax/servlet/jsp/PageContext: javax.servlet.jsp.PageContext -> [Help 1]
------------------------
Detailed Stack Trace:
------------------------
org.apache.maven.lifecycle.LifecycleExecutionException:
Failed to execute goal
com.liferay.maven.plugins:liferay-maven-plugin:6.2.10.13:build-service
(default-cli) on project xyz-portlet: null
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at
org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at
org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at
org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at
org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at
org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at
org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
at
org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at
org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at
java.lang.reflect.Method.invoke(Method.java:601)
at
org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at
org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at
org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at
org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused
by: org.apache.maven.plugin.MojoExecutionException
at
com.liferay.maven.plugins.AbstractLiferayMojo.execute(AbstractLiferayMojo.java:88)
at
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
Caused
by: java.lang.reflect.InvocationTargetException
at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at
java.lang.reflect.Method.invoke(Method.java:601)
at
com.liferay.maven.plugins.AbstractLiferayMojo.executeTool(AbstractLiferayMojo.java:224)
at
com.liferay.maven.plugins.ServiceBuilderMojo.doExecute(ServiceBuilderMojo.java:167)
at
com.liferay.maven.plugins.AbstractLiferayMojo.execute(AbstractLiferayMojo.java:81)
... 22 more
Caused
by: org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'com.liferay.portal.kernel.language.LanguageUtil' defined in
class path resource [META-INF/util-spring.xml]: Cannot create inner bean
'com.liferay.portal.language.LanguageImpl#53d6cbe8' of type
[com.liferay.portal.language.LanguageImpl] while setting bean property
'language'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'com.liferay.portal.language.LanguageImpl#53d6cbe8' defined in class
path resource [META-INF/util-spring.xml]: Invocation of init method failed;
nested exception is java.lang.NoClassDefFoundError:
javax/servlet/jsp/PageContext
at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281)
at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:120)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1327)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1085)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:516)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
at
com.liferay.portal.spring.context.ArrayApplicationContext.<init>(ArrayApplicationContext.java:31)
at
com.liferay.portal.spring.util.SpringUtil._loadContext(SpringUtil.java:74)
at
com.liferay.portal.spring.util.SpringUtil.loadContext(SpringUtil.java:60)
at
com.liferay.portal.util.InitUtil.initWithSpring(InitUtil.java:189)
at
com.liferay.portal.util.InitUtil.initWithSpring(InitUtil.java:166)
at
com.liferay.portal.tools.servicebuilder.ServiceBuilder.main(ServiceBuilder.java:199)
... 29 more
Caused
by: org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'com.liferay.portal.language.LanguageImpl#53d6cbe8' defined in
class path resource [META-INF/util-spring.xml]: Invocation of init method
failed; nested exception is java.lang.NoClassDefFoundError:
javax/servlet/jsp/PageContext
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1422)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:518)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270)
... 49 more
Caused
by: java.lang.NoClassDefFoundError: javax/servlet/jsp/PageContext
at
java.lang.Class.getDeclaredMethods0(Native Method)
at
java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
at
java.lang.Class.getMethod0(Class.java:2685)
at
java.lang.Class.getMethod(Class.java:1620)
at
org.springframework.beans.BeanUtils.findMethod(BeanUtils.java:162)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1502)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1487)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1419)
... 52 more
Caused
by: java.lang.ClassNotFoundException: javax.servlet.jsp.PageContext
at
java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at
java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at
java.security.AccessController.doPrivileged(Native Method)
at
java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at
java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at
java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 60 more