接続プールを作成しました。
Eclipse でサーバーを起動するとすべて正常に動作しますが、webapps フォルダーにデプロイしてから Eclipse の外部で実行しようとすると、接続プールから接続を取得できません (サーブレット コードのこの行から nullpointerexception を取得しています) :
pstmt = conn.prepareStatement(query);
コード スニペット:
サーブレット コード:
Context env = null;
try {
env = new InitialContext();
pool = (javax.sql.DataSource) env.lookup("java:/comp/env/jdbc/postgres");
conn = pool.getConnection();
context.xml
<context>
<Resource name="jdbc/postgres" auth="Container" type="javax.sql.DataSource"
driverClassName="org.postgresql.Driver" url="jdbc:postgresql://localhost:5432/postgres"
docBase="postgpool" path="/postgpool" reloadable="true" source="org.eclipse.jst.j2ee.server:postgpool"
scope="Shareable"
username="postgres" password="789654" maxActive="35" maxIdle="10"
maxWait="-1" />
</context>
どんな助けでも大歓迎です。