facebook

Datasource binding problem

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #226350 Reply

    – System Setup ——————————-
    Operating System and version: WindowsXP SP2
    Eclipse version: 3.0.1
    Eclipse build id: 200409161125
    Fresh Eclipse install (y/n): y
    If not, was it upgraded to its current version using the update manager?
    Other installed external plugins:
    com.ibm.etools.projectinterchange_1.0.0.2
    com.objfac.xmleditor_2.0.10
    com.sysdeo.eclipse.tomcat_3.0.0
    kpdo.ec;ipse_2.1.0
    org.junit_3.8.1
    Number of plugins in the <eclipse>/plugins directory that begin with org.eclipse.pde.*: 8
    MyEclipse version: 3.8.3
    Eclipse JDK version: j2sdk1.4.2_06
    Application Server JDK version: j2sdk1.4.2_06
    Are there any exceptions in the Eclipse log file ? no

    If this is a DB related question please answer the following:

    RDBMS vendor and version: MySQL 4.1
    JDBC driver vendor and version, and access type (thin, type-2, etc): com.mysql.jdbc.Driver
    Connection URL: jdbc:mysql://localhost:3306/libraryweb3
    Eclipse error logs related to com.genuitec.eclipse.sqlexplorer packages: cant find any

    – Message Body ——————————-
    I am trying to develop a small teaching example based upon the oft-used Library application and comprising a Struts project, a Session EJB used as a Businesss Delegate (CRUD and Borrow and Return functions) and a Hibernate O/R mapping to a MySql database. Deployed to JBoss 4, my example works ok when the Business Delegate is a POJO but not when I substitute a Session Bean (and its Transaction Management) for the POJO. It would appear that my datasource is not being bound to the MyEclipse JNDI service. I would be grateful for any help. [Note. My understanding of the JNDI Service is very limited. Also, I am not using an Enterprise Application Project.]

    The deployment descriptors are shown below with my manual additions surrounded by double quotes. [Note. The additions have been copied by me from a non-Genuitec tutorial example which employed a Session EJB and Hibernate but not with the MyEclipse IDE support.]

    [hibernate,cfg.xml]
    <hibernate-configuration>
    <session-factory>
    <!– properties –>
    <property name=”connection.username”>root</property>
    <property name=”connection.url”>jdbc:mysql://localhost:3306/libraryweb3</property>
    <property name=”dialect”>net.sf.hibernate.dialect.MySQLDialect</property>
    <property name=”connection.password”>p088502z</property>
    <property name=”connection.driver_class”>com.mysql.jdbc.Driver</property>
    “<property name=”connection.datasource”>java:/MySqlDS</property>
    <property name=”transaction.manager_lookup_class”>
    net.sf.hibernate.transaction.JBossTransactionManagerLookup</property>
    <property name=”transaction.factory.class”>
    net.sf.hibernate.transaction.JTATransactionFactory</property>”

    <!– mapping files –>
    <mapping resource=”de/laliluna/library/Book.hbm.xml”/>
    <mapping resource=”de/laliluna/library/Customer.hbm.xml”/>
    </session-factory>
    </hibernate-configuration>

    [ejb-jar.xml]
    <ejb-jar>
    <description><![CDATA[No Description.]]></description>
    <display-name>Generated by XDoclet</display-name>
    <enterprise-beans>
    <session >
    <description><![CDATA[Description for MyLibrary]]></description>
    <display-name>Name for MyLibrary</display-name>
    <ejb-name>MyLibrary</ejb-name>
    <home>mylibrary.interfaces.MyLibraryHome</home>
    <remote>mylibrary.interfaces.MyLibrary</remote>
    <ejb-class>mylibrary.ejb.MyLibrarySession</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    </enterprise-beans
    <assembly-descriptor>
    “<container-transaction>
    <method>
    <ejb-name>MyLibrary</ejb-name>
    <method-name>*</method-name>
    </method>
    <trans-attribute>RequiresNew</trans-attribute>
    </container-transaction>”
    </assembly-descriptor>
    </ejb-jar>

    [jboss.xml]
    <jboss>
    <enterprise-beans>
    <session>
    <ejb-name>MyLibrary</ejb-name>
    <jndi-name>/ejb/MyLibraryHome</jndi-name>
    <method-attributes>
    </method-attributes>
    </session>
    </enterprise-beans>

    <resource-managers>
    </resource-managers>
    </jboss>

    [mysql-ds.xml]
    <datasources>
    <local-tx-datasource>
    “<jndi-name>MySqlDS</jndi-name>
    <connection-url>jdbc:mysql://localhost:3306/libraryweb3</connection-url>
    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <user-name>root</user-name>

    <!– corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) –>
    <metadata>
    <type-mapping>mySQL</type-mapping>
    </metadata>
    </local-tx-datasource>
    </datasources>

    In the Struts Action subclass, the relevant code snippet for the Session EJB is
    .
    .
    .
    try {
    InitialContext context = new InitialContext();
    MyLibraryHome libraryHome = (MyLibraryHome) context.lookup(MyLibraryHome.JNDI_NAME);
    MyLibrary library = libraryHome.create();
    //LibraryManager libraryManager = new LibraryManager();
    bookListForm.setBooks(library.getAllBooks());
    }
    .
    .
    .
    The code fails when the getAllBooks() method is called with the following exception stack traces.

    javax.naming.NameNotFoundException: MySqlDS not bound
    at org.jnp.server.NamingServer.getBinding(NamingServer.java:490)
    at org.jnp.server.NamingServer.getBinding(NamingServer.java:498)
    at org.jnp.server.NamingServer.getObject(NamingServer.java:504)
    at org.jnp.server.NamingServer.lookup(NamingServer.java:277)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:544)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:520)
    at javax.naming.InitialContext.lookup(InitialContext.java:347)
    at net.sf.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:44)
    at net.sf.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:83)
    at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:65)
    at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1155)
    at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:789)
    at de.laliluna.library.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:51)
    at mylibrary.ejb.MyLibraryBean.getAllBooks(MyLibraryBean.java:109)
    etc.
    10:56:25,987 INFO [STDOUT] %%%% Error Creating SessionFactory %%%%

    10:56:26,081 INFO [STDOUT] net.sf.hibernate.HibernateException: Could not find datasource
    at net.sf.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:48)
    at net.sf.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:83)
    at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:65)
    at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1155)
    at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:789)
    at de.laliluna.library.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:51)
    at mylibrary.ejb.MyLibraryBean.getAllBooks(MyLibraryBean.java:109)
    etc.
    Caused by: javax.naming.NameNotFoundException: MySqlDS not bound
    at org.jnp.server.NamingServer.getBinding(NamingServer.java:490)
    at org.jnp.server.NamingServer.getBinding(NamingServer.java:498)
    at org.jnp.server.NamingServer.getObject(NamingServer.java:504)
    at org.jnp.server.NamingServer.lookup(NamingServer.java:277)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:544)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:520)
    at javax.naming.InitialContext.lookup(InitialContext.java:347)
    at net.sf.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:44)
    … 81 more

    11:00:03,581 WARN [TransactionImpl] Transaction TransactionImpl:XidImpl[FormatId=257, GlobalId=myworkstation1/15, BranchQual=, localId=15] timed out. status=STATUS_ACTIVE

    #226359 Reply

    Riyad Kalla
    Member

    I am researching this…

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Datasource binding problem

You must be logged in to post in the forum log in