<?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>UserService dependency injection from portal-spring.xml</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=490478" />
  <subtitle>UserService dependency injection from portal-spring.xml</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=490478</id>
  <updated>2026-06-15T18:55:49Z</updated>
  <dc:date>2026-06-15T18:55:49Z</dc:date>
  <entry>
    <title>RE: UserService dependency injection from portal-spring.xml</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=499429" />
    <author>
      <name>Dennis Kieselhorst</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=499429</id>
    <updated>2008-02-20T15:36:41Z</updated>
    <published>2008-02-20T15:36:41Z</published>
    <summary type="html">Found another easy way: I used &lt;a href="http://static.springframework.org/spring/docs/2.0.x/reference/beans.html#beans-factory-class-instance-factory-method"&gt;spring&amp;#39;s  factory-bean and factory-method attributes&lt;/a&gt; to retrieve a UserLocalService instance from UserLocalServiceFactory.getService().</summary>
    <dc:creator>Dennis Kieselhorst</dc:creator>
    <dc:date>2008-02-20T15:36:41Z</dc:date>
  </entry>
  <entry>
    <title>UserService dependency injection from portal-spring.xml</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=490477" />
    <author>
      <name>Dennis Kieselhorst</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=490477</id>
    <updated>2008-02-18T16:57:32Z</updated>
    <published>2008-02-18T16:57:32Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Hi,&lt;br&gt;&lt;br&gt;I'd like to write a customized UserService for my portlet application. The service needs Liferay's UserService or UserLocalService. To autowire the dependencies I need a bean for it in my applicationContext. I found out that UserService is described in Liferay's portal-spring.xml, so Spring should resolve it with the following config in my web.xml (have not tried it yet):&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;
	&amp;lt;context-param&amp;gt;
		&amp;lt;param-name&amp;gt;contextConfigLocation&amp;lt;/param-name&amp;gt;
		&amp;lt;param-value&amp;gt;/WEB-INF/context/my-web-context.xml,classpath:my-service-context.xml,
		  classpath:portal-spring.xml&amp;lt;/param-value&amp;gt;
	&amp;lt;/context-param&amp;gt;
	&amp;lt;listener&amp;gt;
		&amp;lt;description&amp;gt;Spring initialization&amp;lt;/description&amp;gt;
		&amp;lt;listener-class&amp;gt;org.springframework.web.context.ContextLoaderListener&amp;lt;/listener-class&amp;gt;
	&amp;lt;/listener&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;I think this will cause multiple contexts (the liferay context and my context). In other forum messages SpringUtil is used to retrieve the liferay context. &lt;br&gt;&lt;br&gt;So what's recommend?&lt;br&gt;&lt;br&gt;Regards&lt;br&gt;Dennis&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Dennis Kieselhorst</dc:creator>
    <dc:date>2008-02-18T16:57:32Z</dc:date>
  </entry>
</feed>
