java.lang.ClassNotFoundException:com.ibm.websphere.appprofile.accessintent.AccessIntent

时间:2016-06-17 09:08:15

标签: java websphere jndi

我正在尝试使用JNDI名称获取数据库连接。我在唱Websphere应用服务器。 请在下面找到代码。

public class GetDbConnection {
        private static Connection getConnection() throws Exception {
        Hashtable<String, String> pdEnv = new Hashtable<String, String>();
        pdEnv.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory"); 
        pdEnv.put(Context.PROVIDER_URL, "iiop://10.70.52.228:30305/");
        Connection connection = null;   
    try{    
        Context ctx = new InitialContext(pdEnv);
    System.out.println("Initial Context: "+ctx.getNameInNamespace());

    DataSource ds = (DataSource) ctx.lookup("jdbc/siperian-mdmtrg01-cmx_ors-ds");
    System.out.println("DataSource Object : "+ds.getClass());        
   connection = ds.getConnection();
   System.out.println("Connection established ::" +connection);
    }catch(Exception ex){
        ex.printStackTrace();
    }
       return connection;   }        

我遇到错误。这是完整的打印堆栈跟踪。

  

初始上下文:MDMTRG2Cell01 / clusters / InformaticaMDM_Cluster   J2CA0036E:调用方法时发生异常   setDataSourceProperties on   com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl使用者   资源jdbc / siperian-mdmtrg01-cmx_ors-ds:   java.lang.NoClassDefFoundError:   COM / IBM / websphere的/ appprofile / accessintent / AccessIntent

请在这个reagrd中帮助我。

1 个答案:

答案 0 :(得分:0)

问题的原因是 WebSphere Application Server Java™虚拟机(JVM)找不到JDBC JAR文件

示例如果我们使用DB2数据源,我们需要DB2 JAR,在包含实现类的websphere类路径中。

最可能的原因是JDBC Provider配置的类路径使用了WebSphere Application Server变量,例如DB2_JDBC_DRIVER_PATH,该变量尚未针对相应的WebSphere Application Server jvm进程设置。

这也可能是由基于Unix的服务器引起的,因为userID没有访问包含该类的jar的权限。