Moving this back on the list.

In general it's a good idea to keep the discussion (and the solution) on the mailing list. That way everyone benefits (and everyone can help).

Comments are surrounded with ==== COMMENT ====

On 8/9/2012 4:18 AM, CHRISTOS STAVRINOU wrote:
Thank you for your answer that solved the problem. But now I get the
error below that

[Sybase][ODBC Driver Manager] Unable to load resource file

I can't understand what happens and how to fix it.

Please help if you have any answer.

Thanks a lot.

org.apache.jasper.JasperException: javax.servlet.ServletException:
java.sql.SQLException: [Sybase][ODBC Driver Manager] Unable to load
resource file
        
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:548)
        
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:456)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

root cause

javax.servlet.ServletException: java.sql.SQLException: [Sybase][ODBC
Driver Manager] Unable to load resource file
        
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:911)
        
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840)
        org.apache.jsp.sybread_jsp._jspService(sybread_jsp.java:157)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

root cause

java.sql.SQLException: [Sybase][ODBC Driver Manager] Unable to load
resource file
        ianywhere.ml.jdbcodbc.jdbc3.IDriver.makeODBCConnection(Native Method)
        ianywhere.ml.jdbcodbc.jdbc3.IDriver.connect(IDriver.java:768)
        java.sql.DriverManager.getConnection(DriverManager.java:579)
        java.sql.DriverManager.getConnection(DriverManager.java:221)
        org.apache.jsp.sybread_jsp._jspService(sybread_jsp.java:95)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


==== COMMENT ====

This looks like you are placing the SQL inside of a JSP page. In general, this is not best practice. I am not sure that this list is the place to discuss DAO (data access object) architecture, although the following blog post by Christopher Schultz is quite instructive:

http://blog.christopherschultz.net/index.php/2009/03/16/properly-handling-pooled-jdbc-connections/

==== COMMENT ====

On Wed, Aug 8, 2012 at 7:46 PM, Mark Eggers <its_toas...@yahoo.com> wrote:
On 8/8/2012 6:06 AM, CHRISTOS STAVRINOU wrote:

Problem with tomcat 7 and java ld_library_path under centos 6 using
IANYWHERE JDBC DRIVER

At what path I must copy the file dbjodbc12.so? What is the correct
configuration?

How I can configure the java.library.path under under centos 6 and
tomcat 7 in order to fix the problem?

Please help me. If you have any answers please email me to
stavr...@gmail.com

Thanks in advance

The connection string is as follows:

"jdbc:ianywhere:driver=libdbodbc12.so;ENG=host;DBN=database"

==== COMMENT ====

According to a discussion on the SQL Anywhere forum, you no longer need to put driver and DBN=database (shouldn't that be DSN=database) in the connection string.

However, they're using sajdbc4.jar -> sybase.jdbc4.sqlanywhere.IDriver and you appear to be using the jdbc3 driver?

Here's the discussion link:

http://sqlanywhere-forum.sybase.com/questions/8551/sybasejdbc4sqlanywhereidriver-problems-java-hangs-when-connecting

==== COMMENT ====

But when running the program, I get the following exception (with the
relevant stack trace) -
Exception in thread "main" java.lang.UnsatisfiedLinkError: no
dbjodbc12 in java.library.path
                 at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
                 at java.lang.Runtime.loadLibrary0(Runtime.java:823)
                 at java.lang.System.loadLibrary(System.java:1030)
                 at
ianywhere.ml.jdbcodbc.IDriver.try_load(IDriver.java:247)
                 at
ianywhere.ml.jdbcodbc.IDriver.<clinit>(IDriver.java:216)
                 at java.lang.Class.forName0(Native Method)
                 at java.lang.Class.forName(Class.java:169)


I just did a quick yum search on a CentOS 6 machine, and I guess you're
running a self-installed version of Tomcat 7 from tomcat.apache.org.

If that's the case, you can do the following to add to your
java.library.path.

1. Create a file called setenv.sh in $CATALINA_BASE/bin
2. Add the following lines

    JAVA_OPTS="-Djava.library.path=directory-with-libdbodbc12.so"
    export JAVA_OPTS

3. Restart Tomcat

Technically you could place this in CATALINA_OPTS instead, and the path
would only be available to Tomcat (and not the separate shutdown JVM). For
memory parameters, this is important. For java.library.path, probably not as
much.

If you've installed Tomcat 7 from a third party RPM, then you'll have to
find the bin directory and create the file as above. Hopefully the packager
didn't alter catalina.sh so that it doesn't parse setenv.sh.

I've not tried this since I use pure Java drivers for databases, and have
not used this database. I do load the APR native library this way.

==== COMMENT ====

I don't know where you've placed the dbjodbc12.so and corresponding JAR file. Here are some thoughts on that.

1. dbjodbc12.so location

Place this outside of your Tomcat installation. Since this is a system resource, you might consider placing it in /opt/Sybase/lib or something similar.

Make sure that the file (and directory) are readable by the user running your Tomcat process. In general for a directory 0755 is appropriate, and for the file itself 0755 (libraries are executable?).

Another possibility is to place the library in a system location (/lib, /usr/lib, /usr/local/lib) and let ldconfig make this available. If you do this, then the java.library.path should not be needed. However, that will impact your entire system so it may not be what you want.

2. sajdbc4.jar

I'm guessing that you're actually using sajdbc3.jar? Again, I don't know since I've not worked with the Sybase database.

At any rate, since you're doing this all in JSP (and I assume for now NOT using JNDI), you need to place the appropriate JAR file in WEB-INF/lib of your application.

It should be found ONLY in the WEB-INF/lib of your application. Placing the JAR file in multiple places will just lead to the issues you're seeing.

One of these days I'm going to walk through the classloader mechanics so I can understand why multiple JAR locations creates issues.

==== COMMENT ====

. . . . just my two cents.
/mde/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to