Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with connection pooling on Sun Appserver 9.0_01 (Glassfish) [JDBC93] #131

Closed
firebird-automations opened this issue Nov 8, 2006 · 19 comments

Comments

@firebird-automations
Copy link

Submitted by: Marcel Gascoyne (mgascoyne)

Relate to JDBC176
Is duplicated by JDBC219

Votes: 1

We've problems with the connection pool on our appserver. The class used for the connection pool is org.firebirdsql.pool.sun.AppServerConnectionPoolDataSource.

At unspecific time, all attempts to use a connection from the pool is resulting in the following exception:

Error in allocating a connection. Cause: Connection could not be allocated because: Could not obtain connection during blocking timeout (5000 ms)

The connection limit on the pool is set to 100 connections. But where are only about 5 connections in use. If this exception occurs you must restart the appserver.

Commits: 990502c fbbb8b8

@firebird-automations
Copy link
Author

Commented by: Marcel Gascoyne (mgascoyne)

The used firebird version is 1.5.3, not 1.5.2

@firebird-automations
Copy link
Author

Commented by: Marcel Gascoyne (mgascoyne)

This issue also occurs with Firebird 2.0 (Release) and Jaybird 2.2.0 Beta driver.

@firebird-automations
Copy link
Author

Commented by: Alexander Glazkov (solarapex)

After spending a few hours, it seems I have found the cause.

Normally, the databaseName parameter value has format SERVER/PORT:DRIVE:/PATH/FILE.GDB
This is the old format.

The section 6 in the FAQ provides a different format.

//SERVER:PORT/DRIVE:/PATH/FILE.GDB

Try it. It should work.
If it works in your case, then there are 2 questions:
1. Why the connection pool does not support the old-style URLs.
2. Why the error message is so fuzzy.

My platform:
Windows 2000
FireBird 2.0
JayBird 2.1.1
JDK 1.5.0_10

@firebird-automations
Copy link
Author

Commented by: Alexander Glazkov (solarapex)

One correction to the config above
JDK 1.5.0_08

@firebird-automations
Copy link
Author

Commented by: Jaroslav Beran (berk)

Hi,

I am unable to find org.firebirdsql.pool.sun.AppServerConnectionPoolDataSource class,
But I got the same error when I used org.firebirdsql.pool.FBWrappingDataSource class.

After several experiments I choosed org.firebirdsql.pool.FBSimpleDataSource and it works fine.

My properties for this data source are:

userName - myuser
password - mypass
database - localhost/3050:c:/db/ELITNET.FDB

My platform is:

- Win XP
- Sun Java System Application Server Platform Edition 9.0_01 (build b14)
- jdk1.6.0_01
- FireBird 2.0
- JayBird 2.1.1

@firebird-automations
Copy link
Author

Commented by: Tray Allen (dycept)

Hello,

I am also confronted with some Trouble in using the Jaybird driver together with glassfish

This is the setup....

I wrote a session bean doing this:

@stateless
public class MySessionBean implements MySession{
public String helloSession() {
try {
InitialContext ctx = new InitialContext();

	DataSource ds = \(DataSource\) ctx\.lookup\("jdbc/TESTDB"\);
	
	Connection con = ds\.getConnection\(\);
	con\.close\(\);
	return "Hello my name is dycept and I am funky";	
	\}
	catch \(Exception e\)
	\{
		e\.printStackTrace\(\);
		return "whoops";
	\}
	
	
\}

}

For that Session bean i wrote a client doning this:

public static void main\(String\[\] args\) throws Exception\{
	/\*properties f?r jndi\*/
	
	Properties props = new Properties\(\);
	props\.setProperty\("java\.naming\.factory\.initial", "com\.sun\.enterprise\.naming\.SerialInitContextFactory"\);
	props\.setProperty\("java\.naming\.factory\.url\.pkgs","com\.sun\.enterprise\.naming"\);
                     props\.setProperty\("java\.naming\.factory\.state","com\.sun\.corba\.ee\.impl\.presentation\.rmi\.JNDIStateFactoryImpl"\);
                      props\.setProperty\("org\.omg\.CORBA\.ORBInitialHost", "localhost"\);
                      props\.setProperty\("org\.omg\.CORBA\.ORBInitialPort", "3700"\);
	String foo;
	String jndiName = MySession\.class\.getName\(\);
	InitialContext ctx = new InitialContext\(\);
	MySession remote = \(MySession\)ctx\.lookup\(jndiName\);
	foo=remote\.helloSession\(\);
	System\.out\.println\(foo\);
\}

So when i go into the Adminconsole of Glassfish to configure a connection pool and use one of the following:

- org.firebirdsql.pool.sun.AppServerDataSource
- org.firebirdsql.pool.sun.AppServerConnectionPoolDataSource

then I get an Errormessage, that looks like this when I run the Client:

javax.ejb.EJBException: nested exception is: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.RemoteException: null; nested exception is:
java.lang.AbstractMethodError: org.firebirdsql.jdbc.FBConnection.getClientInfo()Ljava/util/Properties;
at ejb.dycept._MySession_Wrapper.helloSession(ejb.dycept._MySession_Wrapper.java)
at BClient.BClient.main(BClient.java:30)

Only if i set the class to be :

- org.firebirdsql.pool.FBSimpleDataSource

I can execute the Client without errormessage.

Plz help me I am very confused.... :-(

@firebird-automations
Copy link
Author

Commented by: Carl Smotricz (smotricz)

I had the same problem and was able to fix it thanks to the comments in this issue - thanks!

In my successful configuration, I am using org.firebirdsql.pool.sun.AppServerConnectionPoolDataSource .
This is found in jaybird-pool-2.0.1.jar, which I placed into \glassfish\domains\domain1\lib along with jaybird-2.0.1.jar .

I specified Resource Type javax.sql.ConnectionPoolDataSource. Apart from all the defaults, I only specified "password", "userName" and "databaseName" properties. The latter is <//localhost:3050/myalias> , i.e. "new format".

I found that using an alias (specified in %FIREBIRD_HOME%\aliases.conf) helped avoid complications with colons and slashes in database path names.

@firebird-automations
Copy link
Author

Modified by: Roman Rokytskyy (rrokytskyy)

Fix Version: Jaybird 2.2 [ 10053 ]

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

assignee: Roman Rokytskyy [ rrokytskyy ] => Mark Rotteveel [ avalanche1979 ]

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

Current working theory:
Some Connection and ConnectionPool related classes have incorrect or incomplete synchronisation, secondly the BlockingStack used by PooledConnectionQueue (which is used amongst others by AppServerConnectionPoolDataSource and AppServerXADataSource) has incorrect synchronisation and stack semantics in both the timed and untimed pop.
In some situations this could cause the BlockingStack to be emptied instead of the first available value to be returned, and in other situations it could cause a thread waiting to pop a value to return null and not continue waiting for a value to become available.

I have yet to reproduce this problem, before I can actually fix this.

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

I committed a fix for the incorrect synchronisation and broken stack semantics of BlockingStack. I also added testcases for the issues, and removed unncessary code from BlockingStack.

As far as I can see this should fix the described issue, unfortunately I have only been able to reproduce this with a synthetic testcase. I will do some more investigation into a realistic reproduction case, and see if other synchronisation issues reported by FindBugs for Connection and ConnectionPool related classes could contribute to this problem as well.

Potentially this fixes other issues as well: JDBC144, JDBC131

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

Link: This issue relate to JDBC176 [ JDBC176 ]

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

Removed Fix version; for Jaybird 2.2 use org.firebirdsql.ds.FBConnectionPoolDataSource instead.

This class is considered for removal in Jaybird version after 2.2

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

Fix Version: Jaybird 2.2 [ 10053 ] =>

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

Fix Version: Jaybird 2.3 [ 10440 ]

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

Link: This issue is duplicated by JDBC219 [ JDBC219 ]

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

Removed deprecated org.firebirdsql.pool.sun classes

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants