<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>DXP ServiceBuilder,unable to inject services</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=89553185" />
  <subtitle>DXP ServiceBuilder,unable to inject services</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=89553185</id>
  <updated>2026-04-06T09:02:25Z</updated>
  <dc:date>2026-04-06T09:02:25Z</dc:date>
  <entry>
    <title>RE: DXP ServiceBuilder,unable to inject services</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118437722" />
    <author>
      <name>Amos Fong</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118437722</id>
    <updated>2020-02-06T01:10:05Z</updated>
    <published>2020-02-06T01:10:05Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;I just ran into this error as well (Liferay DXP 7.0) and adding "type" to the ServiceReference fixed it for me:&amp;nbsp;&lt;br&gt;&lt;pre&gt;&lt;code&gt;&amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;@ServiceReference(type = AccountWebService.class)
&amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;private AccountWebService _accountWebService;&lt;/code&gt;&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Amos Fong</dc:creator>
    <dc:date>2020-02-06T01:10:05Z</dc:date>
  </entry>
  <entry>
    <title>RE: DXP ServiceBuilder,unable to inject services</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=89566710" />
    <author>
      <name>Zak Thompson</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=89566710</id>
    <updated>2017-05-17T20:57:47Z</updated>
    <published>2017-05-17T20:57:47Z</published>
    <summary type="html">That worked, thanks David!</summary>
    <dc:creator>Zak Thompson</dc:creator>
    <dc:date>2017-05-17T20:57:47Z</dc:date>
  </entry>
  <entry>
    <title>RE: DXP ServiceBuilder,unable to inject services</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=89564297" />
    <author>
      <name>David H Nebinger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=89564297</id>
    <updated>2017-05-17T18:28:36Z</updated>
    <published>2017-05-17T18:28:36Z</published>
    <summary type="html">Change to:&lt;br /&gt;&lt;br /&gt;&amp;lt;reference entity=&amp;#34;AssetVocabulary&amp;#34; package-path=&amp;#34;&lt;strong&gt;com.liferay.portlet.asset&lt;/strong&gt;&amp;#34; /&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="https://www.eventbrite.com/e/liferay-symposium-north-america-2017-registration-28398031276"&gt;Come meet me at the 2017 LSNA!&lt;/a&gt;</summary>
    <dc:creator>David H Nebinger</dc:creator>
    <dc:date>2017-05-17T18:28:36Z</dc:date>
  </entry>
  <entry>
    <title>DXP ServiceBuilder,unable to inject services</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=89553184" />
    <author>
      <name>Zak Thompson</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=89553184</id>
    <updated>2017-05-17T16:11:22Z</updated>
    <published>2017-05-17T16:11:22Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;I am working on a service builder module and I'm attempting to inject the following services into my local service impl:&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;private AssetCategoryPropertyLocalService assetCategoryPropertyLocalService;
private AssetVocabularyLocalService assetVocabularyLocalService;&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;My first attempt at injecting them was to use setter methods with OSGI Reference annotations, but the services were null when my custom service methods were called:&lt;br&gt;&lt;pre&gt;&lt;code&gt;@Reference(unbind = "-")
	protected void setAssetCategoryPropertyLocalService(final AssetCategoryPropertyLocalService assetCategoryPropertyLocalService){
		this.assetCategoryPropertyLocalService = assetCategoryPropertyLocalService;
	}

@Reference(unbind = "-")
	protected void setAssetVocabularyLocalService(final AssetVocabularyLocalService assetVocabularyLocalService) {
		this.assetVocabularyLocalService = assetVocabularyLocalService;
	}&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;I then tried to add ServiceReference annotations to the services, but this results in exceptions being thrown when the module is deployed:&lt;br&gt;&lt;pre&gt;&lt;code&gt;@ServiceReference
	private AssetCategoryPropertyLocalService assetCategoryPropertyLocalService;
@ServiceReference
	private AssetVocabularyLocalService assetVocabularyLocalService;&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;Exception:&lt;br&gt;&lt;pre&gt;&lt;code&gt;
[com_liferay_portal_spring_extender:103] Invocation of 'start' failed. 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.company.site.integrity.service.SiteIntegrityLocalService' defined in URL [bundleentry://665.fwk725273950/META-INF/spring/module-spring.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.company.site.integrity.service.impl.SiteIntegrityLocalServiceImpl': Unable to inject bean reference fields; nested exception is java.lang.IllegalArgumentException: Can not set com.liferay.asset.kernel.service.AssetCategoryPropertyLocalService field com.company.site.integrity.service.impl.SiteIntegrityLocalServiceImpl.assetCategoryPropertyLocalService to com.liferay.blogs.web.internal.auth.publicpath.AuthPublicPath
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:762)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
	at com.liferay.portal.spring.extender.internal.context.ModuleApplicationContextRegistrator._createApplicationContext(ModuleApplicationContextRegistrator.java:144)
	at com.liferay.portal.spring.extender.internal.context.ModuleApplicationContextRegistrator.start(ModuleApplicationContextRegistrator.java:61)
	at sun.reflect.GeneratedMethodAccessor380.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.felix.dm.InvocationUtil.invokeMethod(InvocationUtil.java:111)
	at org.apache.felix.dm.InvocationUtil.invokeCallbackMethod(InvocationUtil.java:66)
	at org.apache.felix.dm.impl.ComponentImpl.invokeCallbackMethod(ComponentImpl.java:769)
	at org.apache.felix.dm.impl.ComponentImpl.invoke(ComponentImpl.java:760)
	at org.apache.felix.dm.impl.ComponentImpl.bindService(ComponentImpl.java:705)
	at org.apache.felix.dm.impl.ComponentImpl.access$400(ComponentImpl.java:54)
	at org.apache.felix.dm.impl.ComponentImpl$7.run(ComponentImpl.java:202)
	at org.apache.felix.dm.impl.SerialExecutor.runTask(SerialExecutor.java:137)
	at org.apache.felix.dm.impl.SerialExecutor.runTasks(SerialExecutor.java:119)
	at org.apache.felix.dm.impl.SerialExecutor.execute(SerialExecutor.java:85)
	at org.apache.felix.dm.impl.ComponentImpl.calculateStateChanges(ComponentImpl.java:252)
	at org.apache.felix.dm.impl.ComponentImpl.start(ComponentImpl.java:440)
	at org.apache.felix.dm.DependencyManager.add(DependencyManager.java:167)
	at com.liferay.portal.spring.extender.internal.context.ModuleApplicationContextExtender$ModuleApplicationContextExtension.start(ModuleApplicationContextExtender.java:223)
	at org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:259)
	at org.apache.felix.utils.extender.AbstractExtender.modifiedBundle(AbstractExtender.java:232)
	at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:482)
	at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:1)
	at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232)
	at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444)
	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:905)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:165)
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:75)
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:67)
	at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:102)
	at org.eclipse.osgi.container.Module.publishEvent(Module.java:461)
	at org.eclipse.osgi.container.Module.start(Module.java:452)
	at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:454)
	at org.eclipse.osgi.container.ModuleContainer.applyDelta(ModuleContainer.java:717)
	at org.eclipse.osgi.container.ModuleContainer.resolveAndApply(ModuleContainer.java:491)
	at org.eclipse.osgi.container.ModuleContainer.resolve(ModuleContainer.java:437)
	at org.eclipse.osgi.container.ModuleContainer.refresh(ModuleContainer.java:955)
	at org.eclipse.osgi.container.ModuleContainer$ContainerWiring.dispatchEvent(ModuleContainer.java:1336)
	at org.eclipse.osgi.container.ModuleContainer$ContainerWiring.dispatchEvent(ModuleContainer.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.company.site.integrity.service.impl.SiteIntegrityLocalServiceImpl': Unable to inject bean reference fields; nested exception is java.lang.IllegalArgumentException: Can not set com.liferay.asset.kernel.service.AssetCategoryPropertyLocalService field com.company.site.integrity.service.impl.SiteIntegrityLocalServiceImpl.assetCategoryPropertyLocalService to com.liferay.blogs.web.internal.auth.publicpath.AuthPublicPath
	at com.liferay.portal.spring.extender.internal.bean.ServiceReferenceAnnotationBeanPostProcessor.autoInject(ServiceReferenceAnnotationBeanPostProcessor.java:101)
	at com.liferay.portal.spring.extender.internal.bean.ServiceReferenceAnnotationBeanPostProcessor.postProcessBeforeInitialization(ServiceReferenceAnnotationBeanPostProcessor.java:67)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1564)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
	... 51 more
Caused by: java.lang.IllegalArgumentException: Can not set com.liferay.asset.kernel.service.AssetCategoryPropertyLocalService field com.company.site.integrity.service.impl.SiteIntegrityLocalServiceImpl.assetCategoryPropertyLocalService to com.liferay.blogs.web.internal.auth.publicpath.AuthPublicPath
	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
	at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81)
	at java.lang.reflect.Field.set(Field.java:764)
	at com.liferay.portal.spring.extender.internal.bean.ServiceReferenceAnnotationBeanPostProcessor.autoInject(ServiceReferenceAnnotationBeanPostProcessor.java:95)
	... 55 more
&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;I also have tried adding the following to my service xml to inject the service, but it gives me an error in the build service task:&lt;br&gt;&lt;pre&gt;&lt;code&gt;&amp;lt;reference entity="AssetVocabulary" package-path="com.liferay.portal" /&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;Error:&lt;br&gt;&lt;pre&gt;&lt;code&gt;Unable to find AssetVocabulary in Account,Address,BrowserTracker,ClassName,ClusterGroup,Company,Contact,Country,EmailAddress,Group,Image,Layout,LayoutBranch,LayoutFriendlyURL,LayoutPrototype,LayoutRevision,LayoutSet,LayoutSetBranch,LayoutSetPrototype,LayoutTemplate,ListType,MembershipRequest,Organization,OrgGroupRole,OrgLabor,PasswordPolicy,PasswordPolicyRel,PasswordTracker,Permission,Phone,PluginSetting,Portal,PortalPreferences,Portlet,PortletItem,PortletPreferences,RecentLayoutBranch,RecentLayoutRevision,RecentLayoutSetBranch,Region,Release,Repository,RepositoryEntry,Resource,ResourceAction,ResourceBlock,ResourceBlockPermission,ResourcePermission,ResourceTypePermission,Role,ServiceComponent,Subscription,SystemEvent,Team,Theme,Ticket,User,UserGroup,UserGroupGroupRole,UserGroupRole,UserIdMapper,UserNotificationDelivery,UserNotificationEvent,UserTracker,UserTrackerPath,VirtualHost,WebDAVProps,Website,WorkflowDefinitionLink,WorkflowInstanceLink&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;What is the proper way to inject these services into my servicebuilder component?&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Zak Thompson</dc:creator>
    <dc:date>2017-05-17T16:11:22Z</dc:date>
  </entry>
</feed>
