Foros de discusión

[ServiceBuilder] Context initialization failed. Error creating bean

G Jerom, modificado hace 11 años.

[ServiceBuilder] Context initialization failed. Error creating bean

New Member Mensajes: 8 Fecha de incorporación: 27/06/12 Mensajes recientes
Hi Everyone,

I’m working with liferay 6.0.6 and Service Builder. I create entity AppelFine.
As soon as I am deploying my war made by eclipse in liferay I get the following error:


		09:31:48,880 ERROR [ContextLoader:220] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.perso.payyourfine.service.AppealFineLocalService' defined in ServletContext resource [/WEB-INF/classes/META-INF/portlet-spring.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.perso.payyourfine.service.persistence.AppealFinePersistence' defined in ServletContext resource [/WEB-INF/classes/META-INF/portlet-spring.xml]: Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
	at com.liferay.portal.spring.context.PortletContextLoaderListener.contextInitialized(PortletContextLoaderListener.java:71)
	at com.liferay.portal.kernel.servlet.PortalClassLoaderServletContextListener.doPortalInit(PortalClassLoaderServletContextListener.java:91)
	at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePortalLifecycle.java:42)
	at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:52)
	at com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLifecycle(BasePortalLifecycle.java:50)
	at com.liferay.portal.kernel.servlet.PortalClassLoaderServletContextListener.contextInitialized(PortalClassLoaderServletContextListener.java:52)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4205)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4704)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)
	at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)
	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1315)
	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
	at org.apache.catalina.core.StandardService.start(StandardService.java:525)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.perso.payyourfine.service.persistence.AppealFinePersistence' defined in ServletContext resource [/WEB-INF/classes/META-INF/portlet-spring.xml]: Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
	at com.liferay.portal.spring.annotation.BeanReferenceAnnotationBeanPostProcessor._autoInject(BeanReferenceAnnotationBeanPostProcessor.java:106)
	at com.liferay.portal.spring.annotation.BeanReferenceAnnotationBeanPostProcessor._autoInject(BeanReferenceAnnotationBeanPostProcessor.java:148)
	at com.liferay.portal.spring.annotation.BeanReferenceAnnotationBeanPostProcessor.postProcessBeforeInitialization(BeanReferenceAnnotationBeanPostProcessor.java:57)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1413)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	... 41 more
Caused by: java.lang.ExceptionInInitializerError
	at com.perso.payyourfine.model.impl.AppealFineModelImpl.<clinit>(AppealFineModelImpl.java:77)
	at com.perso.payyourfine.service.persistence.AppealFinePersistenceImpl.<clinit>(AppealFinePersistenceImpl.java:72)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:74)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958)
	... 54 more
Caused by: java.lang.NullPointerException
	at com.liferay.portal.configuration.ConfigurationImpl.getFileName(ConfigurationImpl.java:336)
	at com.liferay.portal.configuration.ConfigurationImpl.<init>(ConfigurationImpl.java:121)
	at com.liferay.portal.configuration.ConfigurationImpl.<init>(ConfigurationImpl.java:61)
	at com.liferay.portal.configuration.ConfigurationFactoryImpl.getConfiguration(ConfigurationFactoryImpl.java:28)
	at com.liferay.portal.kernel.configuration.ConfigurationFactoryUtil.getConfiguration(ConfigurationFactoryUtil.java:25)
	at com.liferay.util.service.ServiceProps.<init>(ServiceProps.java:65)
	at com.liferay.util.service.ServiceProps.<clinit>(ServiceProps.java:69)
	... 63 more

</clinit></init></init></init></clinit></clinit>


Here is my file porlet-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.perso.payyourfine.service.AppealFineLocalService" class="com.perso.payyourfine.service.impl.AppealFineLocalServiceImpl" />
	<bean id="com.perso.payyourfine.service.AppealFineLocalServiceUtil" class="com.perso.payyourfine.service.AppealFineLocalServiceUtil">
		<property name="service" ref="com.perso.payyourfine.service.AppealFineLocalService" />
	</bean>
	<bean id="com.perso.payyourfine.service.persistence.AppealFinePersistence" class="com.perso.payyourfine.service.persistence.AppealFinePersistenceImpl" parent="basePersistence" />
</beans>



In this thread they suggest to add service.properties file into WEB-INF/classes but it’s already done.
LiferayForum

Here is my file service.properties

##
## Properties Override
##

    #
    # Specify where to get the overridden properties. Updates should not be made
    # on this file but on the overridden version of this file.
    #
    include-and-override=service-ext.properties

##
## Build
##

    build.namespace=Inventory
    build.number=205
    build.date=1340722673179
    build.auto.upgrade=true

##
## Spring
##

    #
    # Input a list of comma delimited Spring configurations. These will be
    # loaded after the bean definitions specified in the
    # portalContextConfigLocation parameter in web.xml.
    #
    spring.configs=\
        WEB-INF/classes/META-INF/base-spring.xml,\
        \
        WEB-INF/classes/META-INF/hibernate-spring.xml,\
        WEB-INF/classes/META-INF/infrastructure-spring.xml,\
        \
        WEB-INF/classes/META-INF/cluster-spring.xml,\
        \
        WEB-INF/classes/META-INF/portlet-spring.xml,\
        \
        WEB-INF/classes/META-INF/dynamic-data-source-spring.xml,\
        WEB-INF/classes/META-INF/shard-data-source-spring.xml,\
        \
        WEB-INF/classes/META-INF/ext-spring.xml
	
		


If you need more informations, just ask.
Can somebody help me for this ?
Thanks
thumbnail
David H Nebinger, modificado hace 11 años.

RE: [ServiceBuilder] Context initialization failed. Error creating bean

Liferay Legend Mensajes: 14914 Fecha de incorporación: 2/09/06 Mensajes recientes
Add a blank "portlet.properties" file in the docroot/WEB-INF/src directory, rebuild and re-deploy.
G Jerom, modificado hace 11 años.

RE: [ServiceBuilder] Context initialization failed. Error creating bean

New Member Mensajes: 8 Fecha de incorporación: 27/06/12 Mensajes recientes
David H Nebinger:
Add a blank "portlet.properties" file in the docroot/WEB-INF/src directory, rebuild and re-deploy.


Hi,

Thanks for your quick help.
I create a black portlet.properties, rebuild with the ServiceBuilder and redeploy with the .war file.
Unfortunately it doesn't work.
If you need more informations, just ask.

Regards
thumbnail
David H Nebinger, modificado hace 11 años.

RE: [ServiceBuilder] Context initialization failed. Error creating bean

Liferay Legend Mensajes: 14914 Fecha de incorporación: 2/09/06 Mensajes recientes
You need to have one in both plugin projects, the plugin hosting the service.xml file and the plugins that are consuming the services provided by that portlet.
G Jerom, modificado hace 11 años.

RE: [ServiceBuilder] Context initialization failed. Error creating bean

New Member Mensajes: 8 Fecha de incorporación: 27/06/12 Mensajes recientes
Thanks for the information.
But i have only one portlet (with one service.xml) inside one lifferay project.
thumbnail
David H Nebinger, modificado hace 11 años.

RE: [ServiceBuilder] Context initialization failed. Error creating bean

Liferay Legend Mensajes: 14914 Fecha de incorporación: 2/09/06 Mensajes recientes
Well I can tell you that the NPE is being thrown in getFileName() where it is looking for "portlet.properties" from the classes folder and, when it doesn't find it, the NPE is thrown.

Can you check your deployed war and see if there is indeed a portlet.properties file in the WEB-INF/classes directory?
G Jerom, modificado hace 11 años.

RE: [ServiceBuilder] Context initialization failed. Error creating bean

New Member Mensajes: 8 Fecha de incorporación: 27/06/12 Mensajes recientes
David H Nebinger:
Well I can tell you that the NPE is being thrown in getFileName() where it is looking for "portlet.properties" from the classes folder and, when it doesn't find it, the NPE is thrown.

Can you check your deployed war and see if there is indeed a portlet.properties file in the WEB-INF/classes directory?


I check my deployed war in the WEB-INF/classes directory :
-rw------- 1 www server 0 Jun 27 15:08 portlet.properties

In the same folder where I can find :
-rw------- 1 www server 1101 Jun 27 15:09 service.properties
thumbnail
David H Nebinger, modificado hace 11 años.

RE: [ServiceBuilder] Context initialization failed. Error creating bean

Liferay Legend Mensajes: 14914 Fecha de incorporación: 2/09/06 Mensajes recientes
Your service is part of a portlet plugin, and not another type of plugin?
G Jerom, modificado hace 11 años.

RE: [ServiceBuilder] Context initialization failed. Error creating bean

New Member Mensajes: 8 Fecha de incorporación: 27/06/12 Mensajes recientes
David H Nebinger:
Your service is part of a portlet plugin, and not another type of plugin?

Yes. I create a liferay project, then a liferay portelet and finally a service builder for my liferay project. I write some code to create a form for my entity. That's all.
thumbnail
David H Nebinger, modificado hace 11 años.

RE: [ServiceBuilder] Context initialization failed. Error creating bean

Liferay Legend Mensajes: 14914 Fecha de incorporación: 2/09/06 Mensajes recientes
Okay, my bad. Plugins using the service (other portlets) need the portlet.properties.

Your portlet is going to be looking for the service.properties file which it is not finding.

Seeing that a previous post is showing unix file permissions, they are only readable by the owner. I'm guessing that the owner of the file and user that you use to start your app server are probably two different users.

Try changing the permissions on service.properties to 644 and see if that fixes the issue...
G Jerom, modificado hace 11 años.

RE: [ServiceBuilder] Context initialization failed. Error creating bean

New Member Mensajes: 8 Fecha de incorporación: 27/06/12 Mensajes recientes
David H Nebinger:
Okay, my bad. Plugins using the service (other portlets) need the portlet.properties.

Your portlet is going to be looking for the service.properties file which it is not finding.

Seeing that a previous post is showing unix file permissions, they are only readable by the owner. I'm guessing that the owner of the file and user that you use to start your app server are probably two different users.

Try changing the permissions on service.properties to 644 and see if that fixes the issue...


I give the 777 permissions for service.properties for the two different locations : WEB-INF/classes & WEB-INF/src but it doesn't work.

Inside service.properties one line caught my attention : include-and-override=service-ext.properties
Where can I find this file ? Because I can't find it.
thumbnail
David H Nebinger, modificado hace 11 años.

RE: [ServiceBuilder] Context initialization failed. Error creating bean

Liferay Legend Mensajes: 14914 Fecha de incorporación: 2/09/06 Mensajes recientes
service-ext.properties is an optional file that you can use to handle property overrides. It is not required and would not be throwing the exception.

After changing the permissions, you probably have to restart your app server to see if it worked (only when the portlet plugin is initializing will it attempt to read the file).
thumbnail
Milen Dyankov, modificado hace 11 años.

RE: [ServiceBuilder] Context initialization failed. Error creating bean

Regular Member Mensajes: 171 Fecha de incorporación: 23/09/09 Mensajes recientes
G Jerom:

I give the 777 permissions for service.properties for the two different locations : WEB-INF/classes & WEB-INF/src but it doesn't work.

Inside service.properties one line caught my attention : include-and-override=service-ext.properties
Where can I find this file ? Because I can't find it.


Don't worry about service-ext.properties file - its used to extends the config since service.properties gets overwritten every time you run service builder. I assume you are using Liferay IDE to build you project. But have you tried to do the same thing from ant? If not, go to the folder where you have your project and try to run this:
ant clean build-service war

You can also try to delete the WEB-INF/src/service.properties and let service builder regenerate it (not sure if that works without changes in service.xml so back it up first)
Then deploy the WAR found in <YOUR_PROJECT>/../../dist folder and see if it works.
G Jerom, modificado hace 11 años.

RE: [ServiceBuilder] Context initialization failed. Error creating bean

New Member Mensajes: 8 Fecha de incorporación: 27/06/12 Mensajes recientes
@David H Nebinger : I restarted the server but the issue remains the same.
@ Milen Dyankov : With Ant I can clean and build services. But I can't make a war for this issue :
build-css:
[java] Error: Could not find or load main class com.liferay.portal.tools.SassToCssBuilder
It seems that this issues come from liferay 6.0.6 and is fix with liferay 6.1 But I have to use liferay 6.0.6 for my work.
So I export with Eclipse my project after using Ant for clean and build services. But I get the same issue as I explain before (Error creating bean)

For an unknown reason, when I restart the server, I have this line on stdout.log :

Loading file:/tmp/35-payYourFine-portlet/WEB-INF/classes/service.properties

Which mean that the server is trying to get service.properties from the tmp folder.
How can I set the right path ?
thumbnail
Milen Dyankov, modificado hace 11 años.

RE: [ServiceBuilder] Context initialization failed. Error creating bean

Regular Member Mensajes: 171 Fecha de incorporación: 23/09/09 Mensajes recientes
G Jerom:
With Ant I can clean and build services. But I can't make a war for this issue :
build-css:
[java] Error: Could not find or load main class com.liferay.portal.tools.SassToCssBuilder


Are you sure you are using a version of Liferay SDK that matches the version of the portal? Double check the value of app.server.dir property in <SDK_HOME>/build.<YOURNAME>.properties file! You may have different versions of SDK/portal mixed up which is sometimes hard to realize with Eclipse IDE. I personally would try to solve the issues without Liferay IDE and only being sure it works from ant, continue to fix things in Eclipse IDE