5 Replies Latest reply on Nov 21, 2008 11:46 AM by Alec Brecher

    mdb can use datasource but servlet cannot

    Alec Brecher Newbie

      I have struggled with a situation where a message driven bean is able to connect to a datasource using the jndi name: java:/actn_shw but a servlet in the same ear cannot find the same datasource. Any suggestions would be greatly appreciated.

      No NamingException is thrown when the datasource is retrieved from the initial context but the DataSource is null.


      jboss AS 4.2.0 default server

      2008-11-19 11:05:22,258 INFO [org.jboss.resource.connectionmanager.ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=actn_shw' to JNDI name 'java:actn_shw'

      -ds.xml:
      <local-tx-datasource>
      <jndi-name>actn_shw</jndi-name>
      <connection-url>jdbc:postgresql://dbhost:5432/shw</connection-url>
      <driver-class>org.postgresql.Driver</driver-class>
      ...

      web.xml:
      <resource-ref>
      <res-ref-name>jdbc/actn_shw</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>

      jboss-web.xml:
      <resource-ref>
      <res-ref-name>jdbc/actn_shw</res-ref-name>
      <jndi-name>java:/actn_shw</jndi-name>
      </resource-ref>

      No NamingException is thrown when the datasource is retrieved from the initial context but the DataSource is null.

        • 1. Re: mdb can use datasource but servlet cannot
          Alec Brecher Newbie

          So I looked through the NamingContextFactory Wiki - thank you for pointing that out. I used the service locator to print out the bindings from both the servlet and the bean. Both appear identical:

          from servlet:
          InitialContext().listBindings("java:/") gives:
          2008-11-19 13:58:41,024 INFO [STDOUT] actn_shw: org.jboss.resource.adapter.jdbc.WrapperDataSource:Reference Class Name: org.jboss.resource.adapter.jdbc.WrapperDataSource
          Type: nns
          Content: java:actn_shw

          and from bean:
          InitialContext().listBindings("java:/") gives:
          2008-11-19 14:05:45,015 INFO [STDOUT] actn_shw: org.jboss.resource.adapter.jdbc.WrapperDataSource:Reference Class Name: org.jboss.resource.adapter.jdbc.WrapperDataSource
          Type: nns
          Content: java:actn_shw

          I am really stuck. Assistance would be very welcome.

          • 2. Re: mdb can use datasource but servlet cannot
            jaikiran pai Master

            Are you packaging any jboss specific jar files in your application packaging?

            Please post the output of

            jar -tf myapp.ear


            and

            jar -tf myapp.war


            • 3. Re: mdb can use datasource but servlet cannot
              Alec Brecher Newbie

              Yes, it looks like jboss-common-client.jar and log4j-1.2.15.jar are both in the .war. Should they be removed? TIA. -Alec

              ear:
              META-INF/
              META-INF/MANIFEST.MF
              common.jar
              actioncenter.war
              ejb.jar
              META-INF/jboss.xml
              META-INF/application.xml


              war:
              META-INF/
              META-INF/MANIFEST.MF
              WEB-INF/
              META-INF/application.xml
              META-INF/ejb-jar.xml
              META-INF/jboss.xml
              WEB-INF/jboss-web.xml
              WEB-INF/web.xml
              actionFormUnitTest.html
              WEB-INF/classes/
              WEB-INF/classes/com/
              WEB-INF/classes/com/atomd/
              WEB-INF/classes/com/atomd/ejb/
              WEB-INF/classes/com/atomd/ejb/entities/
              WEB-INF/classes/com/atomd/ejb/servlets/
              WEB-INF/classes/com/atomd/ejb/util/
              WEB-INF/classes/com/atomd/ejb/util/beans/
              WEB-INF/classes/com/atomd/ejb/web/
              WEB-INF/classes/com/atomd/ejb/web/beans/
              WEB-INF/classes/com/atomd/ejb/web/entities/
              WEB-INF/classes/com/atomd/ejb/web/util/
              WEB-INF/classes/com/atomd/util/
              WEB-INF/classes/correcta/
              WEB-INF/classes/com/atomd/ejb/entities/Action.class
              WEB-INF/classes/com/atomd/ejb/entities/Activity.class
              WEB-INF/classes/com/atomd/ejb/entities/Address.class
              WEB-INF/classes/com/atomd/ejb/entities/AddressScore.class
              WEB-INF/classes/com/atomd/ejb/entities/Attribute.class
              WEB-INF/classes/com/atomd/ejb/entities/CandidateScore.class
              WEB-INF/classes/com/atomd/ejb/entities/DataAccessException.class
              WEB-INF/classes/com/atomd/ejb/entities/Elected.class
              WEB-INF/classes/com/atomd/ejb/entities/ElectedWebForm.class
              WEB-INF/classes/com/atomd/ejb/entities/Email.class
              WEB-INF/classes/com/atomd/ejb/entities/EmailMessage.class
              WEB-INF/classes/com/atomd/ejb/entities/Household.class
              WEB-INF/classes/com/atomd/ejb/entities/Instruction4Request.class
              WEB-INF/classes/com/atomd/ejb/entities/InvalidActionException.class
              WEB-INF/classes/com/atomd/ejb/entities/InvalidActivityException.class
              WEB-INF/classes/com/atomd/ejb/entities/InvalidAddressException.class
              WEB-INF/classes/com/atomd/ejb/entities/InvalidAttributeException.class
              WEB-INF/classes/com/atomd/ejb/entities/InvalidEmailException.class
              WEB-INF/classes/com/atomd/ejb/entities/InvalidEmailMessageException.class
              WEB-INF/classes/com/atomd/ejb/entities/InvalidEntityException.class
              WEB-INF/classes/com/atomd/ejb/entities/InvalidNameException.class
              WEB-INF/classes/com/atomd/ejb/entities/InvalidPersistenceException.class
              WEB-INF/classes/com/atomd/ejb/entities/InvalidPersonException.class
              WEB-INF/classes/com/atomd/ejb/entities/InvalidPhoneException.class
              WEB-INF/classes/com/atomd/ejb/entities/InvalidVoterException.class
              WEB-INF/classes/com/atomd/ejb/entities/MstridAddr.class
              WEB-INF/classes/com/atomd/ejb/entities/Name.class
              WEB-INF/classes/com/atomd/ejb/entities/Person.class
              WEB-INF/classes/com/atomd/ejb/entities/Phone.class
              WEB-INF/classes/com/atomd/ejb/entities/Stfid.class
              WEB-INF/classes/com/atomd/ejb/entities/Voter.class
              WEB-INF/classes/com/atomd/ejb/servlets/ActionPublisherServlet.class
              WEB-INF/classes/com/atomd/ejb/servlets/Enhancements.class
              WEB-INF/classes/com/atomd/ejb/servlets/HandleActionServlet.class
              WEB-INF/classes/com/atomd/ejb/servlets/MatchAndLoadPerson.class
              WEB-INF/classes/com/atomd/ejb/util/AddressDAO.class
              WEB-INF/classes/com/atomd/ejb/util/AddressEnhancer.class
              WEB-INF/classes/com/atomd/ejb/util/AppLogger.class
              WEB-INF/classes/com/atomd/ejb/util/ElectedDAO.class
              WEB-INF/classes/com/atomd/ejb/util/ElectedWebFormFactory.class
              WEB-INF/classes/com/atomd/ejb/util/EmailProducer.class
              WEB-INF/classes/com/atomd/ejb/util/EmailProducer4Boyden.class
              WEB-INF/classes/com/atomd/ejb/util/EmailProducer4Roads.class
              WEB-INF/classes/com/atomd/ejb/util/EmailProducer4SHW.class
              WEB-INF/classes/com/atomd/ejb/util/EmailProducer4SM.class
              WEB-INF/classes/com/atomd/ejb/util/EmailSender.class
              WEB-INF/classes/com/atomd/ejb/util/EmailSenderException.class
              WEB-INF/classes/com/atomd/ejb/util/EntitySAXEventHandler.class
              WEB-INF/classes/com/atomd/ejb/util/ExportActionData.class
              WEB-INF/classes/com/atomd/ejb/util/ExportException.class
              WEB-INF/classes/com/atomd/ejb/util/JmsProducer.class
              WEB-INF/classes/com/atomd/ejb/util/JmsProducerException.class
              WEB-INF/classes/com/atomd/ejb/util/MatchScoreKeeper.class
              WEB-INF/classes/com/atomd/ejb/util/ServiceLocator.class
              WEB-INF/classes/com/atomd/ejb/util/ServiceLocatorException.class
              WEB-INF/classes/com/atomd/ejb/util/beans/ActivityDAO.class
              WEB-INF/classes/com/atomd/ejb/util/beans/AddressDAO.class
              WEB-INF/classes/com/atomd/ejb/util/beans/AddressEnhancement.class
              WEB-INF/classes/com/atomd/ejb/util/beans/AttributeDAO.class
              WEB-INF/classes/com/atomd/ejb/util/beans/EmailDAO.class
              WEB-INF/classes/com/atomd/ejb/util/beans/NameVoterDAO.class
              WEB-INF/classes/com/atomd/ejb/util/beans/PersonDAO.class
              WEB-INF/classes/com/atomd/ejb/util/beans/PersonMatcher.class
              WEB-INF/classes/com/atomd/ejb/util/beans/PhoneDAO.class
              WEB-INF/classes/com/atomd/ejb/util/beans/VoterFileDAO.class
              WEB-INF/classes/com/atomd/ejb/util/beans/VoterFileMatcher.class
              WEB-INF/classes/com/atomd/ejb/web/beans/ActionCenterDistributorBean.class
              WEB-INF/classes/com/atomd/ejb/web/beans/ActionCenterDistributorUtil.class
              WEB-INF/classes/com/atomd/util/Format.class
              WEB-INF/classes/correcta/CorrectAddressScrubber.class
              WEB-INF/classes/correcta/Test.class
              WEB-INF/classes/correcta/javaCANativeDispatcher.class
              WEB-INF/lib/
              WEB-INF/lib/activation.jar
              WEB-INF/lib/commons-codec-1.3.jar
              WEB-INF/lib/commons-httpclient-3.1.jar
              WEB-INF/lib/commons-logging-1.1.1.jar
              WEB-INF/lib/commons-logging.jar
              WEB-INF/lib/db2jcc.jar
              WEB-INF/lib/db2jcc_javax.jar
              WEB-INF/lib/db2jcc_license_cu.jar
              WEB-INF/lib/db2policy.jar
              WEB-INF/lib/db2qgjava.jar
              WEB-INF/lib/jboss-common-client.jar
              WEB-INF/lib/log4j-1.2.15.jar
              WEB-INF/lib/mail.jar
              WEB-INF/lib/mailapi.jar
              WEB-INF/lib/pg74.216.jdbc2.jar
              WEB-INF/lib/sinetfactory.jar
              WEB-INF/lib/smtp.jar
              WEB-INF/jboss-web.xml

              • 4. Re: mdb can use datasource but servlet cannot
                jaikiran pai Master

                Yes, i would recommend removing those jars from your packaging and see how it goes. If that still does not fix your issue, let us know.

                • 5. Re: mdb can use datasource but servlet cannot
                  Alec Brecher Newbie

                  That solved the problem. Thank you!