PDA

View Full Version : NameNotFoundException



jasonwilliams
Sep 8th, 2004, 02:18 AM
hi, mavens:
i'm new to springframeowrk. lately i download an open source software, which makes use of spring and hibernate. however, when deploying to tomcat (5.0.27). it issues EXCEPTION like A.) why may cause this problem.
Or where there's resource explaining such configuration.
i appreciate it, sincerely.
jason
p.s.: the configuration that exception complains would be Exception B.)


=================EXCEPTION A) ================BEG
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean wit
h name 'hibernateProperties' defined in class path resource [applicationContext-
oness-common-model-dataSource-jndi.xml]: Can't resolve reference to bean 'hibern
ateDialect' while setting property 'hibernateDialect'; nested exception is org.s
pringframework.beans.factory.BeanCreationException : Error creating bean with nam
e 'hibernateDialect' defined in class path resource [applicationContext-oness-co
mmon-model-dataSource-jndi.xml]: Initialization of bean failed; nested exception
is javax.naming.NameNotFoundException: Name net.sf.oness.common.model.hibernate
Dialect is not bound in this Context
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean wit
h name 'hibernateDialect' defined in class path resource [applicationContext-one
ss-common-model-dataSource-jndi.xml]: Initialization of bean failed; nested exce
ption is javax.naming.NameNotFoundException: Name net.sf.oness.common.model.hibe
rnateDialect is not bound in this Context
javax.naming.NameNotFoundException: Name net.sf.oness.common.model.hibernateDial
ect is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingConte xt.java:768)
at org.apache.naming.NamingContext.lookup(NamingConte xt.java:138)
at org.apache.naming.NamingContext.lookup(NamingConte xt.java:779)
at org.apache.naming.NamingContext.lookup(NamingConte xt.java:138)
at org.apache.naming.NamingContext.lookup(NamingConte xt.java:779)
at org.apache.naming.NamingContext.lookup(NamingConte xt.java:151)
at org.apache.naming.SelectorContext.lookup(SelectorC ontext.java:136)
at javax.naming.InitialContext.lookup(InitialContext. java:347)
at org.springframework.jndi.JndiTemplate$1.doInContex t(JndiTemplate.java
:120)
at org.springframework.jndi.JndiTemplate.execute(Jndi Template.java:85)
at org.springframework.jndi.JndiTemplate.lookup(JndiT emplate.java:117)
at org.springframework.jndi.AbstractJndiLocator.looku p(AbstractJndiLocat
or.java:169)
at org.springframework.jndi.AbstractJndiLocator.after PropertiesSet(Abstr
actJndiLocator.java:164)
at org.springframework.beans.factory.support.Abstract AutowireCapableBean
Factory.invokeInitMethods(AbstractAutowireCapableB eanFactory.java:718)
at org.springframework.beans.factory.support.Abstract AutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFact ory.java:213)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean
(AbstractBeanFactory.java:159)
at org.springframework.beans.factory.support.Abstract AutowireCapableBean
Factory.resolveReference(AbstractAutowireCapableBe anFactory.java:658)
at org.springframework.beans.factory.support.Abstract AutowireCapableBean
Factory.resolveValueIfNecessary(AbstractAutowireCa pableBeanFactory.java:626)
at org.springframework.beans.factory.support.Abstract AutowireCapableBean
Factory.applyPropertyValues(AbstractAutowireCapabl eBeanFactory.java:564)
at org.springframework.beans.factory.support.Abstract AutowireCapableBean
Factory.populateBean(AbstractAutowireCapableBeanFa ctory.java:419)
at org.springframework.beans.factory.support.Abstract AutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFact ory.java:195)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean
(AbstractBeanFactory.java:159)
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactor y.java:178)
at org.springframework.context.support.AbstractApplic ationContext.refres
h(AbstractApplicationContext.java:272)
at org.springframework.web.context.support.XmlWebAppl icationContext.refr
esh(XmlWebApplicationContext.java:131)
at org.springframework.web.context.ContextLoader.crea teWebApplicationCon
text(ContextLoader.java:154)
at org.springframework.web.context.ContextLoader.init WebApplicationConte
xt(ContextLoader.java:95)
at org.springframework.web.context.ContextLoaderListe ner.contextInitiali
zed(ContextLoaderListener.java:48)
at org.apache.catalina.core.StandardContext.listenerS tart(StandardContex
t.java:3827)
at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4
343)
at org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase
.java:823)
at org.apache.catalina.core.ContainerBase.addChild(Co ntainerBase.java:80
7)
at org.apache.catalina.core.StandardHost.addChild(Sta ndardHost.java:595)

at org.apache.catalina.core.StandardHostDeployer.inst all(StandardHostDep
loyer.java:277)
at org.apache.catalina.core.StandardHost.install(Stan dardHost.java:832)
at org.apache.catalina.startup.HostConfig.deployWARs( HostConfig.java:617
)
at org.apache.catalina.startup.HostConfig.deployApps( HostConfig.java:431
)
at org.apache.catalina.startup.HostConfig.start(HostC onfig.java:968)
at org.apache.catalina.startup.HostConfig.lifecycleEv ent(HostConfig.java
:349)
at org.apache.catalina.util.LifecycleSupport.fireLife cycleEvent(Lifecycl
eSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1091)

at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:789)
at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1083)

at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:478
)
at org.apache.catalina.core.StandardService.start(Sta ndardService.java:4
80)
at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:231
3)
at org.apache.catalina.startup.Catalina.start(Catalin a.java:556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:284)
at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:422)

=================EXCEPTION A) ================END

=================EXCEPTION B) ================BEG
...
<!-- Hibernate Dialect -->
<bean id="hibernateDialect" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/net.sf.oness.common.model.hibernateDialect</value>
</property>
</bean>
...
=================EXCEPTION B) ================BEG

robh
Sep 8th, 2004, 11:08 AM
The problem here seems to be that the hibernate dialect object is bound to the JNDI name java:comp/env/net.sf.oness.common.model.hibernateDialect. You should check your JNDI tree to ensure that this object is bound.

Rob

Ben Alex
Sep 8th, 2004, 05:10 PM
Try reading the section entitled "JNDI Configuration" at http://oness.sourceforge.net/installing.html.

jasonwilliams
Sep 9th, 2004, 03:54 AM
Try reading the section entitled "JNDI Configuration" at http://oness.sourceforge.net/installing.html.
That's why I'm confused. Because, after modifying tomcat-context.xml, located in the WEB_INF, via setting up underlying properties, including driverClass, id/passwd, url, etc., it still issues the same exception; even though I modify datasource.properties, the error result is still the same. I'm not very familiar with springframework, therefore this problem may be minor to mavens, but I appreciate your help, sincerely.
Jason
==========tomcat-context.xml==========BEG
<!-- MySQL dB username and password for dB connections -->
<parameter>
<name>username</name>
<value>test</value>
</parameter>
<parameter>
<name>password</name>
<value>test</value>
</parameter>
<!-- Class name for JDBC driver -->
<parameter>
<name>driverClassName</name>
<value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
</parameter>
<!-- Autocommit setting. This setting is required to make
Hibernate work. Or you can remove calls to commit(). -->
<parameter>
<name>defaultAutoCommit</name>
<value>false</value>
</parameter>
<!-- The JDBC connection url for connecting to your MySQL dB.
The autoReconnect=true argument to the url makes sure that the
mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
connection. mysqld by default closes idle connections after 8 hours.
-->
<parameter>
<name>url</name>
<value>jdbc:microsoft:sqlserver://localhost:1433;databaseName=oness;SelectMethod=cur sor</value>
</parameter>
==================tomcat-context.xml==========END

==========datasoource.properties===========BEG
hibernate.show_sql=false
hibernate.hbm2ddl.auto=create

# If you want to use postgres
dataSource.username=test
dataSource.password=test
dataSource.url=jdbc:microsoft:sqlserver://localhost:1433;databaseName=oness;SelectMethod=cur sor
dataSource.driverClassName=com.microsoft.jdbc.sqls erver.SQLServerDriver
hibernate.dialect=net.sf.hibernate.dialect.SybaseD ialect
==========datasoource.properties===========END

carlos
Sep 9th, 2004, 05:48 AM
As it's a ONess related question I'd be very pleased to answer further questions in the ONess mailing list.

You have to choose between JNDI or local configuration. If you use JNDI (default) the datasource.properties is ignored.

Check this file
http://cvs.sourceforge.net/viewcvs.py/oness/party/webapp/src/conf/tomcat-context.xml?view=markup

and read the doc on top


To setup this context copy this file to the specified
directory and change it to match your needs.
You may rename it if you want.

o Tomcat 4&#58; TOMCAT_HOME/webapps
o Tomcat 5&#58; TOMCAT_HOME/conf/Catalina/localhost

and ensure the environment name net.sf.oness.common.model.hibernateDialect has the correct values


<Environment description="Hibernate dialect"
name="net.sf.oness.common.model.hibernateDialect"
value="net.sf.hibernate.dialect.MySQLDialect"
type="java.lang.String"/>

jasonwilliams
Sep 9th, 2004, 09:18 PM
Thanks your help, Carlos. The problem now has been solved. The tomcat-context.xml have to be put in "$TOMCAT_HOME_V5/conf/Catalina/localhost/"; it should work.
I appreciate your help, sincerely.
jason
ps: but it seems failed still in tomcat 4.1.30, if the tomcat-context.xml still located in the $TOMCAT_HOME_v4/webapps/$ONESS/WEB-INF/classes/.


As it's a ONess related question I'd be very pleased to answer further questions in the ONess mailing list.

You have to choose between JNDI or local configuration. If you use JNDI (default) the datasource.properties is ignored.

Check this file
http://cvs.sourceforge.net/viewcvs.py/oness/party/webapp/src/conf/tomcat-context.xml?view=markup

and read the doc on top


To setup this context copy this file to the specified
directory and change it to match your needs.
You may rename it if you want.

o Tomcat 4&#58; TOMCAT_HOME/webapps
o Tomcat 5&#58; TOMCAT_HOME/conf/Catalina/localhost

and ensure the environment name net.sf.oness.common.model.hibernateDialect has the correct values


<Environment description="Hibernate dialect"
name="net.sf.oness.common.model.hibernateDialect"
value="net.sf.hibernate.dialect.MySQLDialect"
type="java.lang.String"/>

carlos
Sep 10th, 2004, 02:58 AM
ps: but it seems failed still in tomcat 4.1.30, if the tomcat-context.xml still located in the $TOMCAT_HOME_v4/webapps/$ONESS/WEB-INF/classes/.
Because it has to be in $TOMCAT_HOME_v4/webapps as you can see in the doc