Proxool java.lang.NoClassDefFoundError

大城市里の小女人 提交于 2020-02-06 08:16:05

问题


I just started using Proxool (JDBC Connection Pool manager). I downloaded the jar which is found at the following link: http://proxool.sourceforge.net/download.html. After that, I just added the jar location into the ClassPath in netbeans 7.0.1, built the project, restarted my server (which is Glassfish) and then tried to configure it as this example shows:

https://java2s.com/Open-Source/Java/Database-JDBC-Connection-Pool/proxool/org/logicalcobwebs/proxool/ProxoolDataSourceTest.java.htm

I just adapted the Example (parameters) to fix into my application and the following piece of code below crashes. It shows the error java.lang.NoClassDefFoundError: Could not initialize class org.logicalcobwebs.proxool.ProxoolDataSource.

I can't understand why because I just imported the whole package. I do not know where to start.

Here's my code:

import org.logicalcobwebs.proxool.*;
import org.logicalcobwebs.*;

/* Error Here ----> */ ProxoolDataSource dataSource = new ProxoolDataSource();
        dataSource.setAlias("flpool");
        dataSource.setDriver("com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource");
        dataSource.setDriverUrl("jdbc:mysql://localhost:3306/superdb");
        dataSource.setUser("db");
        dataSource.setPassword("password");
        dataSource.setMaximumActiveTime(100);
        dataSource.setMinimumConnectionCount(8);
        dataSource.setMaximumConnectionCount(25);
        Hashtable env = new Hashtable();
        env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.registry.RegistryContextFactory");
        env.put(Context.PROVIDER_URL, "rmi://localhost:1099");
        Context context = new InitialContext(env);
        context.createSubcontext("jdbc");
        context.bind(jndiName,dataSource);
        context.close();          

    DataSource ds = (DataSource) context.lookup(jndiName);

    ProxoolFacade.removeConnectionPool("flpool");   

    context.close();

if someone have any idea will appreciate it your help, thanks in advance.


回答1:


I would guess that you are missing an Apache Commons Logging JAR.

The message

Could not initialize class org.logicalcobwebs.proxool.ProxoolDataSource

indicates that static initialization of the named class failed.

I downloaded the source of Proxool, and the only static initialization in this class was the following line:

private static final Log LOG = LogFactory.getLog(ProxoolDataSource.class);

Try adding a Commons Logging JAR to your project and restarting your server.



来源:https://stackoverflow.com/questions/13462861/proxool-java-lang-noclassdeffounderror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!