Results 1 to 6 of 6

Thread: Just JDBC support (newbie guy)

  1. #1
    Join Date
    Dec 2004
    Location
    MEXICO
    Posts
    11

    Default Just JDBC support (newbie guy)

    Hello everyone:

    I was trying to use the Spring framework with the JDBC DAO support. ONLY the JDBC DAO support, to avoid the need of using the try - catch - finally idiom to access the database.

    I created the DAO interfaces and implementations. Then created an XML file called AcronetApplicationContext.xml and stored it under the <WEBAPPLICATION-FOLDER>/WEB-INF/classes folder.

    I am using WebLogic Server 6.0 and a WebLogic Portal 4.0 application.

    These is the AcronetApplicationContext.xml file:

    --------------------------------> AcronetApplicationContext.xml file

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <!-- Middle tier application context definition for the Database. -->
    <beans>
    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiName">
    <value>weblogic.jdbc.pool.commercePool</value>
    </property>
    </bean>

    <!-- Transaction manager for a single JDBC DataSource -->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager">
    <property name="dataSource">
    <ref local="dataSource"/>
    </property>
    </bean>

    <bean id="medicalCenterDao" class="com.novartis.oncodb.acronet.util.dao.intern al.MedicalCenterDaoImpl">
    <property name="dataSource">
    <ref local="dataSource"/>
    </property>
    </bean>
    </beans>
    --------------------------------> End of AcronetApplicationContext.xml file

    I wanted to use my DAO to create (in the simplest and maybe most horrible way) a record in the Database, the record corresponds to a medical center data, using this JSP:

    --------------------------------> INSERT A RECORD JSP
    <%@ page import="com.novartis.oncodb.acronet.util.dao.Medic alCenterDao" %>
    <%@ page import="com.novartis.oncodb.acronet.util.dao.inter nal.MedicalCenterDaoImpl" %>
    <%@ page import="javax.sql.DataSource" %>
    <%@ page import="javax.naming.*" %>
    <%@ page import="com.novartis.oncodb.acronet.util.to.Medica lCenterTo" %>
    <%@ page import="org.springframework.context.ApplicationCon text" %>
    <%@ page import="org.springframework.context.support.ClassP athXmlApplicationContext"%>
    <%
    DataSource ds = null;
    try {
    InitialContext ic = new InitialContext();
    ds = (DataSource) ic.lookup("weblogic.jdbc.pool.commercePool");
    ic = null;
    }catch(NamingException iae){
    iae.printStackTrace();
    }

    ApplicationContext ctx = new ClassPathXmlApplicationContext("WEB-INF/classes/AcronetApplicationContext.xml");

    MedicalCenterDao dao = (MedicalCenterDao) ctx.getBean("medicalCenterDao");

    MedicalCenterTo centro = new MedicalCenterTo("Siglo XXI", "Metro Centro Medico");

    out.println(dao.createCenter(centro));
    %>
    --------------------------------> END OF INSERT A RECORD JSP

    When loading this JSP I get the following error in the stack trace:

    =============== Initializing Logger ======================
    <8/12/2004 01:54:04 PM PST> <Notice> <WebLogicServer> <ListenThread listening on
    port 7501>
    <8/12/2004 01:54:05 PM PST> <Notice> <WebLogicServer> <Started WebLogic Admin Se
    rver "portalServer" for domain "portalDomain" running in Production Mode>
    <8/12/2004 02:12:58 PM PST> <Error> <HTTP> <[WebAppServletContext(21422866,acron
    et,/acronet)] Servlet failed with Exception
    java.lang.NoSuchMethodError: org.springframework.core.io.AbstractResource: metho
    d getDescription()Ljava/lang/String; not found
    at java.lang.String.valueOf(String.java:1947)
    at java.lang.StringBuffer.append(StringBuffer.java:37 0)
    at
    org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBea
    nDefinitions(XmlBeanDefinitionReader.java:117)
    at org.springframework.context.support.AbstractXmlApp licationContext.loa
    dBeanDefinitions(AbstractXmlApplicationContext.jav a:144)
    at org.springframework.context.support.AbstractXmlApp licationContext.ref
    reshBeanFactory(AbstractXmlApplicationContext.java :79)
    at org.springframework.context.support.AbstractApplic ationContext.refres
    h(AbstractApplicationContext.java:249)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<i
    nit>(ClassPathXmlApplicationContext.java:80)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<i
    nit>(ClassPathXmlApplicationContext.java:65)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<i
    nit>(ClassPathXmlApplicationContext.java:56)
    at jsp_servlet.__meterenbd._jspService(__meterenbd.ja va:110)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java: 27)
    at weblogic.servlet.internal.ServletStubImpl.invokeSe rvlet(ServletStubIm
    pl.java:262)
    at weblogic.servlet.internal.ServletStubImpl.invokeSe rvlet(ServletStubIm
    pl.java:321)
    at weblogic.servlet.internal.ServletStubImpl.invokeSe rvlet(ServletStubIm
    pl.java:198)
    at weblogic.servlet.internal.WebAppServletContext.inv okeServlet(WebAppSe
    rvletContext.java:2637)
    at weblogic.servlet.internal.ServletRequestImpl.execu te(ServletRequestIm
    pl.java:2359)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThrea d.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.ja va:120)
    >

    Could it be possible that the method is not present?

    Thanks in advance,

    Carlos Morales

  2. #2
    Join Date
    Aug 2004
    Location
    Auburn, AL, USA.
    Posts
    106

    Default

    I would first look at using the ContextLoaderListener; I don't think it forces you to do anything other than declare it as a listener (i.e. you don't have to use Spring MVC just because you are using the listener).

    Second, have you tested the calls in a non-JSP manner? Even wrapping all the calls in a JavaBean which you call from your JSP (or better yet a servlet) would allow you to test both in an IDE and from the servlet contain but with cleaner error messages than JSP tends to generate.

  3. #3
    Join Date
    Dec 2004
    Location
    MEXICO
    Posts
    11

    Default Problem with ContextLoaderServlet

    Quote Originally Posted by rrsIPOV
    I would first look at using the ContextLoaderListener; I don't think it forces you to do anything other than declare it as a listener (i.e. you don't have to use Spring MVC just because you are using the listener).

    Second, have you tested the calls in a non-JSP manner? Even wrapping all the calls in a JavaBean which you call from your JSP (or better yet a servlet) would allow you to test both in an IDE and from the servlet contain but with cleaner error messages than JSP tends to generate.
    Hi, let me first thank you for your attention, time and support.
    I set up the listener in the web.xml deployment descriptor, also the context parameter to specify the location of the application context XML file. The problem is not inside any code I wrote, I throw away all I did when I noticed I had not even configured the ContextLoaderListener :? . The problem is still there:

    -------------- WEBLOGIC 6.1 STACKTRACE WHEN STARTING UP------------->

    <9/12/2004 09:24:26 AM PST> <Notice> <Management> <Applications will only be cop
    ied to managed servers when needed. To force applications to be copied to manage
    d servers when they are started, specify system property -Dweblogic.management.f
    orceApplicationCopy=true on your startup command.>
    <9/12/2004 09:30:40 AM PST> <Notice> <Management> <Application Poller not starte
    d for production server.>
    log4j:WARN No appenders could be found for logger (org.springframework.web.conte
    xt.ContextLoader).
    log4j:WARN Please initialize the log4j system properly.
    <9/12/2004 09:30:42 AM PST> <Error> <HTTP> <[WebAppServletContext(9248159,acrone
    t,/acronet)] Error loading servlet: 'context'
    java.lang.NoSuchMethodError: org.springframework.core.io.AbstractResource: metho
    d getDescription()Ljava/lang/String; not found
    at java.lang.String.valueOf(String.java:1947)
    at java.lang.StringBuffer.append(StringBuffer.java:37 0)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBea
    nDefinitions(XmlBeanDefinitionReader.java:117)
    at org.springframework.context.support.AbstractXmlApp licationContext.loa
    dBeanDefinitions(AbstractXmlApplicationContext.jav a:144)
    at org.springframework.context.support.AbstractXmlApp licationContext.ref
    reshBeanFactory(AbstractXmlApplicationContext.java :79)
    at org.springframework.context.support.AbstractApplic ationContext.refres
    h(AbstractApplicationContext.java:249)
    at org.springframework.web.context.support.XmlWebAppl icationContext.refr
    esh(XmlWebApplicationContext.java:131)
    at org.springframework.web.context.ContextLoader.crea teWebApplicationCon
    text(ContextLoader.java:167)
    at org.springframework.web.context.ContextLoader.init WebApplicationConte
    xt(ContextLoader.java:101)
    at org.springframework.web.context.ContextLoaderServl et.init(ContextLoad
    erServlet.java:80)
    at javax.servlet.GenericServlet.init(GenericServlet.j ava:258)
    at weblogic.servlet.internal.ServletStubImpl.createSe rvlet(ServletStubIm
    pl.java:731)
    at weblogic.servlet.internal.ServletStubImpl.createIn stances(ServletStub
    Impl.java:658)
    at weblogic.servlet.internal.ServletStubImpl.prepareS ervlet(ServletStubI
    mpl.java:603)
    at weblogic.servlet.internal.WebAppServletContext.pre loadServlet(WebAppS
    ervletContext.java:2360)
    at weblogic.servlet.internal.WebAppServletContext.pre loadServlets(WebApp
    ServletContext.java:2301)
    at weblogic.servlet.internal.HttpServer.preloadServle ts(HttpServer.java:
    558)
    at weblogic.servlet.internal.WebService.preloadServle ts(WebService.java:
    450)
    at weblogic.t3.srvr.ServletInitRunner.run(ServletInit Runner.java:49)
    at java.lang.Thread.run(Thread.java:484)
    >
    <9/12/2004 09:30:42 AM PST> <Error> <HTTP> <[WebAppServletContext(9248159,acrone
    t,/acronet)] Error loading servlet: "context"
    java.lang.NoSuchMethodError: org.springframework.core.io.AbstractResource: metho
    d getDescription()Ljava/lang/String; not found
    at java.lang.String.valueOf(String.java:1947)
    at java.lang.StringBuffer.append(StringBuffer.java:37 0)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBea
    nDefinitions(XmlBeanDefinitionReader.java:117)

    at org.springframework.context.support.AbstractXmlApp licationContext.loa
    dBeanDefinitions(AbstractXmlApplicationContext.jav a:144)
    at org.springframework.context.support.AbstractXmlApp licationContext.ref
    reshBeanFactory(AbstractXmlApplicationContext.java :79)
    at org.springframework.context.support.AbstractApplic ationContext.refres
    h(AbstractApplicationContext.java:249)
    at org.springframework.web.context.support.XmlWebAppl icationContext.refr
    esh(XmlWebApplicationContext.java:131)
    at org.springframework.web.context.ContextLoader.crea teWebApplicationCon
    text(ContextLoader.java:167)
    at org.springframework.web.context.ContextLoader.init WebApplicationConte
    xt(ContextLoader.java:101)
    at org.springframework.web.context.ContextLoaderServl et.init(ContextLoad
    erServlet.java:80)
    at javax.servlet.GenericServlet.init(GenericServlet.j ava:258)
    at weblogic.servlet.internal.ServletStubImpl.createSe rvlet(ServletStubIm
    pl.java:731)
    at weblogic.servlet.internal.ServletStubImpl.createIn stances(ServletStub
    Impl.java:658)
    at weblogic.servlet.internal.ServletStubImpl.prepareS ervlet(ServletStubI
    mpl.java:603)
    at weblogic.servlet.internal.WebAppServletContext.pre loadServlet(WebAppS
    ervletContext.java:2360)
    at weblogic.servlet.internal.WebAppServletContext.pre loadServlets(WebApp
    ServletContext.java:2301)
    at weblogic.servlet.internal.HttpServer.preloadServle ts(HttpServer.java:
    558)
    at weblogic.servlet.internal.WebService.preloadServle ts(WebService.java:
    450)
    at weblogic.t3.srvr.ServletInitRunner.run(ServletInit Runner.java:49)
    at java.lang.Thread.run(Thread.java:484)
    >
    javax.servlet.ServletException: Servlet class: 'org.springframework.web.context.
    ContextLoaderServlet' could not be handled by the ClassLoader
    at weblogic.servlet.internal.ServletStubImpl.prepareS ervlet(ServletStubI
    mpl.java:637)
    at weblogic.servlet.internal.WebAppServletContext.pre loadServlet(WebAppS
    ervletContext.java:2360)
    at weblogic.servlet.internal.WebAppServletContext.pre loadServlets(WebApp
    ServletContext.java:2301)
    at weblogic.servlet.internal.HttpServer.preloadServle ts(HttpServer.java:
    558)
    at weblogic.servlet.internal.WebService.preloadServle ts(WebService.java:
    450)
    at weblogic.t3.srvr.ServletInitRunner.run(ServletInit Runner.java:49)
    at java.lang.Thread.run(Thread.java:484)
    =============== Initializing Logger ======================
    <9/12/2004 09:30:43 AM PST> <Notice> <WebLogicServer> <ListenThread listening on
    port 7501>
    <9/12/2004 09:30:44 AM PST> <Notice> <WebLogicServer> <Started WebLogic Admin Se
    rver "portalServer" for domain "portalDomain" running in Production Mode>
    ---------------END OF STACKTRACE WHEN STARTING UP--------------------->

    I want to clearly state that the code I am "testing" now is by no means mine, I am just checking that the ContextLoaderListener works fine: it doesn't... :roll:

    Do you have any other suggestion?

    Thanks in advance,

    Carlos Morales

  4. #4
    Join Date
    Aug 2004
    Location
    Auburn, AL, USA.
    Posts
    106

    Default

    I am not sure. I just took a look at the source (http://cvs.sourceforge.net/viewcvs.p...mework/spring/) and AbstractResource being abstract does not implement the getDescription() method - so it should force any concrete classes that extend it to implement this method. AbstractResource does make heavy use of the getDescription() method.

    First I would suspect some sort of classpath issue. Second, is the code using any sort of reflection? That might allow it to compile without being correct. Aside from those, it is something that someone with more experience w/ Spring, or perhapse with WebLogic will have to answer.

  5. #5
    Join Date
    Aug 2004
    Location
    Birmingham, UK
    Posts
    18

    Default

    Sorry no solution, but,

    Code:
    java.lang.NoSuchMethodError&#58; org.springframework.core.io.AbstractResource&#58; metho 
    d getDescription&#40;&#41;Ljava/lang/String; not found 
    at java.lang.String.valueOf&#40;String.java&#58;1947&#41;
    seem to run into this error on a Hibernate + Spring project when running JUnit tests from Ant within Eclipse. Unit tests run fine when run directly from Eclipse JUnit plugin. Could this possibly have something to do with a jar conflict?

  6. #6
    Join Date
    Dec 2004
    Location
    MEXICO
    Posts
    11

    Default

    Quote Originally Posted by rrsIPOV
    I am not sure. I just took a look at the source (http://cvs.sourceforge.net/viewcvs.p...mework/spring/) and AbstractResource being abstract does not implement the getDescription() method - so it should force any concrete classes that extend it to implement this method. AbstractResource does make heavy use of the getDescription() method.

    First I would suspect some sort of classpath issue. Second, is the code using any sort of reflection? That might allow it to compile without being correct. Aside from those, it is something that someone with more experience w/ Spring, or perhapse with WebLogic will have to answer.
    Hi, thanks for your attention.
    I assume you are questioning about the "reflection" with the Spring Framework. I am using the JAR files in the "dist" directory of the spring-framework-1.1.2. Actually I didn't develop anything at all. I just tried to configure the ContextLoaderServlet and the ContextLoaderListener (in the web.xml file) but I get always the same error.

    Thanks again,

    Carlos Morales

Similar Threads

  1. Replies: 4
    Last Post: May 11th, 2012, 08:34 AM
  2. Spring JDBC for unit tests?
    By amkush in forum Data
    Replies: 7
    Last Post: Aug 20th, 2008, 02:29 PM
  3. Replies: 2
    Last Post: Oct 24th, 2005, 09:41 AM
  4. stale Oracle processes
    By compostellas in forum Data
    Replies: 7
    Last Post: Jun 27th, 2005, 12:14 PM
  5. Replies: 3
    Last Post: Dec 9th, 2004, 04:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •