Hi,

For a past few days i have been trying to get ulc springmvc integration working for a project. I could manage to get development runner running as shown in one of the mails on the mailing list .

The problem arises when i access the application as a webapplication. When i access the jsp page the SpringWebULCApplication gets instantiated but when it goes to find the application using the following

public static IApplication getApplication(ApplicationContext context, String applicationBeanName) {
   IApplication application;
   if(applicationBeanName != null) {
     application = ((IApplication) context.getBean(applicationBeanName));
   } else {
     final Map applications = context.getBeansOfType(IApplication.class);
if(applications.size() != 1) throw new IllegalArgumentException("Application context must contain exactly one ULCApplication: "+applications);
     application = (IApplication) applications.values().iterator().next();
   }
   return application;
}

it is not able to locate the bean which implements IApplication.class and hence terminates with an error "Application context must contain exactly one ULCApplication:"

Can someone help me in  making use of SpringWebULCApplication class.
Is there anything more that is required like an applicationContext.xml file to let the framework find the class that implements IApplication.class ?
------------------------------------------------------------------------
So far i have managed to do the following changes.
1>Edit web.xml  to introduce

<servlet>
   <servlet-name>springapp</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
   <load-on-startup>1</load-on-startup>
 </servlet>

 <servlet-mapping>
   <servlet-name>springapp</servlet-name>
   <url-pattern>/ulc</url-pattern>
 </servlet-mapping>

2>Introduce file called springapp-servlet.xml in the same location as web.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";
      xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-2.5.xsd";>

<!-- the application context definition for the springapp DispatcherServlet -->

 <bean name="/ulc" class="org.mernst.ulcjava.spring.ULCController"/>
<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>

</beans>

3>Edit the xxxx.jsp file and update the url to access /ulc
<%
String applicationUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() +
                         request.getContextPath() + "/ulc";
%>

4>Introduce spring.xml in the resources ( i guess this would be only used with development launcher code)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd";>

<bean name="ABC" scope="prototype" class="com.xxx.xxxx.application.ABC">
</bean>

</beans>

(Class ABC implements  IApplication)

5>Development Runner Code

public class SpringDevelopmentRunner implements IApplication {
private static final String SPRING_XML = "/spring.xml";
   private static final String SPRING_IAPPLICATION_BEAN = "ABC";

   private ClassPathXmlApplicationContext _springContext;
   private IApplication _delegate;

   public void start() {
       _springContext = new ClassPathXmlApplicationContext(SPRING_XML);
_delegate = (IApplication) _springContext.getBean(SPRING_IAPPLICATION_BEAN);
       _delegate.start();
   }
...
.. ...

Thanks,
Eugene
_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer

Reply via email to