thanks chris.. i hope you don't mind if i forward this to the list..
great workaround..
maybe i could do the lookup with another protocol jnp:// maybe.
i'll give that & this a try.
-----Original Message-----
From: Christopher G. Stach II [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 5 June 2001 11:21 AM
To: Warren Crossing
Subject: Re: java.net.MalformedURLException: unknown protocol: jndi
Okay, there's a jndi URL context factory in the COS naming package, but
that's not compatible with the jnp provider. Here, from
cosnaming-1.2.1/lib/providerutil.jar:
0 Fri Oct 22 01:49:00 CDT 1999 com/sun/jndi/url/jndi/
1723 Fri Oct 22 01:48:58 CDT 1999
com/sun/jndi/url/jndi/jndiDNSClient.class
4132 Fri Oct 22 01:49:00 CDT 1999
com/sun/jndi/url/jndi/jndiURLContextFactory.class
648 Fri Oct 22 01:49:04 CDT 1999
com/sun/jndi/url/jndi/jndiURLContext.class
My design is basically a ripoff of the Java Pet Store, just improved and
trimmed down a lot. If you want, look at the WebController and
WebControllerWebImpl in Sun's dist of that.
1. EJB is a stateful session bean
2. I don't have JAAS security setup
3. All of the methods for it work, except one
4. If I change the method to take NO arguments, instead of the single
argument, it works
5. The single argument is a class I defined, and is serializable
6. The class is an interface
7. The server (which is throwing the exception) does have access to the
class and all of the classes which implement the interface
8. This all works under Sun's J2EE SDK 1.3
That about as much information as I can give without sending you entire
configurations. Since I'm in a rush, this is what I did to fix it.
WebControllerEJB.getEventResult(WebEvent event) is the method whose
invocation fails. I figured out that what it was doing was passing the
parameter 'event' by reference, instead of serializing it and passing by
value. This caused the server to try and look up the reference in the
client, which can't happen. I don't know why it would use jndi: instead of
jnp: either! What I did was serialize the object myself to a byte array and
that passes by value. I should note that the other methods in the EJB take
Long and other JDK classes and they serialize just fine, as well. Just my
WebEvent class doesn't work for some reason.
Original WebControllerWebImpl:
public synchronized WebEventResult handleEvent(WebEvent event)
throws WebEventException
try {
return _wcEJB.getEventResult(event);
} catch (RemoteException e) {
e.printStackTrace();
throw new GeneralException(e.getMessage());
}
}
Original WebController.java:
public WebEventResult getEventResult(WebEvent event)
throws RemoteException, WebEventException;
Original WebControllerEJB.java:
public WebEventResult getEventResult(WebEvent event)
throws WebEventException
{
return _sm.handleEvent(event);
}
New WebControllerWebImpl:
public synchronized WebEventResult handleEvent(WebEvent event)
throws WebEventException
byte[] bytes;
try {
PipedInputStream istream = new PipedInputStream();
PipedOutputStream ostream = new PipedOutputStream(istream);
ObjectOutputStream oo = new ObjectOutputStream(ostream);
oo.writeObject(event);
oo.flush();
ostream.close();
bytes = new byte[istream.available()];
istream.read(bytes, 0, istream.available());
} catch (IOException e) {
e.printStackTrace();
throw new GeneralException(e.getMessage());
}
try {
return _wcEJB.getEventResult(bytes);
} catch (RemoteException e) {
e.printStackTrace();
throw new GeneralException(e.getMessage());
}
}
New WebController.java:
public WebEventResult getEventResult(byte[] bytes)
throws RemoteException, WebEventException;
New WebControllerEJB.java:
public WebEventResult getEventResult(byte[] bytes)
throws WebEventException
{
WebEvent event;
try {
ByteArrayInputStream istream = new ByteArrayInputStream(bytes);
ObjectInputStream oi = new ObjectInputStream(istream);
event = (WebEvent) oi.readObject();
istream.close();
} catch (ClassNotFoundException e) {
throw new WebEventException("Class not found: " +
e.getMessage());
} catch (IOException e) {
throw new WebEventException("IO Exception: " + e.getMessage());
}
return _sm.handleEvent(event);
}
WebEvent.java:
package com.cig.controller.event;
import java.io.Serializable;
public interface WebEvent
extends Serializable
{
public String getName();
}
chris!@#
----- Original Message -----
From: "Warren Crossing" <[EMAIL PROTECTED]>
To: "'Christopher G. Stach II'" <[EMAIL PROTECTED]>; "Warren Crossing"
<[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, June 04, 2001 8:01 PM
Subject: RE: java.net.MalformedURLException: unknown protocol: jndi
> hey, thanks for responding directly to me.. i will post this to the
jakarta
> & jboss lists
> so anyone else recieve this error knows about as much as we do =)
>
> 1. i picked up this problem again when i upgraded to 4.0b5. from 4.0b1
> 2. i recieve this error regardless of whether i start tomcat with
-nonaming
> 3. the ejb is declared stateless in the descriptor.
> 4. the ejb is declared in a resource element in the war descriptor
> 5. the lookup is performed by simple name each time ie "Manager" not
> "comp://javax.env/Manager" nor "jndi://Manager".
> 6. i believe this to be a jboss jndi problem as the
> StreamRemoteCall.exceptionRecievedFromServer states
> 7. my calls from servlet to this ejb actually work ( i see my ejb debug
> notes in jboss log )
> 8. my servlet invokes a class that looks up & calls the ejb
> 9. the lookup succeeds however the method invocation fails ( with the
below
> exception )
>
> i did read something about java naming security improvements and changes
in
> jdk1.3
> anyway i've changed catalina.policy to grant all permissions same with
> jboss.policy ( default )
> also removed lkeading comment from serv
ername in jndi.properties
>
> stateless ejb remote proxies ( ie client side interfaces ) are
serializable
> and interchangeable, so its not a proxy mixup/classloader/security thing?
> right?
> we're not using jarkarta/common/lib/jndi.jar as naming provider.. we're
> using jnp-client.jar
>
> check the signature on your ejbs..
>
> still no luck..
>
> can i clarify your jndi issue..
> are you invoking all test ejb methods from the same
> servlet/class/method/scope??
>
> regards,
>
> warren.
>
> -----Original Message-----
> From: Christopher G. Stach II [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, 3 June 2001 4:24 PM
> To: [EMAIL PROTECTED]
> Subject: java.net.MalformedURLException: unknown protocol: jndi
>
>
> Hey there, I'm using JBoss 2.2.2 and Tomcat 4.0b5 (separate) and I'm
> having this problem also. I have other EJBs that work just fine, but this
> one doesn't. Actually, it's just a single method in this EJB that doesn't
> work. I didn't find any followups to this thread. Have you figured this
> out?
>
> My stack trace, to compare:
>
> java.lang.reflect.UndeclaredThrowableException:
> java.net.MalformedURLException: unknown protocol: jndi
> at
>
sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteC
> all.java:245)
> at
> sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220)
> at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
> at
> org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker_Stub.invoke(Unknown
> Source)
> at
>
org.jboss.ejb.plugins.jrmp.interfaces.StatefulSessionProxy.invoke(StatefulSe
> ssionProxy.java:186)
> at $Proxy1.handleEvent(Unknown Source)
> at
>
com.cig.controller.web.WebControllerWebImpl.handleEvent(WebControllerWebImpl
> .java:113)
> at com.cig.controller.web.Main.doRequestHandler(Main.java:322)
> at com.cig.controller.web.Main.processRequest(Main.java:188)
> at com.cig.controller.web.Main.doPost(Main.java:93)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
>
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
> FilterChain.java:254)
> at
>
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
> ain.java:194)
> at
>
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
> va:255)
> at
>
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
> at
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
>
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
> va:225)
> at
>
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
> at
>
org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:2
> 46)
> at
>
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 64)
> at
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
> org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2252)
> at
>
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164
> )
> at
>
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
> at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:446)
> at
>
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 64)
> at
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
>
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
> :163)
> at
>
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
> 66)
> at
>
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
>
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:
> 875)
> at
>
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:952)
> at java.lang.Thread.run(Thread.java:484)
>
> chris
>
> To: "'tomcat-user@xxxxxxxxxxxxxxxxxx'" <tomcat-user@xxxxxxxxxxxxxxxxxx>
> Subject: java.net.MalformedURLException: unknown protocol: jndi
> From: Warren Crossing <WarrenC@xxxxxxxxxxxxx>
> Date: Tue, 3 Apr 2001 14:59:23 +1000
> Delivered-To: mailing list [EMAIL PROTECTED]
> list-help: <mailto:[EMAIL PROTECTED]>
> list-post: <mailto:[EMAIL PROTECTED]>
> list-unsubscribe: <mailto:[EMAIL PROTECTED]>
> Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
> Reply-To: tomcat-user@xxxxxxxxxxxxxxxxxx
>
>
>
> tomcat 4.0 beta2
>
> overview/symptom
>
> A servlet instance invokes a method on an enterprise bean.. the bean is a
> CLASS/STATIC field of the servlet - execution occurs normally
> however when this servlet calls a class that invokes the same field
> reference of the servlet class everything fails.
>
> detail
>
> 1 AbstractPortal.service ( servlet ) does naming lookup for ejb and
invokes
> Manager.load method [ OK ]
> 2 delegates processing to WorkFlow.processEvent
> 3 WorkFlow invokes store method on AbstractPortal.Manager ejb reference
> [FAILED]
> 4 control returns to AbstractPortal
> 5 AbstractPortal.service ( servlet ) invokes Manager.store method [ OK ]
>
> both calls can c class access to org.jboss.ejb.plugins.jrmp.server in
> www/WEB-INF/lib
> step 3 cannot c ${CATALINA_HOME}/common/lib/jndi.jar and causes stack
trace
> 1
>
> boundary condition
>
> if i take ${CATALINA_HOME}/common/lib/jndi.jar and place it in
> www/WEB-INF/lib i receive stacktrace 2 @ point 1
> i know the sequence works in tomcat 4.0 beta1
> launching catalina with -nonaming has no effect
>
> assumption
>
> org.apache.naming is not used in any calls..
> the classloader that loaded AbstractPortal also loaded WorkFlow
> the classloader that loaded WorkFlow is used to access
> AbstractPortal.Manager
>
> question
>
> what is different about these calls..
> 1 form 3 from 5 ?? except 1 & 5 occur from the class with the STATIC
> reference and is a servlet.. or something..
> could it be a subtle classloader/classpath issue??
>
> i will move the code around and try to reproduce it in a simple context..
>
> stacktrace 1
>
> java.lang.reflect.UndeclaredThrowableException:
> java.net.MalformedURLException: unknown protocol: jndi
> at
>
sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteC
> all.java:245)
> at
> sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220)
> at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
> at
> org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker_Stub.invoke(Unknown
> Source)
> at
>
org.jboss.ejb.plugins.jrmp.interfaces.StatelessSessionProxy.invoke(Stateless
> SessionProxy.java:188)
> at $Proxy1.store(Unknown Source)
> at
> nu.tradeforce.portal.content.WorkFlow.processEvent(WorkFlow.java:74)
> at
>
nu.tradeforce.portal.control.AbstractPortal.dispatch(AbstractPortal.java:110
> )
> at
>
nu.tradeforce.portal.control.AbstractPortal.service(AbstractPortal.java:174)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>
> stack trace 2
>
> javax.naming.CommunicationException. Root exception is
> java.rmi.ServerException: RemoteException occurred in server thread;
nested
> exception is:
> java.rmi.UnmarshalException: error unmarshalling arguments; nested
> exception is:
> java.net.MalformedURLException: unknown protocol: jndi
> java.rmi.UnmarshalException: error unmarshalling arguments; nested
exception
> is:
> java.net.MalformedURLException: unknown protocol: jndi
> java.net.MalformedURLException: unknown protocol: jndi
> at
>
sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteC
> all.java:245)
> at
> sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220)
> at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
> at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
> at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:295)
> at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:279)
> at javax.naming.InitialContext.lookup(InitialContext.java:354)
> at
>
nu.tradeforce.portal.control.AbstractPortal.lookupManager(AbstractPortal.jav
> a:73)
> at
> nu.tradeforce.portal.control.AbstractPortal.init(AbstractPortal.java:36)
>
>
> its completly bugged my out!! any ideas?
> -wozza
>