Announcement Announcement Module
Collapse
No announcement yet.
ClasspathXmlApplicationContext doesn't work with Struts 1 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ClasspathXmlApplicationContext doesn't work with Struts 1

    I use Spring OXM as well as Struts 1 but without integrating Struts with Spring IOC. This is because the application is an old one and I'm just adding a module that involves the XML binding and I have no intention to change the architecture of the application.

    I have an action class that calls ClasspathXmlApplicationContext for bean injection for the OXM.

    Here is my spring context XML:

    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"
      xmlns:oxm="http://www.springframework.org/schema/oxm"
      xsi:schemaLocation="
         http://www.springframework.org/schema/beans 
         http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
         http://www.springframework.org/schema/oxm 
         http://www.springframework.org/schema/oxm/spring-oxm-1.5.xsd">
    
        <bean id="xmlMapper" class="com.st.mas.wmr.utils.xml.stifbinconv.XmlMapper">
            <property name="marshaller" ref="jaxbMarshaller" />
            <property name="unmarshaller" ref="jaxbMarshaller" />
        </bean>
        <bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
            <property name="contextPath" value="com.st.mas.wmr.utils.xml.jaxb.stifbinconv"/>
            <property name="validating" value="true"/>
        </bean>
    </beans>
    The action class:
    Code:
    public class StifBinConversionAction extends AnyDispatchAction {
        private IProcessStifOliBinConversion svc;
    
        public StifBinConversionAction() {
            super();
            svc = new ProcessStifOliBinConversion();
        }
    The service class:
    Code:
    public class ProcessStifOliBinConversion
        implements
            IProcessStifOliBinConversion {
        private BasicDataSource ds;
    
        private IAtomStifOliBinConversion dao;
        private ApplicationContext ctx;
        private XmlMapper xmlMapper;
    
        public ProcessStifOliBinConversion() {
            super();
            ds = new BasicDataSource();
            //TODO consts
            ds.setDriverClassName("oracle.jdbc.driver.OracleDriver");
            ds.setUrl("jdbc:oracle:thin:@sglx482:1521:wmr");
            ds.setUsername("wmr_online");
            ds.setPassword("wmr_online");
    
            dao = new AtomStifOliBinConversion(ds);
            ctx = new ClassPathXmlApplicationContext("oxm-context.xml", XmlMapper.class);
            xmlMapper = ctx.getBean(XmlMapper.class);
        }
    The web application gives HTTP 500 WITHOUT any error message or stack trace.

    Seems that the problem is within the Spring injection.

    It's irritating when there's an error but there's no error message. It makes you stuck for days.

    Thanks

    Will

  • #2
    For starters you are using spring 3 and spring oxm from spring webservices (judging from the xsd elements in your configuration). Simply don't do that as the 2 don't mix. Spring 3 has its own oxm support, so either use the correct jar or fix your namespace.

    Next to that if you want to run out of resources your current approach is a good one. Each time your action is invoked/constructed you reconstruct the whole applicationcontext...Not really wise to do...

    For more information on your error I suggest enabling debug logging and check your log files. The status 500 page will not show you that much information...

    Comment

    Working...
    X