无法在Glassfish中为h2数据库创建连接池和数据源

时间:2012-04-05 17:29:38

标签: java java-ee glassfish h2

这是我的glassfish-resources.xml:

    <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
  <jdbc-connection-pool res-type="javax.sql.DataSource"
datasource-classname="org.h2.jdbcx.JdbcDataSource"
pool-resize-quantity="1" max-pool-size="5" steady-pool-size="0"
statement-timeout-in-seconds="60" name="jdbc/test_pool">
    <property name="driverClass" value="org.h2.Driver"/>
    <property name="URL" value="jdbc:h2:D:\test\test;IFEXISTS=TRUE;AUTO_SERVER=TRUE"/>
    <property name="User" value="root"/>
    <property name="Password" value="root"/>
  </jdbc-connection-pool>
  <jdbc-resource object-type="system-all" enabled="true" jndi-name="jdbc/test" pool-name="jdbc/test_pool" />
</resources>

使用 maven glassfish插件通过m2eclipse将战争部署到服务器后,当我执行asadmin> list-jdbc-connection-pools时,我的连接池不在列表中。我真的迷失了

修改

asadmin add-resources

出于某种原因正常工作

Glassfish 3.1.2(build 23)

的pom.xml:

    <dependency>
                <groupId>org.glassfish</groupId>
                <artifactId>maven-embedded-glassfish-plugin</artifactId>
                <version>3.1.1</version>
                <type>maven-plugin</type>
            </dependency>

<plugin>
                <groupId>org.glassfish.maven.plugin</groupId>
                <artifactId>maven-glassfish-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <glassfishDirectory>d:\glassfish3</glassfishDirectory>
                    <user>admin</user>
                    <passwordFile>d:\password.txt</passwordFile>
                    <debug>true</debug>
                    <echo>true</echo>
                    <domain>
                        <name>domain1</name>
                        <adminPort>4848</adminPort> <!-- mandatory for mvn glassfish:deploy -->
                    </domain>
                    <components>
                        <component>
                            <name>${project.artifactId}</name>
                            <artifact>${project.build.directory}/${project.build.finalName}.war</artifact>
                        </component>
                    </components>
                </configuration>
            </plugin>

EDIT2 问题解决了。谢谢大家!!!

1 个答案:

答案 0 :(得分:0)

尝试直接从管理控制台添加连接池。然后 ping 以查看是否正在收听。