Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » JBOSS ClassCastException when accessing remote home interface
JBOSS ClassCastException when accessing remote home interface [message #247896] Tue, 01 June 2004 09:29 Go to next message
Eclipse UserFriend
Originally posted by: gerhard.kainz.knowing.at

Hi,

I am writing a plugin for eclipse 3.0 (M8) , that needs access to JBOSS. I
have all the JBOSS jars as bootstrap entries and j2ee.jar in the runtime
classpath. A security manager is set to all permissions.

The problem is as follows:

Following code is called as part of a factory Class

public static OCSessionEJB getSessionBean() {
if (ocSession == null) {

try {

getInitialContext();

Object ref = context.lookup("OCSessionEJB");

Object object = PortableRemoteObject.narrow(ref,
OCSessionEJBHome.class);

OCSessionEJBHome home = (OCSessionEJBHome) object;

ocSession = home.create();

} catch (Exception e) {

System.err.println("MESSAGE:" + e.getMessage());

e.printStackTrace(System.err);}}

return ocSession;

}




private static void getInitialContext() throws NamingException {

if (context == null) {

if(System.getSecurityManager() == null) {System.setSecurityManager(new
RMISecurityManager());}

Hashtable connectionProperties = new Hashtable();

connectionProperties.put(Context.INITIAL_CONTEXT_FACTORY,

namingContextFactory);

connectionProperties.put(Context.PROVIDER_URL, providerURL);

context = new InitialContext(connectionProperties);}

}

I wrote a small application, that uses the plugin's viewer and fills it with
data from our jboss server. It works (including the above code). When I run
it as a plugin the initial context ist set (seems so), the context.lookup
works (ref != null) but PortableRemoteObject.narrow() throws a
ClassCastException.

Any ides are welcome

Gerhard a: Kainz
Re: JBOSS ClassCastException when accessing remote home interface [message #247940 is a reply to message #247896] Tue, 01 June 2004 10:46 Go to previous message
Eclipse UserFriend
Originally posted by: gerhard.kainz.knowing.at

Thanks to J. O Connor I found the following and it works:

private static void getInitialContext() throws NamingException {

if (context == null) {

// set security manager

// if(System.getSecurityManager() == null) {

// System.setSecurityManager(new RMISecurityManager());

// }

//

//

// Hashtable connectionProperties = new Hashtable();

// connectionProperties.put(Context.INITIAL_CONTEXT_FACTORY,

// namingContextFactory);

// connectionProperties.put(Context.PROVIDER_URL, providerURL);

// context = new InitialContext(connectionProperties);


Hashtable env = new Hashtable();

env.put("java.naming.factory.initial",

"org.jnp.interfaces.NamingContextFactory");

env.put("java.naming.factory.url.pkgs",

"org.jboss.naming:org.jnp.interfaces");

env.put("java.naming.provider.url", "jnp://localhost:1099");

env.put("java.naming.rmi.security.manager", "yes");

NamingContextFactory namingFactory = new

NamingContextFactory();

context = namingFactory.getInitialContext(env);

}

}

"gk" <gerhard.kainz@knowing.at> schrieb im Newsbeitrag
news:c9hvp5$k0c$1@eclipse.org...
> Hi,
>
> I am writing a plugin for eclipse 3.0 (M8) , that needs access to JBOSS. I
> have all the JBOSS jars as bootstrap entries and j2ee.jar in the runtime
> classpath. A security manager is set to all permissions.
>
> The problem is as follows:
>
> Following code is called as part of a factory Class
>
> public static OCSessionEJB getSessionBean() {
> if (ocSession == null) {
>
> try {
>
> getInitialContext();
>
> Object ref = context.lookup("OCSessionEJB");
>
> Object object = PortableRemoteObject.narrow(ref,
> OCSessionEJBHome.class);
>
> OCSessionEJBHome home = (OCSessionEJBHome) object;
>
> ocSession = home.create();
>
> } catch (Exception e) {
>
> System.err.println("MESSAGE:" + e.getMessage());
>
> e.printStackTrace(System.err);}}
>
> return ocSession;
>
> }
>
>
>
>
> private static void getInitialContext() throws NamingException {
>
> if (context == null) {
>
> if(System.getSecurityManager() == null) {System.setSecurityManager(new
> RMISecurityManager());}
>
> Hashtable connectionProperties = new Hashtable();
>
> connectionProperties.put(Context.INITIAL_CONTEXT_FACTORY,
>
> namingContextFactory);
>
> connectionProperties.put(Context.PROVIDER_URL, providerURL);
>
> context = new InitialContext(connectionProperties);}
>
> }
>
> I wrote a small application, that uses the plugin's viewer and fills it
with
> data from our jboss server. It works (including the above code). When I
run
> it as a plugin the initial context ist set (seems so), the context.lookup
> works (ref != null) but PortableRemoteObject.narrow() throws a
> ClassCastException.
>
> Any ides are welcome
>
> Gerhard a: Kainz
>
>
>
Previous Topic:[RCP M8] NoClassDefFoundError org/eclipse/swt/widgets/Listener
Next Topic:Can't Install/Update New Features/Plugins
Goto Forum:
  


Current Time: Mon Jun 09 01:30:44 EDT 2025

Powered by FUDForum. Page generated in 0.02705 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top