无法实例化类:org.jboss.naming.remote.client.InitialContextFactory [英] Cannot instantiate class: org.jboss.naming.remote.client.InitialContextFactory

查看:209
本文介绍了无法实例化类:org.jboss.naming.remote.client.InitialContextFactory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将jboss 7.1.1 final连接到三层架构方法,在我的业务层中保持连接逻辑,并从我的表示层访问此业务层。但它抛出以下异常无法实例化类:org.jboss.naming.remote.client.InitialContextFactory



如果我在相同的演示文稿中保持jboss连接逻辑,它的工作正常层。



以下是我的业务逻辑代码。



  public   static   void  Connect()
{
尝试
{
javax.naming.Context context = null ;
ConnectionFactory connectionFactory;
连接连接;
会话会话;
字符串 topicName = jms / topic / TestedTopic;
目标dest = null ;
MessageConsumer consumer = null ;
TextListener listener = null ;
java.util.Properties jndiProps = new java.util.Properties();
jndiProps.put(Context .__ Fields.INITIAL_CONTEXT_FACTORY, org.jboss.naming.remote.client.InitialContextFactory );
jndiProps.put(Context .__ Fields.PROVIDER_URL, remote://10.1.7.149:4447< /跨度>);
jndiProps.put(Context .__ Fields.SECURITY_PRINCIPAL, admin);
jndiProps.put(Context .__ Fields.SECURITY_CREDENTIALS, admin123);
jndiProps.put( jboss.naming.client.ejb.context);


context = new InitialContext(jndiProps);


connectionFactory =(ConnectionFactory)context.lookup( jms / RemoteConnectionFactory );
connection = connectionFactory.createConnection();
dest =(Destination)context.lookup(topicName);
session = connection.createSession( false ,Session .__ Fields.AUTO_ACKNOWLEDGE);
consumer = session.createConsumer(dest);

listener = new TextListener();
consumer.setMessageListener(listener);
connection.start();
}
catch (例外)
{

// throw;
}
}

解决方案

 添加  a   reference     Visual   Studio      add  < span class =code-leadattribute> a   reference      已编译 输出 如果   使用 一个  
in 您的 代码 via reflection < span class =code-leadattribute> a reference 加入

3 选项:
best 使用 a 完整 合格 NET classname 包括 dll name

use BootClassPathAssemby http: // sourceforge.net/apps/mediawiki/ikvm/ index.php?title = ClassLoader


使用 一个 class file 来自 dll 使用 AppDomainAssemblyClassLoader 详细信息 http: // sourceforge.net/apps/mediawiki/ikvm/index.php ?标题=类加载器


I am trrying to connect jboss 7.1.1 final with Three tier architecture approach keeping connection logic in my business layer and access this business layer from my presentation layer. But it is throwing following exception "Cannot instantiate class: org.jboss.naming.remote.client.InitialContextFactory

Its working fine if i keep jboss connection logic in same presentation layer.

following is my code in business logic.

public static void Connect()
    {
        try
        {
            javax.naming.Context context = null;
            ConnectionFactory connectionFactory;
            Connection connection;
            Session session;
            String topicName = "jms/topic/TestedTopic";
            Destination dest = null;
            MessageConsumer consumer = null;
            TextListener listener = null;
            java.util.Properties jndiProps = new java.util.Properties();
            jndiProps.put(Context.__Fields.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
            jndiProps.put(Context.__Fields.PROVIDER_URL, "remote://10.1.7.149:4447");
            jndiProps.put(Context.__Fields.SECURITY_PRINCIPAL, "admin");
            jndiProps.put(Context.__Fields.SECURITY_CREDENTIALS, "admin123");
            jndiProps.put("jboss.naming.client.ejb.context", true);


            context = new InitialContext(jndiProps);


            connectionFactory = (ConnectionFactory)context.lookup("jms/RemoteConnectionFactory");
            connection = connectionFactory.createConnection();
            dest = (Destination)context.lookup(topicName);
            session = connection.createSession(false, Session.__Fields.AUTO_ACKNOWLEDGE);
            consumer = session.createConsumer(dest);

            listener = new TextListener();
            consumer.setMessageListener(listener);
            connection.start();
        }
        catch (Exception)
        {

            //throw;
        }
    }

解决方案

Adding a reference to Visual Studio does not add a reference in the compiled output. Only if you use one class
in your code and not via reflection a reference is added.

There are 3 options:
The best is you use a full qualified .NET classname. This include also the dll name.

Or you use BootClassPathAssemby like in http://sourceforge.net/apps/mediawiki/ikvm/index.php?title=ClassLoader


Or you use one class file from the dll and use the AppDomainAssemblyClassLoader. Details are at http://sourceforge.net/apps/mediawiki/ikvm/index.php?title=ClassLoader


这篇关于无法实例化类:org.jboss.naming.remote.client.InitialContextFactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆