You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by mgyh <mg...@comsys.com> on 2009/02/11 23:17:47 UTC
Cannot instantiate class:
org.openejb.client.LocalInitialContextFactory
I am new to OpenEJB. So far, I am very pleased and would like to use this
for additional development. I installed OpenEJB successfully in Tomcat 6.0
(download the .war, deployed to webapps, then ran the installer). I created
a Bean and am able to successfully use this in a JSP program. This works
just fine using the following code.
p.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");
InitialContext context = new InitialContext(p);
QdbInterface qdbcontext = (QdbInterface)
context.lookup("QdbBeanLocal");
However, I would like to use this same bean from within a purely java
applet. If I put this above code into my java applets init() method, I get
the following error:
javax.naming.NoInitialContextException: Cannot instantiate class:
org.openejb.client.LocalInitialContextFactory [Root exception is
java.lang.ClassNotFoundException:
org.apache.openejb.client.LocalInitialContextFactory]
I have searched the message board and found a couple similar posts. The
suggestion was to ensure that the openejb-core-3.1.jar is in the CLASSPATH.
Could someone offer suggestion about what I am doing wrong? What is the
difference between the successful JSP code and the unsuccessful java applet?
I did add the openejb-core-3.1.jar to my classpath, but this didn't work.
Any ideas?
--
View this message in context: http://www.nabble.com/Cannot-instantiate-class%3A-org.openejb.client.LocalInitialContextFactory-tp21965469p21965469.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Cannot instantiate class: org.openejb.client.LocalInitialContextFactory
Posted by David Blevins <da...@visi.com>.
Not sure, maybe a new one called "Applet Client" or something?
-David
On Feb 12, 2009, at 8:27 PM, Karan Malhi wrote:
> Could you suggest a page on the wiki?
>
> On Thu, Feb 12, 2009 at 10:56 PM, David Blevins <david.blevins@visi.com
> >wrote:
>
>> Fantastic response.
>>
>> We should throw this one into a wiki page.
>>
>> -David
>>
>>
>> Begin forwarded message:
>>
>> Resent-From: <db...@visi.com>
>>> From: Karan Malhi <ka...@gmail.com>
>>> Date: February 12, 2009 7:09:06 PM PST
>>> To: users@openejb.apache.org
>>> Subject: Re: Cannot instantiate class:
>>> org.openejb.client.LocalInitialContextFactory
>>> Reply-To: users@openejb.apache.org
>>>
>>>
>>> Hi,
>>>
>>> Here is what you would need to do to make it work. Firstly, you
>>> would need
>>> to add the following jars in the root directory of your webapp --
>>> javaee-api.jar and openejb-client.jar (you can copy these from
>>> <Tomcat-install>/webapps/openejb/lib ).
>>> Update the Applet code as shown (notice that we are not using
>>> LocalInitialContextFactory here)
>>>
>>> Properties props = new Properties();
>>>
>>>
>>> props
>>> .put
>>> (Context
>>> .INITIAL_CONTEXT_FACTORY
>>> ,"org.apache.openejb.client.RemoteInitialContextFactory");
>>> props.put(Context.PROVIDER_URL, "
>>> http://127.0.0.1:8080/openejb/ejb");
>>> Context ctx = new InitialContext(props);
>>> Update the HTML as shown -- notice the archive attribute which has
>>> the
>>> comma
>>> separated list of jars needed by the applet (the version of jars
>>> on your
>>> machine might be different than mine- but that should not matter)
>>> <applet
>>> codebase = "."
>>> code = "qdbapplets.MyApplet.class"
>>> name = "TestApplet"
>>> width = "400"
>>> height = "300"
>>> hspace = "0"
>>> vspace = "0"
>>> align = "top"
>>> archive="openejb-client-3.1.1-SNAPSHOT.jar,javaee-api-5.0-1.jar"
>>>
>>>>
>>>> </applet>
>>>
>>>
>>>
>>> What is the
>>>>
>>>>> difference between the successful JSP code and the unsuccessful
>>>>> java
>>>>> applet? I did add the openejb-core-3.1.jar to my classpath, but
>>>>> this
>>>>> didn't work. Any ideas?
>>>>>
>>>>
>>>> JSP is running in the same VM as openejb, hence you can use
>>> LocalInitialContextFactory. Applet runs in a separate VM, hence it
>>> would
>>> need RemoteInitialContextFactory
>>>
>>> In order to get more information, please refer to this page --
>>> http://openejb.apache.org/3.0/clients.html
>>>
>>> --
>>> Karan Singh Malhi
>>>
>>
>>
>
>
> --
> Karan Singh Malhi
Re: Cannot instantiate class: org.openejb.client.LocalInitialContextFactory
Posted by Karan Malhi <ka...@gmail.com>.
Could you suggest a page on the wiki?
On Thu, Feb 12, 2009 at 10:56 PM, David Blevins <da...@visi.com>wrote:
> Fantastic response.
>
> We should throw this one into a wiki page.
>
> -David
>
>
> Begin forwarded message:
>
> Resent-From: <db...@visi.com>
>> From: Karan Malhi <ka...@gmail.com>
>> Date: February 12, 2009 7:09:06 PM PST
>> To: users@openejb.apache.org
>> Subject: Re: Cannot instantiate class:
>> org.openejb.client.LocalInitialContextFactory
>> Reply-To: users@openejb.apache.org
>>
>>
>> Hi,
>>
>> Here is what you would need to do to make it work. Firstly, you would need
>> to add the following jars in the root directory of your webapp --
>> javaee-api.jar and openejb-client.jar (you can copy these from
>> <Tomcat-install>/webapps/openejb/lib ).
>> Update the Applet code as shown (notice that we are not using
>> LocalInitialContextFactory here)
>>
>> Properties props = new Properties();
>>
>>
>> props.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.openejb.client.RemoteInitialContextFactory");
>> props.put(Context.PROVIDER_URL, "
>> http://127.0.0.1:8080/openejb/ejb");
>> Context ctx = new InitialContext(props);
>> Update the HTML as shown -- notice the archive attribute which has the
>> comma
>> separated list of jars needed by the applet (the version of jars on your
>> machine might be different than mine- but that should not matter)
>> <applet
>> codebase = "."
>> code = "qdbapplets.MyApplet.class"
>> name = "TestApplet"
>> width = "400"
>> height = "300"
>> hspace = "0"
>> vspace = "0"
>> align = "top"
>> archive="openejb-client-3.1.1-SNAPSHOT.jar,javaee-api-5.0-1.jar"
>>
>>>
>>> </applet>
>>
>>
>>
>> What is the
>>>
>>>> difference between the successful JSP code and the unsuccessful java
>>>> applet? I did add the openejb-core-3.1.jar to my classpath, but this
>>>> didn't work. Any ideas?
>>>>
>>>
>>> JSP is running in the same VM as openejb, hence you can use
>> LocalInitialContextFactory. Applet runs in a separate VM, hence it would
>> need RemoteInitialContextFactory
>>
>> In order to get more information, please refer to this page --
>> http://openejb.apache.org/3.0/clients.html
>>
>> --
>> Karan Singh Malhi
>>
>
>
--
Karan Singh Malhi
Fwd: Cannot instantiate class: org.openejb.client.LocalInitialContextFactory
Posted by David Blevins <da...@visi.com>.
Fantastic response.
We should throw this one into a wiki page.
-David
Begin forwarded message:
> Resent-From: <db...@visi.com>
> From: Karan Malhi <ka...@gmail.com>
> Date: February 12, 2009 7:09:06 PM PST
> To: users@openejb.apache.org
> Subject: Re: Cannot instantiate class:
> org.openejb.client.LocalInitialContextFactory
> Reply-To: users@openejb.apache.org
>
> Hi,
>
> Here is what you would need to do to make it work. Firstly, you
> would need
> to add the following jars in the root directory of your webapp --
> javaee-api.jar and openejb-client.jar (you can copy these from
> <Tomcat-install>/webapps/openejb/lib ).
> Update the Applet code as shown (notice that we are not using
> LocalInitialContextFactory here)
>
> Properties props = new Properties();
>
> props
> .put
> (Context
> .INITIAL_CONTEXT_FACTORY
> ,"org.apache.openejb.client.RemoteInitialContextFactory");
> props.put(Context.PROVIDER_URL, "
> http://127.0.0.1:8080/openejb/ejb");
> Context ctx = new InitialContext(props);
> Update the HTML as shown -- notice the archive attribute which has
> the comma
> separated list of jars needed by the applet (the version of jars on
> your
> machine might be different than mine- but that should not matter)
> <applet
> codebase = "."
> code = "qdbapplets.MyApplet.class"
> name = "TestApplet"
> width = "400"
> height = "300"
> hspace = "0"
> vspace = "0"
> align = "top"
> archive="openejb-client-3.1.1-SNAPSHOT.jar,javaee-api-5.0-1.jar"
>>
> </applet>
>
>
>
>> What is the
>>> difference between the successful JSP code and the unsuccessful java
>>> applet? I did add the openejb-core-3.1.jar to my classpath, but
>>> this
>>> didn't work. Any ideas?
>>
> JSP is running in the same VM as openejb, hence you can use
> LocalInitialContextFactory. Applet runs in a separate VM, hence it
> would
> need RemoteInitialContextFactory
>
> In order to get more information, please refer to this page --
> http://openejb.apache.org/3.0/clients.html
>
> --
> Karan Singh Malhi
Re: Cannot instantiate class: org.openejb.client.LocalInitialContextFactory
Posted by Karan Malhi <ka...@gmail.com>.
Hi,
Took me a while and help from David Blevins, but we figured out a solution
to the issues concerning applets. I have created an example which you can
checkout from our svn repository. Read the README.txt of the example first
before you try to run the example. I have tried to be as detailed as
possible in the README.txt, if you have any suggestions to improve the
instructions in it, that would be really appreciated. The maven pom.xml is
not perfect and kind of tries to do some tasks twice -- like signing jar
files (which should not affect the final outcome of the example).
Here is the link to the README.txt in case you want to quickly go over the
example
http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/webapps/applet/README.txt?revision=744815&view=markup&pathrev=744815
On Sat, Feb 14, 2009 at 2:30 AM, Karan Malhi <ka...@gmail.com> wrote:
> You would need to sign your applet. A good tutorial on how to do that is
> available here
> http://www-personal.umich.edu/~lsiden/tutorials/signed-applet/signed-applet.html<http://www-personal.umich.edu/%7Elsiden/tutorials/signed-applet/signed-applet.html>
> Also, make sure to sign openejb-client.jar too. This will get you past the
> above restriction, however I still could not get it to work (though I got
> past the security restrictions). I wrote a desktop client and it works fine.
> Need to dig deeper into it.
>
> On Fri, Feb 13, 2009 at 11:27 AM, mgyh <mg...@comsys.com> wrote:
>
>>
>> Your suggestions did get me past my initial problem. I guess that I did
>> not
>> realize that the applet was running in a separate VM. I don't think that
>> I
>> completely understand that. I'll do some reading on the side to get a
>> better grasp of this.
>>
>> However, once I made these changes, I get an AccessControlException as
>> follows:
>>
>> java.security.AccessControlException: access denied
>> (java.util.PropertyPermission /QdbBeanLocal read)
>>
>> could you offer suggestions to get past this? QdbBeanLocal is my JNDI
>> name
>> for my bean, which is located successfully from jsp. I have tried the
>> following unsuccessfully:
>> 1) I tried the JNDI name QdbBeanRemote also
>> 2) I added the following permissions to Tomcat's catalina.policy file
>> permission org.apache.naming.JndiPermission
>> "jndi://localhost/QdbBean", "read";
>> permission org.apache.naming.JndiPermission
>> "jndi://localhost/QdbBeanLocal", "read";
>> permission org.apache.naming.JndiPermission
>> "jndi://localhost/QdbBeanRemote", "read";
>> 3) restarted Tomcat
>>
>> no luck. I am not particularly good at understanding security policy.
>> What
>> am I missing?
>>
>>
>>
>> KMalhi wrote:
>> >
>> > Hi,
>> >
>> > Here is what you would need to do to make it work. Firstly, you would
>> need
>> > to add the following jars in the root directory of your webapp --
>> > javaee-api.jar and openejb-client.jar (you can copy these from
>> > <Tomcat-install>/webapps/openejb/lib ).
>> > Update the Applet code as shown (notice that we are not using
>> > LocalInitialContextFactory here)
>> >
>> > Properties props = new Properties();
>> >
>> >
>> props.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.openejb.client.RemoteInitialContextFactory");
>> > props.put(Context.PROVIDER_URL, "
>> > http://127.0.0.1:8080/openejb/ejb");
>> > Context ctx = new InitialContext(props);
>> > Update the HTML as shown -- notice the archive attribute which has the
>> > comma
>> > separated list of jars needed by the applet (the version of jars on your
>> > machine might be different than mine- but that should not matter)
>> > <applet
>> > codebase = "."
>> > code = "qdbapplets.MyApplet.class"
>> > name = "TestApplet"
>> > width = "400"
>> > height = "300"
>> > hspace = "0"
>> > vspace = "0"
>> > align = "top"
>> > archive="openejb-client-3.1.1-SNAPSHOT.jar,javaee-api-5.0-1.jar"
>> >>
>> > </applet>
>> >
>> >
>> >
>> >> What is the
>> >> > difference between the successful JSP code and the unsuccessful java
>> >> > applet? I did add the openejb-core-3.1.jar to my classpath, but this
>> >> > didn't work. Any ideas?
>> >>
>> > JSP is running in the same VM as openejb, hence you can use
>> > LocalInitialContextFactory. Applet runs in a separate VM, hence it would
>> > need RemoteInitialContextFactory
>> >
>> > In order to get more information, please refer to this page --
>> > http://openejb.apache.org/3.0/clients.html
>> >
>> > --
>> > Karan Singh Malhi
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Cannot-instantiate-class%3A-org.openejb.client.LocalInitialContextFactory-tp21965469p21999832.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Karan Singh Malhi
>
--
Karan Singh Malhi
Re: Cannot instantiate class: org.openejb.client.LocalInitialContextFactory
Posted by Karan Malhi <ka...@gmail.com>.
You would need to sign your applet. A good tutorial on how to do that is
available here
http://www-personal.umich.edu/~lsiden/tutorials/signed-applet/signed-applet.html
Also, make sure to sign openejb-client.jar too. This will get you past the
above restriction, however I still could not get it to work (though I got
past the security restrictions). I wrote a desktop client and it works fine.
Need to dig deeper into it.
On Fri, Feb 13, 2009 at 11:27 AM, mgyh <mg...@comsys.com> wrote:
>
> Your suggestions did get me past my initial problem. I guess that I did
> not
> realize that the applet was running in a separate VM. I don't think that I
> completely understand that. I'll do some reading on the side to get a
> better grasp of this.
>
> However, once I made these changes, I get an AccessControlException as
> follows:
>
> java.security.AccessControlException: access denied
> (java.util.PropertyPermission /QdbBeanLocal read)
>
> could you offer suggestions to get past this? QdbBeanLocal is my JNDI name
> for my bean, which is located successfully from jsp. I have tried the
> following unsuccessfully:
> 1) I tried the JNDI name QdbBeanRemote also
> 2) I added the following permissions to Tomcat's catalina.policy file
> permission org.apache.naming.JndiPermission
> "jndi://localhost/QdbBean", "read";
> permission org.apache.naming.JndiPermission
> "jndi://localhost/QdbBeanLocal", "read";
> permission org.apache.naming.JndiPermission
> "jndi://localhost/QdbBeanRemote", "read";
> 3) restarted Tomcat
>
> no luck. I am not particularly good at understanding security policy. What
> am I missing?
>
>
>
> KMalhi wrote:
> >
> > Hi,
> >
> > Here is what you would need to do to make it work. Firstly, you would
> need
> > to add the following jars in the root directory of your webapp --
> > javaee-api.jar and openejb-client.jar (you can copy these from
> > <Tomcat-install>/webapps/openejb/lib ).
> > Update the Applet code as shown (notice that we are not using
> > LocalInitialContextFactory here)
> >
> > Properties props = new Properties();
> >
> >
> props.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.openejb.client.RemoteInitialContextFactory");
> > props.put(Context.PROVIDER_URL, "
> > http://127.0.0.1:8080/openejb/ejb");
> > Context ctx = new InitialContext(props);
> > Update the HTML as shown -- notice the archive attribute which has the
> > comma
> > separated list of jars needed by the applet (the version of jars on your
> > machine might be different than mine- but that should not matter)
> > <applet
> > codebase = "."
> > code = "qdbapplets.MyApplet.class"
> > name = "TestApplet"
> > width = "400"
> > height = "300"
> > hspace = "0"
> > vspace = "0"
> > align = "top"
> > archive="openejb-client-3.1.1-SNAPSHOT.jar,javaee-api-5.0-1.jar"
> >>
> > </applet>
> >
> >
> >
> >> What is the
> >> > difference between the successful JSP code and the unsuccessful java
> >> > applet? I did add the openejb-core-3.1.jar to my classpath, but this
> >> > didn't work. Any ideas?
> >>
> > JSP is running in the same VM as openejb, hence you can use
> > LocalInitialContextFactory. Applet runs in a separate VM, hence it would
> > need RemoteInitialContextFactory
> >
> > In order to get more information, please refer to this page --
> > http://openejb.apache.org/3.0/clients.html
> >
> > --
> > Karan Singh Malhi
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Cannot-instantiate-class%3A-org.openejb.client.LocalInitialContextFactory-tp21965469p21999832.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>
--
Karan Singh Malhi
R: Cannot instantiate class: org.openejb.client.LocalInitialContextFactory
Posted by Paolo Spadafora <p....@gmail.com>.
Hi,
I think you have to set java permission on applet side. Probably need to
sign the applet.
Also, when doing a remote lookup you need to obtain the remote interface
(QdbBeanRemote), not the local.
Paolo
-----Messaggio originale-----
Da: mgyh [mailto:mgibby@comsys.com]
Inviato: venerdì 13 febbraio 2009 17.27
A: users@openejb.apache.org
Oggetto: Re: Cannot instantiate class:
org.openejb.client.LocalInitialContextFactory
Your suggestions did get me past my initial problem. I guess that I did not
realize that the applet was running in a separate VM. I don't think that I
completely understand that. I'll do some reading on the side to get a
better grasp of this.
However, once I made these changes, I get an AccessControlException as
follows:
java.security.AccessControlException: access denied
(java.util.PropertyPermission /QdbBeanLocal read)
could you offer suggestions to get past this? QdbBeanLocal is my JNDI name
for my bean, which is located successfully from jsp. I have tried the
following unsuccessfully:
1) I tried the JNDI name QdbBeanRemote also
2) I added the following permissions to Tomcat's catalina.policy file
permission org.apache.naming.JndiPermission
"jndi://localhost/QdbBean", "read";
permission org.apache.naming.JndiPermission
"jndi://localhost/QdbBeanLocal", "read";
permission org.apache.naming.JndiPermission
"jndi://localhost/QdbBeanRemote", "read";
3) restarted Tomcat
no luck. I am not particularly good at understanding security policy. What
am I missing?
KMalhi wrote:
>
> Hi,
>
> Here is what you would need to do to make it work. Firstly, you would need
> to add the following jars in the root directory of your webapp --
> javaee-api.jar and openejb-client.jar (you can copy these from
> <Tomcat-install>/webapps/openejb/lib ).
> Update the Applet code as shown (notice that we are not using
> LocalInitialContextFactory here)
>
> Properties props = new Properties();
>
>
props.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.openejb.client.RemoteI
nitialContextFactory");
> props.put(Context.PROVIDER_URL, "
> http://127.0.0.1:8080/openejb/ejb");
> Context ctx = new InitialContext(props);
> Update the HTML as shown -- notice the archive attribute which has the
> comma
> separated list of jars needed by the applet (the version of jars on your
> machine might be different than mine- but that should not matter)
> <applet
> codebase = "."
> code = "qdbapplets.MyApplet.class"
> name = "TestApplet"
> width = "400"
> height = "300"
> hspace = "0"
> vspace = "0"
> align = "top"
> archive="openejb-client-3.1.1-SNAPSHOT.jar,javaee-api-5.0-1.jar"
>>
> </applet>
>
>
>
>> What is the
>> > difference between the successful JSP code and the unsuccessful java
>> > applet? I did add the openejb-core-3.1.jar to my classpath, but this
>> > didn't work. Any ideas?
>>
> JSP is running in the same VM as openejb, hence you can use
> LocalInitialContextFactory. Applet runs in a separate VM, hence it would
> need RemoteInitialContextFactory
>
> In order to get more information, please refer to this page --
> http://openejb.apache.org/3.0/clients.html
>
> --
> Karan Singh Malhi
>
>
--
View this message in context:
http://www.nabble.com/Cannot-instantiate-class%3A-org.openejb.client.LocalIn
itialContextFactory-tp21965469p21999832.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Cannot instantiate class:
org.openejb.client.LocalInitialContextFactory
Posted by mgyh <mg...@comsys.com>.
Your suggestions did get me past my initial problem. I guess that I did not
realize that the applet was running in a separate VM. I don't think that I
completely understand that. I'll do some reading on the side to get a
better grasp of this.
However, once I made these changes, I get an AccessControlException as
follows:
java.security.AccessControlException: access denied
(java.util.PropertyPermission /QdbBeanLocal read)
could you offer suggestions to get past this? QdbBeanLocal is my JNDI name
for my bean, which is located successfully from jsp. I have tried the
following unsuccessfully:
1) I tried the JNDI name QdbBeanRemote also
2) I added the following permissions to Tomcat's catalina.policy file
permission org.apache.naming.JndiPermission
"jndi://localhost/QdbBean", "read";
permission org.apache.naming.JndiPermission
"jndi://localhost/QdbBeanLocal", "read";
permission org.apache.naming.JndiPermission
"jndi://localhost/QdbBeanRemote", "read";
3) restarted Tomcat
no luck. I am not particularly good at understanding security policy. What
am I missing?
KMalhi wrote:
>
> Hi,
>
> Here is what you would need to do to make it work. Firstly, you would need
> to add the following jars in the root directory of your webapp --
> javaee-api.jar and openejb-client.jar (you can copy these from
> <Tomcat-install>/webapps/openejb/lib ).
> Update the Applet code as shown (notice that we are not using
> LocalInitialContextFactory here)
>
> Properties props = new Properties();
>
> props.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.openejb.client.RemoteInitialContextFactory");
> props.put(Context.PROVIDER_URL, "
> http://127.0.0.1:8080/openejb/ejb");
> Context ctx = new InitialContext(props);
> Update the HTML as shown -- notice the archive attribute which has the
> comma
> separated list of jars needed by the applet (the version of jars on your
> machine might be different than mine- but that should not matter)
> <applet
> codebase = "."
> code = "qdbapplets.MyApplet.class"
> name = "TestApplet"
> width = "400"
> height = "300"
> hspace = "0"
> vspace = "0"
> align = "top"
> archive="openejb-client-3.1.1-SNAPSHOT.jar,javaee-api-5.0-1.jar"
>>
> </applet>
>
>
>
>> What is the
>> > difference between the successful JSP code and the unsuccessful java
>> > applet? I did add the openejb-core-3.1.jar to my classpath, but this
>> > didn't work. Any ideas?
>>
> JSP is running in the same VM as openejb, hence you can use
> LocalInitialContextFactory. Applet runs in a separate VM, hence it would
> need RemoteInitialContextFactory
>
> In order to get more information, please refer to this page --
> http://openejb.apache.org/3.0/clients.html
>
> --
> Karan Singh Malhi
>
>
--
View this message in context: http://www.nabble.com/Cannot-instantiate-class%3A-org.openejb.client.LocalInitialContextFactory-tp21965469p21999832.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Cannot instantiate class: org.openejb.client.LocalInitialContextFactory
Posted by Karan Malhi <ka...@gmail.com>.
Hi,
Here is what you would need to do to make it work. Firstly, you would need
to add the following jars in the root directory of your webapp --
javaee-api.jar and openejb-client.jar (you can copy these from
<Tomcat-install>/webapps/openejb/lib ).
Update the Applet code as shown (notice that we are not using
LocalInitialContextFactory here)
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.openejb.client.RemoteInitialContextFactory");
props.put(Context.PROVIDER_URL, "
http://127.0.0.1:8080/openejb/ejb");
Context ctx = new InitialContext(props);
Update the HTML as shown -- notice the archive attribute which has the comma
separated list of jars needed by the applet (the version of jars on your
machine might be different than mine- but that should not matter)
<applet
codebase = "."
code = "qdbapplets.MyApplet.class"
name = "TestApplet"
width = "400"
height = "300"
hspace = "0"
vspace = "0"
align = "top"
archive="openejb-client-3.1.1-SNAPSHOT.jar,javaee-api-5.0-1.jar"
>
</applet>
> What is the
> > difference between the successful JSP code and the unsuccessful java
> > applet? I did add the openejb-core-3.1.jar to my classpath, but this
> > didn't work. Any ideas?
>
JSP is running in the same VM as openejb, hence you can use
LocalInitialContextFactory. Applet runs in a separate VM, hence it would
need RemoteInitialContextFactory
In order to get more information, please refer to this page --
http://openejb.apache.org/3.0/clients.html
--
Karan Singh Malhi
Re: Cannot instantiate class:
org.openejb.client.LocalInitialContextFactory
Posted by mgyh <mg...@comsys.com>.
By the way, I am trying to start the java applet using the following HTML
tag:
<applet
codebase = "."
code = "qdbapplets.MyApplet.class"
name = "TestApplet"
width = "400"
height = "300"
hspace = "0"
vspace = "0"
align = "top"
>
</applet>
mgyh wrote:
>
> I am new to OpenEJB. So far, I am very pleased and would like to use this
> for additional development. I installed OpenEJB successfully in Tomcat
> 6.0 (download the .war, deployed to webapps, then ran the installer). I
> created a Bean and am able to successfully use this in a JSP program.
> This works just fine using the following code.
>
> p.put(Context.INITIAL_CONTEXT_FACTORY,
> "org.apache.openejb.client.LocalInitialContextFactory");
> InitialContext context = new InitialContext(p);
> QdbInterface qdbcontext = (QdbInterface)
> context.lookup("QdbBeanLocal");
>
> However, I would like to use this same bean from within a purely java
> applet. If I put this above code into my java applets init() method, I
> get the following error:
>
> javax.naming.NoInitialContextException: Cannot instantiate class:
> org.openejb.client.LocalInitialContextFactory [Root exception is
> java.lang.ClassNotFoundException:
> org.apache.openejb.client.LocalInitialContextFactory]
>
> I have searched the message board and found a couple similar posts. The
> suggestion was to ensure that the openejb-core-3.1.jar is in the
> CLASSPATH.
>
> Could someone offer suggestion about what I am doing wrong? What is the
> difference between the successful JSP code and the unsuccessful java
> applet? I did add the openejb-core-3.1.jar to my classpath, but this
> didn't work. Any ideas?
>
--
View this message in context: http://www.nabble.com/Cannot-instantiate-class%3A-org.openejb.client.LocalInitialContextFactory-tp21965469p21968538.html
Sent from the OpenEJB User mailing list archive at Nabble.com.