Skip to main content

EJB and DB2 failure

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
7 replies [Last post]
michaelgoossens
Offline
Joined: 2010-12-20

Hello I'm new to EJB and Ihave not been able to connect the application to my database. I'll first explain my hardware and software specs and then the problem.
System:
- My machine is a mac notebook with Snow Leopard OS
- I'm using Netbeans 6.9.1 as IDE
- GlassFish 3 as j2EE application server
- DB2 as database
Application:
I created a small application through http. The request is sent to a bean and this bean retrieves a username from the database. After that the username is written in the response of the http request. When I run this flow the following error is shown:
Failure at loading native library db2jcct2, java.lang.UnsatisfiedLinkError: no db2jcct2 in java.library.path: ERRORCODE=-4472, SQLSTATE=null
What I already tried:
- Adding the library path /opt/IBM/db2/V9.5/lib64 to the "Native Library Path Prefix" in the admin console
- Adding the library path /opt/IBM/db2/V9.5/lib64 to the "Native Library Path Suffix" in the admin console
- Add library path /opt/IBM/db2/V9.5/lib64 to the EJB project in Netbeans.
- Using type 4 ODBC driver.
- recreating ejb connection pool
- recreation ejb data source
...
What now?
I read a lot on the internet but nothing worked for me. I think the problem lies with the library not being loaded properly, can I check this somehow? This problem is lingering for a week now and I would like to get some progress soon :).

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
michaelgoossens
Offline
Joined: 2010-12-20

It has been a while but yesterday I got another burst of motivation to tackle the problem. Nothing I tried worked until now. I took some time to read up on available documentation of db2 and glassfish connection pools. Eventually I decided to use the type 4 driver which is pure java instead of a native library. This still didn't work and a ClassNotFoundException error popped up.
What I had to do then was add the jar's db2jcc4 and the licence jar to the glassfish domain structure in the folder lib/ext. After that no more exceptions and the connection worked as I expected =). Problem solved.

jr158900
Offline
Joined: 2005-04-13

After setting the native library path prefix, did you restart GlassFish ?
Once you restart GlassFish, you should see "-Djava.library.path" entry in server.log which should include the path(s) you have specified.

michaelgoossens
Offline
Joined: 2010-12-20

The server.log shows the following(nothing about -Djava.library.path):
[#|2011-02-14T19:53:27.184+0100|INFO|glassfish3.0.1|
javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=28;_ThreadName=Thread-
1;|com.ibm.db2.jcc.a.SqlException: [jcc][10389][12245][4.2.73] Fout bij laden native bibliotheek db2jcct2,
java.lang.UnsatisfiedLinkError: no db2jcct2 in java.library.path: ERRORCODE=-4472, SQLSTATE=null
So it is still not working =-(.

michaelgoossens
Offline
Joined: 2010-12-20

The java log jvm.log shows:
-Dosgi.shell.telnet.maxconn=1 -Djdbc.drivers=org.apache.derby.jdbc.ClientDrive-
Dfelix.fileinstall.dir=/Applications/NetBeans/glassfish-3.0.1/glassfish/modules/autostart/ -
Djavax.net.ssl.keyStore=/Applications/NetBeans/glassfish-3.0.1/glassfish/domains/domain1/config/keystore.jks -
Dosgi.shell.telnet.port=6666 -Djava.security.policy=/Applications/NetBeans/glassfish-
3.0.1/glassfish/domains/domain1/config/server.policy -Dfelix.fileinstall.poll=5000 -
Dhttp.nonProxyHosts=local|*.local|169.254/16|*.169.254/16|localhost|127.0.0.1|macbook-van-michael-goossens.local -
Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory
-Dosgi.shell.telnet.ip=127.0.0.1 -Djava.endorsed.dirs=/Applications/NetBeans/glassfish-
3.0.1/glassfish/modules/endorsed:/Applications/NetBeans/glassfish-3.0.1/glassfish/lib/endorsed -
Djava.ext.dirs=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/jre/lib/ext:/Applications/NetBeans/glassfish-
3.0.1/glassfish/domains/domain1/lib/ext -Dfelix.fileinstall.bundles.new.start=true -
Djavax.net.ssl.trustStore=/Applications/NetBeans/glassfish-3.0.1/glassfish/domains/domain1/config/cacerts.jks -
Dcom.sun.enterprise.security.httpsOutboundKeyAlias=s1as -Djava.library.path=/opt/IBM/db2/V9.5/lib64 -
Djava.security.auth.login.config=/Applications/NetBeans/glassfish-3.0.1/glassfish/domains/domain1/config/login.conf -
DANTLR_USE_DIRECT_CLASS_LOADING=true -Dfelix.fileinstall.debug=1 -
Dorg.glassfish.web.rfc2109_cookie_names_enforced=false -javaagent:/Applications/NetBeans/glassfish-
3.0.1/glassfish/lib/monitor/btrace-agent.jar=unsafe=true,noServer=true -XX:MaxPermSize=192m -
XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=/Applications/NetBeans/glassfish-

But I still get the error as above.

jr158900
Offline
Joined: 2005-04-13

As long as the directory /opt/IBM/db2/V9.5/lib64 is valid and the library exists, it should work fine.
You can also try setting the environment variable LD_LIBRARY_PATH having the above directory and then start GlassFish to see whether the library is detected.

http://old.nabble.com/Native-Library-Path-Suffix-problem-td21418903.html
http://blogs.sun.com/swchan/entry/glassfish_with_ecc

michaelgoossens
Offline
Joined: 2010-12-20

Thanks for the links, that information looks similar to my problem. Will try tonight.

michaelgoossens
Offline
Joined: 2010-12-20

I did restart. But I will check the log when I get home :-).