Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring/hibernate configuration error
    primarykey
    data
    text
    <p>I'm new at Java Spring and Hibernate and I'm trying to build an application with those technologies (Maven, Spring and Hibernate). When I try to run it I receive an error from the glassfish server, It's a very long stacktrace, but this is the last part: </p> <pre><code>Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: javax.naming.NameNotFoundException: CentricJavaDB not found </code></pre> <p>I'm trying things out for hours but I don't find my mistake. I'm pretty sure it's in a configuration xml file but I can't fix it. I hope some of u guys can help me (:</p> <p>The configuration files: </p> <p>Dispatcher servlet in the WEB-INF folder:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd"&gt; &lt;mvc:annotation-driven /&gt; &lt;context:component-scan base-package="controllers"/&gt; &lt;context:component-scan base-package="service"/&gt; &lt;bean name = "klantDao" class="service.JpaKlantDao"/&gt; &lt;jee:jndi-lookup id="dataSource" jndi-name="jdbc/CentricJavaDB"/&gt; &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt; &lt;property name="dataSource" ref="dataSource" /&gt; &lt;property name="packagesToScan"&gt; &lt;list&gt; &lt;value&gt;domain&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;property name="jpaVendorAdapter"&gt; &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt; &lt;property name="showSql" value="true" /&gt; &lt;property name="generateDdl" value="true" /&gt; &lt;/bean&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="transactionManager" class=" org.springframework.orm.jpa.JpaTransactionManager "&gt; &lt;constructor-arg ref="entityManagerFactory" /&gt; &lt;/bean&gt; &lt;tx:annotation-driven transaction-manager="transactionManager"/&gt; &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" /&gt; &lt;/beans&gt; </code></pre> <p>glassfish-web.xml in WEB-INF:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd"&gt; &lt;glassfish-web-app&gt; &lt;Resource name="jdbc/CentricJavaDB" auth="Container" driverClassName="com.mysql.jdbc.Driver" username="root" password="root" type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/centricjavadb" /&gt; &lt;/glassfish-web-app&gt; </code></pre> <p>I also found this file "Other Sources\Setup\glassfish-resources.xml". I don't see big differences with "glassfish-web.xml" but it also contains database information. I think it also could be important:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd"&gt; &lt;resources&gt; &lt;jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="jdbc/CentricJavaDB" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" jndi-name="jdbc/CentricJavaDB" wrap-jdbc-objects="false"&gt; &lt;property name="serverName" value="localhost"/&gt; &lt;property name="portNumber" value="3306"/&gt; &lt;property name="databaseName" value="centricjavadb"/&gt; &lt;property name="User" value="root"/&gt; &lt;property name="Password" value="root"/&gt; &lt;property name="URL" value="jdbc:mysql://localhost:3306/centricjavadb"/&gt; &lt;property name="driverClass" value="com.mysql.jdbc.Driver"/&gt; &lt;/jdbc-connection-pool&gt; &lt;/resources&gt; </code></pre> <p>I think the error is caused because of the jndi-lookup can't find the datasource in glassfish-web.xml, but correct me if I'm wrong.</p> <p>I think this should be enough information. If you want more files, stacktraces or whatever, just ask and I will post it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload