Note that there are some explanatory texts on larger screens.

plurals
  1. POLiferay + Spring + Spring Web Mvc - @Autowired dont work
    text
    copied!<p>using: liferay 6.1 spring 3.1 spring-portlet-mvc</p> <p>We tried to inject spring beans with @Autowired and it seems that this doesnt work with liferay 6.1 ? Known bug? Workaround?</p> <p>here my applicationContext.xml:</p> <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"&gt; &lt;bean id="viewNameTranslator" class="org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator"/&gt; &lt;bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/&gt; &lt;mvc:annotation-driven /&gt; &lt;context:annotation-config /&gt; &lt;context:component-scan base-package="com.ebcont.yatc.portlets.service"/&gt; &lt;bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt; &lt;property name="locations"&gt; &lt;list&gt; &lt;value&gt;classpath:configuration.properties&lt;/value&gt; &lt;value&gt;classpath:mail.properties&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="appProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"&gt; &lt;property name="singleton" value="true"/&gt; &lt;property name="properties"&gt; &lt;props&gt; &lt;prop key="application.name"&gt;${application.name}&lt;/prop&gt; &lt;/props&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="mailProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"&gt; &lt;property name="singleton" value="true"/&gt; &lt;property name="properties"&gt; &lt;props&gt; &lt;prop key="mail.host"&gt;${mail.host}&lt;/prop&gt; &lt;prop key="mail.port"&gt;${mail.port}&lt;/prop&gt; &lt;prop key="mail.username"&gt;${mail.username}&lt;/prop&gt; &lt;prop key="mail.password"&gt;${mail.password}&lt;/prop&gt; &lt;prop key="mail.smtp.auth"&gt;${mail.smtp.auth}&lt;/prop&gt; &lt;prop key="mail.smtp.starttls.enable"&gt;${mail.smtp.starttls.enable}&lt;/prop&gt; &lt;prop key="mail.registration.sender"&gt;${mail.registration.sender}&lt;/prop&gt; &lt;prop key="mail.registration.subject"&gt;${mail.registration.subject}&lt;/prop&gt; &lt;/props&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"&gt; &lt;property name="host" value="${mail.host}"/&gt; &lt;property name="port" value="${mail.port}"/&gt; &lt;property name="username" value="${mail.username}"/&gt; &lt;property name="password" value="${mail.password}"/&gt; &lt;property name="javaMailProperties"&gt; &lt;props&gt; &lt;prop key="mail.smtp.auth"&gt;${mail.smtp.auth}&lt;/prop&gt; &lt;prop key="mail.smtp.starttls.enable"&gt;${mail.smtp.starttls.enable}&lt;/prop&gt; &lt;/props&gt; &lt;/property&gt; &lt;property name="defaultEncoding" value="UTF-8"/&gt; &lt;/bean&gt; &lt;bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean"&gt; &lt;property name="velocityProperties"&gt; &lt;value&gt; resource.loader=class class.resource.loader.class= org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader &lt;/value&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="portletMultipartResolver" class="org.springframework.web.portlet.multipart.CommonsPortletMultipartResolver"&gt; &lt;!-- one of the properties available; the maximum file size in bytes --&gt; &lt;property name="maxUploadSize" value="100000"/&gt; &lt;/bean&gt; &lt;/beans&gt; </code></pre> <p>web.xml:</p> <pre><code>&lt;web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&gt; &lt;display-name&gt;Portlet MVC&lt;/display-name&gt; &lt;servlet&gt; &lt;servlet-name&gt;ViewRendererServlet&lt;/servlet-name&gt; &lt;servlet-class&gt;org.springframework.web.servlet.ViewRendererServlet&lt;/servlet-class&gt; &lt;/servlet&gt; &lt;listener&gt; &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt; &lt;/listener&gt; &lt;listener&gt; &lt;listener-class&gt;org.springframework.web.context.request.RequestContextListener&lt;/listener-class&gt; &lt;/listener&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;ViewRendererServlet&lt;/servlet-name&gt; &lt;url-pattern&gt;/WEB-INF/servlet/view&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;classpath*:/**/applicationContext.xml&lt;/param-value&gt; &lt;/context-param&gt; </code></pre> <p></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload