wood burning stoves 2.0*
The moose likes JBoss/WildFly and the fly likes Issue Whie Deploying EJB on JBoss AS 5.1.0... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Issue Whie Deploying EJB on JBoss AS 5.1.0..." Watch "Issue Whie Deploying EJB on JBoss AS 5.1.0..." New topic
Author

Issue Whie Deploying EJB on JBoss AS 5.1.0...

Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Hi Everyone,

I am currently using Eclipse 3.5 as my IDE and JBoss AS 5.1.0. When i create a Application Client Project in Eclipse and put in some code. When i try to add the the project to the JBoss server it gives the error Message "The server does not support version 5.0 of the Application Client Module specification." I even tried with 1.4 and 1.3 but still they don't work! Could you please tell me how to solve the issue?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9963
    
163

Where do you see that error? In Eclipse? And what does version of application client module mean?


[My Blog] [JavaRanch Journal]
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
When I select "Add/Remove Projects" after right clicking on JBoss Server! There i get the option of adding the JAR to the server! When I select my JAR i get this error and i am unable to add it on the server!
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

An Application Client Project is used to create a stand-alone application that connects to the app server remotely. It is not meant to be something that gets deployed to an app server. I think that the client app showing up in the Available list on the Add And Remove dialog is a bug in Eclipse (unless there are other types of server that allow this).

I think what you want to do instead is start the app server and then right-click the client app project and select "Run a Java App".


JBoss In Action
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
I want to create a simple EJB project on Eclipse and deploy and run it on the server!

I created a new "EJB Project" added the Home, Remote and Bean class in a package and coded a client code in another package. Then when i right-click on the project and select "Run On Server". After the server is running I click on the client code ConverterCleint.java and select the Run Java Application. But nothing happens. All I get is an error! I don't even know if its the right way to run the EJB, so i am looking for some help.

I have attached my project code structure below, if it helps! The Project is named "Converter".




[Thumbnail for Directory Tree.JPG]

Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

What error are you getting?
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Well i am really new to EJB so still am finding my way!

I first right clicked on the project and selected "Run On Server" which is JBoss GA 5.1.0. Then i selected the ConverterClient and selected "Run Java Application" i get the following error:

Caught an unexpected exception!
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.simple.clientCode.ConverterClient.main(ConverterClient.java:22)

First of all i would like to know am i doing the right thing! I hope this is the right way to run an EJB code!
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

Sounds like you are missing a jndi.properties file. Here is one, it needs to be in your classpath:



Are you following a tutorial for this? The JBoss Tools documentation contains many good tutorials.
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Yes I am following a tutorial for this! Actually the code i wrote was something which i got from the Sun website for the J2EE 1.4 tutorial!

Where do i put the properties? In a file or add in a classpath?
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
After a little bit of searching... I found something that helped!

I added this part of the code in my Client code.

Before:



After:




When I start my JBoss server and run the Client, I get the following error:

javax.naming.NameNotFoundException: comp not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
at org.jnp.server.NamingServer.lookup(NamingServer.java:396)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:726)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.simple.cleintCode.ConverterClient.main(ConverterClient.java:27)

Please let me know how to get rid of this name binding issue!
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

The "java:/comp/env" namespace should be used only within the app server (such as from a servlet). Since you are running from a remote client (that is, a client running in a separate JVM) then you should not use that namespace. Instead, just do:

Context initial = new InitialContext();
Object objref = initial.lookup("ejb/Converter");

Are you sure you have to correct JNDI name (ejb/Converter) for the EJB? JBoss AS 5.1 will tell you the JNDI name of the EJB as it deploys (you'll see that in the console view in Eclipse). Also, you can use JNDIView to determine the name.
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Thanks Peter for sticking with me! But the thing is i changed my code with the one you wrote and now i get no "comp not bound" error! But i don't get any output as well!

I debugged the code and i found out that the code isn't going ahead of the line, and its just stuck there:



Well here's the long and short of the mess i have created. Its a long one, so please be patient!

Home Class:



Remote Class:



Bean Class:


My Deployment Descriptor is in Eclipse is:



Client Application Code:


I have attached the console output of my JBoss when i start my server as well because I could not find any JNDI name which i related to the Converter EJB! The Converter.jar is added to server! I tried attaching the file. but txt, log or many other attachments are not allowed!



I hope this would help you and solve my pathetic situation! Thanks a lot again!



Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

Why are you using EJB 2.1?
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Sorry Peter, didn't know that the EJB 3.0 and EJB 2.1 had so much different. By now you may found out that how novice I am!

Went through some tutorials and found the examples. Even if its EJB 2.1 it should still be working, right? Could you please help me do that!
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
After going through some EJB 3.0 tutorials! I have changed my code to somewhat like EJB 3.0! I would like to know, that in EJB 3.0 there is no need for Home Interface?

Plus my current code is:

Bean Class:


Remote Interface:


Client Application:


Is there anything extra that i have to do? My deployment descriptor is the same! Although i read somewhere that deployment descriptor is not necessary in EJB 3.0!

The thing is it still doesn't work!
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

I just noticed this:

environment.put(Context.PROVIDER_URL, "localhost:8009");

The port should be 1099, not 8009. And the name being looked up is incorrect, it should be:

converterRemote = (ConverterRemote) initial.lookup("ConverterBean/remote");

You can always use JNIView to see the names of the EJBs.

Not sure if those are the only issues, but its a good place to start.

And, yes there is no home interface in EJB3. All you need is a local and/or a remote interface and a bean class that implements them.
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Well this is my JNDI view! You were right about the Bean name!!!



Well it is kinda strange, but i tried running it with 1009 it gave an error like this:


But when i use 8009 i don't get this!

And when the server is starting i found one line saying:
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

1099
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
I tried with 1099! And it worked! Thanks a lot Peter! Couldn't have done it without you! Will be back soon with some other problem maybe!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Issue Whie Deploying EJB on JBoss AS 5.1.0...
 
Similar Threads
Jboss is not starting from eclipse
Long Time Taken to Deploy WAR on JBoss...
Migrating from RAD IDE to Eclipse IDE
How to install Jboss 4.0 in windows Operating Systems
Newbie question - how to deploy application to JBoss