Author Topic: GlassFish is not able to create connection to the DB  (Read 9484 times)

bcarson

  • Newbie
  • *
  • Posts: 32
  • Karma: +1/-0
GlassFish is not able to create connection to the DB
« on: September 03, 2015, 06:25:11 PM »
Both DBServer and AppServer for /opt/SPECjAppServer2004/schema/postgresql/pg_hba.conf show:
# "local" is for Unix domain socket connections only
local   all         all                               trust
# IPv4 local connections:
host    all         all         127.0.0.1/32          trust
host    all         all         appserver1/24         trust
host    all         all         appserver2/24         trust
host    all         all         appserver3/24         trust
host    all         all         appserver4/24         trust
host    all         all         client1/24            trust
# IPv6 local connections:
host    all         all         ::1/128               trust

Do these default values need to be changed?

Thanks,
Bruce

AnoopGupta

  • Jr. Member
  • **
  • Posts: 60
  • Karma: +0/-0
Re: GlassFish is not able to create connection to the DB
« Reply #1 on: September 03, 2015, 06:43:10 PM »
/opt/SPECjAppServer2004/schema/postgresql/pg_hba.conf is just a sample file.
Please check your PostgreSQL installation dir. You should have a pg_hba.conf there (just on the DBServer VM).

Since 1 DBServer VM can service up to 4 AppServer VMs, the 4 AppServer VM hostnames or IP addresses need to be in this file. If the hostnames are appserver[1-4] in your case, then this sample file should still be valid, but does need to be placed appropriately in the DBServer VM.

bcarson

  • Newbie
  • *
  • Posts: 32
  • Karma: +1/-0
Re: GlassFish is not able to create connection to the DB
« Reply #2 on: September 03, 2015, 06:51:51 PM »
Do I make this change to /var/lib/pgsql/9.2/data/pg_hba.conf or /var/lib/pgsql/data/pg_hba.conf ?
Also, what needs to be restarted after I make this change?

Thanks,
Bruce

AnoopGupta

  • Jr. Member
  • **
  • Posts: 60
  • Karma: +0/-0
Re: GlassFish is not able to create connection to the DB
« Reply #3 on: September 04, 2015, 03:26:31 AM »
I am not sure why do you have /var/lib/pgsql/9.2/data and /var/lib/pgsql/data. Either there is a symbolic link, or only one of those is getting used by PostgreSQL. Either way, it wouldn't hurt to have the same content in both the pg_hba.conf files.

After the change, you will have to restart:
  • PostgreSQL on the DBServerVM using pg_ctl stop|start. You may refer to PostgreSQL documentation for more details.
  • After PostgreSQL is started, on AppServer VM restart GlassFish.

abond

  • Moderator
  • Newbie
  • *****
  • Posts: 35
  • Karma: +6/-0
Re: GlassFish is not able to create connection to the DB
« Reply #4 on: September 04, 2015, 10:00:18 AM »
Hello Bruce,

The directory /var/lib/pgsql/9.2/data is the type of directory you get when you install a version of PostgreSQL from www.postgresql.org and the /var/lib/pgsql typically would be one you might get with a version of PostgreSQL from a linux distribution?  What OS are you using and did you install a downloaded version of PostgreSQL?  If you are using an rpm based distribution you could try running "rpm -qa | grep postgres" and verify what packages are installed.

I would also suggest trying to get a simple connection to the database to work from an appserver VM using the psql client command.  This would help debug PostgreSQL based configuration issues without the complication of trying to use Glassfish.

Andy

bcarson

  • Newbie
  • *
  • Posts: 32
  • Karma: +1/-0
Re: GlassFish is not able to create connection to the DB
« Reply #5 on: September 04, 2015, 01:02:24 PM »
Ok, thanks! Ultimately I'm trying to resolve the error in the appserver log showing 'Lookup failed for 'jdbc/SPECDB'' when attempting to hit curl http://specdelivery:8000/SPECjAppServer/app?action=atomicityTests (all 3 tests return FAILED).

POSTGRES info:
[root@specvirt-db ~]# rpm -qa | grep postgres
postgresql-9.2.10-2.el7_1.x86_64
postgresql-libs-9.2.10-2.el7_1.x86_64
postgresql-devel-9.2.10-2.el7_1.x86_64
postgresql-server-9.2.10-2.el7_1.x86_64

I can successfully connect to specdb on the DBServer from the AppServer using psql -h specdb -U spec -d specdb
but the Atomicity test still fails which I guess is my primary concern. What else should I be checking?

abond

  • Moderator
  • Newbie
  • *****
  • Posts: 35
  • Karma: +6/-0
Re: GlassFish is not able to create connection to the DB
« Reply #6 on: September 04, 2015, 01:24:38 PM »
Hey Bruce,

Thanks for the info.  I was afraid there might be multiple versions of PostgreSQL present and causing connection problems, but that does not appear to be the case.  Glad to hear that your normal database connections seem to be working. 

The next step would be to make sure you have the PostgreSQL JDBC file installed and linked correctly.  Are you setting this environment up using the ExampleVM guide and scripts?

Thanks,
Andy

bcarson

  • Newbie
  • *
  • Posts: 32
  • Karma: +1/-0
Re: GlassFish is not able to create connection to the DB
« Reply #7 on: September 04, 2015, 01:45:11 PM »
Yeah for the app server I used the appvm_scripts folder to run:
./makeme_appserver.sh
./setup_files.sh (after changing reference to installed postgres.jar and location of glassfish domain path to /opt/glassfish3/glassfish/domains/domain1/config)

abond

  • Moderator
  • Newbie
  • *****
  • Posts: 35
  • Karma: +6/-0
Re: GlassFish is not able to create connection to the DB
« Reply #8 on: September 04, 2015, 02:10:16 PM »
You shouldn't need to change the domain directory in the setup_files.sh script since it will be created as a part of the buildappsrv.sh command.  Would you attach the setup_files.sh script that you are using here in the forum?  Also, if you happen to have the output of the setup_files.sh script that you could attach here as well that would be handy to see if your buildappsrv.sh command ran ok.  You should have a /opt/glassfish3/glassfish/domains/spec2004-1 directory once it runs, but if one of the interim build steps has a problem it won't necessarily work correctly.

bcarson

  • Newbie
  • *
  • Posts: 32
  • Karma: +1/-0
Re: GlassFish is not able to create connection to the DB
« Reply #9 on: September 04, 2015, 02:46:10 PM »
1) See attached setup_files.sh
2) Error from AppServer log:
NestedStackTrace:
javax.naming.NamingException: Lookup failed for 'jdbc/SPECDB' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: SPECDB not found]
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
        at javax.naming.InitialContext.lookup(InitialContext.java:411)
        at javax.naming.InitialContext.lookup(InitialContext.java:411)
        at com.sun.jdo.spi.persistence.support.sqlstore.ejb.SunContainerHelper.getPersistenceManagerFactory(SunContainerHelper.java:302)
        at com.sun.jdo.spi.persistence.support.sqlstore.ejb.CMPHelper.getPersistenceManagerFactory(CMPHelper.java:222)
        at org.spec.jappserver.supplier.suppliercompent.ejb.SupplierCompCmp20EJB_741753996_ConcreteImpl.jdoLookupPersistenceManagerFactory(SupplierCompCmp20EJB_741753996_ConcreteImpl.java:385)
        at org.spec.jappserver.supplier.suppliercompent.ejb.SupplierCompCmp20EJB_741753996_ConcreteImpl.setEntityContext(SupplierCompCmp20EJB_741753996_ConcreteImpl.java:331)
        at com.sun.ejb.containers.EntityContainer$EntityContextFactory.create(EntityContainer.java:2513)
        at com.sun.ejb.containers.util.pool.NonBlockingPool.preload(NonBlockingPool.java:338)
        at com.sun.ejb.containers.util.pool.NonBlockingPool.doResize(NonBlockingPool.java:586)
        at com.sun.ejb.containers.util.pool.NonBlockingPool$IdleBeanWork.run(NonBlockingPool.java:684)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
Caused by: javax.naming.NameNotFoundException: SPECDB not found
        at com.sun.enterprise.naming.impl.TransientContext.doLookup(TransientContext.java:248)
        at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:215)
        at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:219)
        at com.sun.enterprise.naming.impl.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:77)
        at com.sun.enterprise.naming.impl.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:119)
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:505)

abond

  • Moderator
  • Newbie
  • *****
  • Posts: 35
  • Karma: +6/-0
Re: GlassFish is not able to create connection to the DB
« Reply #10 on: September 04, 2015, 04:25:07 PM »
Hey Bruce,

With the change made to the setup_files.sh script to point to domain1, some of the required changes to spec2004-1 would not be occurring.  I would do the following.

1. Shutdown the glassfish domain
2. Delete the /opt/glassfish3/glassfish/domains/spec2004-1 directory
3. Undo the domain directory changes you made to setup_files.sh to put spec2004-1 back in as the domain directory
4. Rerun the setup_files.sh script and capture the output of the script

See if the atomicity tests work, and if they don't post the output of the setup_files.sh script to the forum and we can take a look at it.

Thanks,
Andy

bcarson

  • Newbie
  • *
  • Posts: 32
  • Karma: +1/-0
Re: GlassFish is not able to create connection to the DB
« Reply #11 on: September 04, 2015, 05:35:38 PM »
I made the change to apply the defaults (/domains/spec2004-1 back into setup_files.sh) but when I run I get:
[root@specvirt-app appvm_scripts]# ./setup_files.sh
/bin/java
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
SPECvirt_sc2013 v1.00, build: 79
mkdir: cannot create directory ‘OLD-envs’: File exists
./env.sh: line 1: ../glassfish.env: No such file or directory
27256    54
27256    54
./setup_files.sh: line 60: cd: /opt/glassfish3/glassfish/domains/spec2004-1/config: No such file or directory

lroderic

  • Moderator
  • Full Member
  • *****
  • Posts: 167
  • Karma: +6/-0
Re: GlassFish is not able to create connection to the DB
« Reply #12 on: September 08, 2015, 12:40:14 PM »
Bruce, the version of setup_files.sh you're using is old (v1.00). Sorry about this. We recently made some changes to how Glassfish installs and builds appserver, so please download the new optdirs-sc2013-v1.01.tgz from https://www.spec.org/forums/index.php?action=dlattach;topic=15.0;attach=55. You also might want to grab the helper scripts archive while you're there.

Lisa