--- Begin Message ---
Hi,

Thanks for your query on saturday , it gave me few clues to get the ulcspring integration working using spring-framework-2.5.6 libraries (spring.jar & spring-webmvc.jar).

Here is what needs to be done.

1>  Edit Web.xml
<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 springapp-servlet.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"/> <bean id="XXXApplet" scope="prototype" class="com.isfsdc.wwm.application.XXXApplet" />
</beans>

3>  Edit xxx.jsp  file
<%
String applicationUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() +
                         request.getContextPath() + "/ulc?app=XXXApplet";
%>

4>  include spring.jar and spring-mvc.jar in web-inf/lib folder

* XXXApplet  extends  com.ulcjava.base.application.AbstractApplication

What was missing was bean entry XXXApplet in springapp-servlet.xml. When the application is launched as a webapplication, beans defined in springapp-servlet.xml are searched using their Ids. (Took time to realize since i have just started using spring-mvc framework)

I tried using the older libraries of spring and realized that the earlier xml files have a different structure. Also spring.xml mentioned in the previous email is usefull when the application is launched as development launcher.

It would be great if there was a post that would demonstrate Spring-MVC-step-by-step with ULC.
Thanks,
Eugene

Christian Ribeaud wrote:
Hi Eugene,

Just a couple of questions before I start to reproduce you problem.

1/ Are you sure that it is not able to find beans implementing IApplication? Obviously you will
    get exactly the same exception if it finds more than one bean, right?
2/ Which version of Spring are you using?

And you are saying that the whole story works using the development runner, right?
Have a nice day. Regards,

christian
--
Canoo - Your Solution Provider for Rich Internet Applications

    Christian Ribeaud
    Canoo Engineering AG
    Kirschgartenstrasse 5
    CH-4051 Basel

    Tel: +41 61 228 94 44
    Fax: +41 61 228 94 49

    [email protected]
    http://www.canoo.com/

On Jul 24, 2009, at 6:49 AM, Eugene Coelho wrote:

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





--- End Message ---

Reply via email to