On 2/14/11 1:57 AM, Jose Alvarez de Lara wrote:
> Hi Cheng,
> I did what you say but I do not know how have you packaged the
> appclient jar file.
> My system is winXP and when I type in the command line
> jar tvf mdb-client.jar
> this is what I get
> 62 Mon Feb 14 06:32:16 CET 2011 META-INF/MANIFEST.MF
> 0 Mon Feb 14 06:28:54 CET 2011 META-INF/
> 495 Mon Feb 14 06:38:28 CET 2011 META-INF/application-client.xml
> 0 Mon Feb 14 06:29:54 CET 2011 client/
> 1104 Mon Feb 14 06:31:26 CET 2011 client/Main.class
> and nothing about sb/PublisherBeanRemote.class.
> I get the appclient jar file from the Eclipse IDE option right click
> on the project, Export -> App Client jar file,
> so I do not understand how you have done it.
This is also what I did. But I then manually update the jar with 'jar
uvf' to add the missing class. I tried to find a way to let Eclipse do
it but couldn't. My personal preference is to switch to command line
for things that are not obvious in tools. You can also try to make a
EAR project that depends on ejb and appclient subprojects, and somehow
configure the EAR project to have a lib jar containing the ejb interfaces.
-cheng
> Will you can explain how is it.
> Thanks,
> Jose
> *From:* Cheng Fang <mailto:cheng.fang_at_oracle.com>
> *Sent:* Friday, February 11, 2011 9:12 PM
> *To:* ejb_at_glassfish.java.net <mailto:ejb_at_glassfish.java.net>
> *Cc:* Jose Alvarez de Lara <mailto:dakhla.0563_at_hotmail.com>
> *Subject:* Re: Naming Exception
>
> Hi Jose,
>
> It could be your project config problem inside eclipse.
>
> Your appclient MANIFEST.MF file is missing a Main-Class attr. I
> changed it to:
>
> Manifest-Version: 1.0
> Class-Path:
> Main-Class: client.Main
>
> You also need to include the remote business interface class in
> appclient jar, as follows:
>
> jar tvf $tmp/mdb-client.jar
> 62 Fri Feb 11 15:02:20 EST 2011 META-INF/MANIFEST.MF
> 0 Wed Feb 09 17:52:16 EST 2011 META-INF/
> 433 Wed Feb 09 17:52:16 EST 2011 META-INF/application-client.xml
> 0 Wed Feb 09 08:40:46 EST 2011 client/
> 1090 Fri Feb 11 14:36:06 EST 2011 client/Main.class
> 247 Fri Feb 11 14:35:28 EST 2011 sb/PublisherBeanRemote.class
>
> I was able to run it with these changes:
>
> asadmin create-jms-resource --restype javax.jms.TopicConnectionFactory
> jms/ConnectionFactory
> asadmin create-jms-resource --restype javax.jms.Topic jms/Topic
> asadmin deploy --force true $tmp/mdb-bean.jar
> asadmin deploy --force true --retrieve /tmp $tmp/mdb-client.jar
> appclient -client /tmp/mdb-clientClient.jar
>
> These are logged in server.log:
> [#|2011-02-11T15:04:35.303-0500|INFO|glassfish3.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=160;_ThreadName=Thread-1;|PUBLISHER:
> Setting message text to: TR|#]
>
> [#|2011-02-11T15:04:35.399-0500|INFO|glassfish3.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=160;_ThreadName=Thread-1;|PUBLISHER:
> Setting message text to: ET|#]
>
> [#|2011-02-11T15:04:35.430-0500|INFO|glassfish3.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=160;_ThreadName=Thread-1;|ET
> to TR say :ET#Hola TR...|#]
>
> [#|2011-02-11T15:04:35.432-0500|INFO|glassfish3.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=167;_ThreadName=Thread-1;|TR
> to ET say :TR#Hola ET...|#]
>
> -cheng
>
> On 2/11/11 9:23 AM, Jose Alvarez de Lara wrote:
>> Thanks Chang. Here it is.
>>
>> *From:* Cheng Fang <mailto:cheng.fang_at_oracle.com>
>> *Sent:* Thursday, February 10, 2011 8:19 PM
>> *To:* ejb_at_glassfish.java.net <mailto:ejb_at_glassfish.java.net>
>> *Cc:* Jose Alvarez de Lara <mailto:dakhla.0563_at_hotmail.com>
>> *Subject:* Re: Naming Exception
>>
>> Can you attach a test app, preferably with source code?
>>
>> Thanks,
>> -cheng
>>
>> On 2/10/11 9:41 AM, Jose Alvarez de Lara wrote:
>>> Hi,
>>> I am trying an Application Client Project on Eclipse Helios SR1. The
>>> app contains a mdb-bean.jar in its classpath that is
>>> a mdb publish/subscribe and an ejb with a remote interface.
>>> This is my code in the client,
>>> private void test() {
>>> try {
>>> PublisherBeanRemote publisher = (PublisherBeanRemote) new
>>> InitialContext().lookup("java:global/mdb-bean/PublisherBean");
>>> publisher.publishNews("TR", "ET#Hola TR...");
>>> publisher.publishNews("ET", "TR#Hola ET...");
>>> } catch (NamingException e) {
>>> // TODO Auto-generated catch block
>>> e.printStackTrace();
>>> }
>>> }
>>> being PublisherBean the implementation of the ejb.
>>> And this is what I get when I run the app,
>>> java.lang.NullPointerException
>>> at
>>> com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:297)
>>> at
>>> com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:271)
>>> at
>>> com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:430)
>>> at javax.naming.InitialContext.lookup(InitialContext.java:392)
>>> at client.Main.test(Main.java:25)
>>> at client.Main.main(Main.java:13)
>>> javax.naming.NamingException: Lookup failed for
>>> 'java:global/mdb-bean/PublisherBean' in SerialContext [Root
>>> exception is javax.naming.NamingException: Unable to acquire
>>> SerialContextProvider for SerialContext [Root exception is
>>> java.lang.NullPointerException]]
>>> at
>>> com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:442)
>>> at javax.naming.InitialContext.lookup(InitialContext.java:392)
>>> at client.Main.test(Main.java:25)
>>> at client.Main.main(Main.java:13)
>>> Caused by: javax.naming.NamingException: Unable to acquire
>>> SerialContextProvider for SerialContext [Root exception is
>>> java.lang.NullPointerException]
>>> at
>>> com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:276)
>>> at
>>> com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:430)
>>> ... 3 more
>>> Caused by: java.lang.NullPointerException
>>> at
>>> com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:297)
>>> at
>>> com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:271)
>>> ... 4 more
>>> The only reason I guess is causing this exception is that the
>>> mdb-bean.jar is not in the classpath.
>>> How can I be sure about it?
>>> Thanks in advance,
>>> Jose