facebook

How to bind factory to JNDI

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

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

    hellodharen
    Member

    i have developed hibernate project..
    when i try to run the TestCase.jave file, it shows error..like this
    can u give appect sugeesion to me
    ***************************************************************************
    init:
    deps-module-jar:
    deps-ear-jar:
    deps-jar:
    compile-single:
    run-main:
    14:46:03,296 INFO Environment:479 – Hibernate 3.1.2
    14:46:03,312 INFO Environment:509 – hibernate.properties not found
    14:46:03,312 INFO Environment:525 – using CGLIB reflection optimizer
    14:46:03,328 INFO Environment:555 – using JDK 1.4 java.sql.Timestamp handling
    14:46:03,421 INFO Configuration:1308 – configuring from resource: /hibernate.cfg.xml
    14:46:03,421 INFO Configuration:1285 – Configuration resource: /hibernate.cfg.xml
    14:46:03,765 INFO Configuration:469 – Reading mappings from resource: com/mirchmarket/model/beans/HContactUs.hbm.xml
    14:46:03,937 INFO HbmBinder:309 – Mapping class: com.mirchmarket.model.beans.HContactUs -> h_contact_us
    14:46:03,953 INFO Configuration:1419 – Configured SessionFactory: java:hibernate/SessionFactory
    14:46:04,046 INFO C3P0ConnectionProvider:50 – C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://192.168.1.5:3306/mirchmarket
    14:46:04,046 INFO C3P0ConnectionProvider:51 – Connection properties: {user=admin, password=****}
    14:46:04,046 INFO C3P0ConnectionProvider:54 – autocommit mode: false
    14:46:04,859 INFO SettingsFactory:77 – RDBMS: MySQL, version: 4.1.11
    14:46:04,859 INFO SettingsFactory:78 – JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.12 ( $Date: 2005-11-17 15:53:48 +0100 (Thu, 17 Nov 2005) $, $Revision$ )
    14:46:04,906 INFO Dialect:103 – Using dialect: org.hibernate.dialect.MySQLDialect
    14:46:04,921 INFO TransactionFactoryFactory:31 – Using default transaction strategy (direct JDBC transactions)
    14:46:04,921 INFO TransactionManagerLookupFactory:33 – No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
    14:46:04,921 INFO SettingsFactory:125 – Automatic flush during beforeCompletion(): disabled
    14:46:04,921 INFO SettingsFactory:129 – Automatic session close at end of transaction: disabled
    14:46:04,921 INFO SettingsFactory:136 – JDBC batch size: 15
    14:46:04,921 INFO SettingsFactory:139 – JDBC batch updates for versioned data: disabled
    14:46:04,921 INFO SettingsFactory:144 – Scrollable result sets: enabled
    14:46:04,921 INFO SettingsFactory:152 – JDBC3 getGeneratedKeys(): enabled
    14:46:04,921 INFO SettingsFactory:160 – Connection release mode: auto
    14:46:04,937 INFO SettingsFactory:178 – Default schema: mirchmarket
    14:46:04,937 INFO SettingsFactory:184 – Maximum outer join fetch depth: 2
    14:46:04,937 INFO SettingsFactory:187 – Default batch fetch size: 1
    14:46:04,937 INFO SettingsFactory:191 – Generate SQL with comments: disabled
    14:46:04,937 INFO SettingsFactory:195 – Order SQL updates by primary key: disabled
    14:46:04,937 INFO SettingsFactory:338 – Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
    14:46:04,937 INFO ASTQueryTranslatorFactory:24 – Using ASTQueryTranslatorFactory
    14:46:04,937 INFO SettingsFactory:203 – Query language substitutions: {}
    14:46:04,937 INFO SettingsFactory:209 – Second-level cache: enabled
    14:46:04,937 INFO SettingsFactory:213 – Query cache: disabled
    14:46:04,937 INFO SettingsFactory:325 – Cache provider: org.hibernate.cache.NoCacheProvider
    14:46:04,937 INFO SettingsFactory:228 – Optimize cache for minimal puts: disabled
    14:46:04,937 INFO SettingsFactory:237 – Structured second-level cache entries: disabled
    14:46:04,953 INFO SettingsFactory:257 – Echoing all SQL to stdout
    14:46:04,953 INFO SettingsFactory:264 – Statistics: disabled
    14:46:04,953 INFO SettingsFactory:268 – Deleted entity synthetic identifier rollback: disabled
    14:46:04,953 INFO SettingsFactory:283 – Default entity-mode: pojo
    14:46:05,031 INFO SessionFactoryImpl:153 – building session factory
    14:46:05,484 INFO SessionFactoryObjectFactory:86 – Factory name: java:hibernate/SessionFactory
    14:46:05,484 INFO NamingHelper:26 – JNDI InitialContext properties:{}
    14:46:05,500 WARN SessionFactoryObjectFactory:98 – Could not bind factory to JNDI
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
    at javax.naming.InitialContext.getNameParser(InitialContext.java:439)
    at org.hibernate.util.NamingHelper.bind(NamingHelper.java:52)
    at org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:90)
    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:290)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
    at com.mirchmarket.junit.actions.MirchJobsTestCase.main(MirchJobsTestCase.java:28)
    14:46:05,500 INFO SchemaUpdate:114 – Running hbm2ddl schema update
    14:46:05,500 INFO SchemaUpdate:126 – fetching database metadata
    14:46:05,500 INFO SchemaUpdate:142 – updating schema
    14:46:05,531 INFO DatabaseMetadata:91 – table not found: h_contact_us
    14:46:05,531 INFO DatabaseMetadata:91 – table not found: h_contact_us
    14:46:05,531 DEBUG SchemaUpdate:151 – create table mirchmarket.mirchmarket.h_contact_us (ID_CONTACT_US bigint not null, ID_SERVICE bigint, TS_SERVICE date not null, TS_CONTACT date, TX_COMMENTS text, IN_REGISTERED char(1), ID_VERTICAL bigint not null, ID_USR bigint not null, NM_CONTACT varchar(40), ID_EMAIL_CONTACT varchar(30), TX_PHONE_CONTACT varchar(30), primary key (ID_CONTACT_US))
    14:46:07,109 ERROR SchemaUpdate:157 – Unsuccessful: create table mirchmarket.mirchmarket.h_contact_us (ID_CONTACT_US bigint not null, ID_SERVICE bigint, TS_SERVICE date not null, TS_CONTACT date, TX_COMMENTS text, IN_REGISTERED char(1), ID_VERTICAL bigint not null, ID_USR bigint not null, NM_CONTACT varchar(40), ID_EMAIL_CONTACT varchar(30), TX_PHONE_CONTACT varchar(30), primary key (ID_CONTACT_US))
    14:46:07,109 ERROR SchemaUpdate:158 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘.h_contact_us (ID_CONTACT_US bigint not null, ID_SERVICE bigint, TS_SERVICE date’ at line 1
    14:46:07,109 INFO SchemaUpdate:162 – schema update complete
    14:46:07,578 ERROR HContactUsHome:33 – Could not locate SessionFactory in JNDI
    Exception in thread “main” java.lang.IllegalStateException: Could not locate SessionFactory in JNDI
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
    at com.mirchmarket.model.beans.HContactUsHome.getSessionFactory(HContactUsHome.java:34)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
    at javax.naming.InitialContext.lookup(InitialContext.java:351)
    at com.mirchmarket.model.beans.HContactUsHome.getSessionFactory(HContactUsHome.java:30)
    at com.mirchmarket.model.beans.HContactUsHome.<init>(HContactUsHome.java:25)
    at com.mirchmarket.junit.actions.MirchJobsTestCase.main(MirchJobsTestCase.java:31)
    at com.mirchmarket.model.beans.HContactUsHome.<init>(HContactUsHome.java:25)
    at com.mirchmarket.junit.actions.MirchJobsTestCase.main(MirchJobsTestCase.java:31)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 8 seconds)
    ***************************************************************************

    #249987

    Haris Peco
    Member

    hellodharen ,

    You have to create JNDI datasource in your application server (JBoss or similar, tomcat can’t export JNDi out of own JVM)
    It is better that you make standalone hibernate.cfg (MyEclipse connection profile or simple jdbc datastore) for test only

    Best

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: How to bind factory to JNDI

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