5 Replies Latest reply on Apr 9, 2013 12:44 AM by sfcoy

    Accessing DataSource configured in JBOSS 7..urgent!

    amitmehra23

      Hi ,

       

      I have configured a datasource in my JBoss AS 7 as a "module" as a JNDI name  java:jboss/ScoringEngineDS as seen below:

       

      jbossDS.jpg

       

      This server is in my local machine. This points to a MySQL database driver which is also present in same local machine.

       

      i made entry in the " persistence.xml" of my application as show below :

      persistence.jpg

       

      the war of my application gets deployed successfully on the server. But when i am trying to run my application(a web service) it throws me this exception :

       

      SEVERE: Could not find datasource: java:jboss/ScoringEngineDS

      javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]

        at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1319)

        at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1448)

        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:596)

        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:589)

        at javax.naming.InitialContext.lookup(Unknown Source)

        at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:75)

        at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:143)

        at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:51)

          ...

      Caused by: java.net.SocketTimeoutException: Receive timed out

        at java.net.PlainDatagramSocketImpl.receive0(Native Method)

        at java.net.PlainDatagramSocketImpl.receive(Unknown Source)

        at java.net.DatagramSocket.receive(Unknown Source)

        at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1289)

        ... 46 more

      INFO: Building entityManagerFactory failed.javax.persistence.PersistenceException: [PersistenceUnit: ScoringEnginePersistenceUnit] Unable to build EntityManagerFactory

       

      I am creating a EntityManagerFactory using the PersistenceUnit defined in persistence.xml

      Where am going wrong? What is the correct way to connect to such a datasource?

       

      I also added a "jndi.properties" files to my classpath containing :

      #jboss JNDI properties

      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory

      java.naming.factory.url.pkgs=org.jnp.interfaces

       

      if i add : java.naming.provider.url=jnp://localhost:1099 , it is throwing me another exception on this.

       

      Kindly provide your inputs on this..its urgent!!!

       

      Thanks,

      Amit M