How to deploy EJB on server? - eclipse

I am learning EJB3 from last few days. I have many questions regarding EJB, application servers and deployment of EJB.
To start with, I have created one simple helloworld stateless session bean but I don't know how to deploy it on server. It has single bean class, bean interface and one servlet client. I have used eclipse to develop this project.
None of the books that I read gives step by step details about how to put EJB on server and how to access those beans.
I have JBoss 6 server and I also have Java EE budle downloaded from sun website. Does this Java EE bundle contains Glassfish server? or do I need to download it separately?
Can anyone please give me step by step details of how to put my bean and its client on server (JBoss or Java EE)?
And why do we need to include bean interface class in EJB client code? I mean either we need to keep client and bean in same package or if we keep them in seperate packages we need to import bean interfaces in client code. Am I right?

With Java EE 6, you can package your Servlet and your EJB in a WAR (either package your EJB in a JAR and put it in WEB-INF/lib or simply put all classes in WEB-INF/classes). And to deploy this WAR, copy it to:
$GLASSFISH_HOME/domains/<domain1>/autodeploy for GlassFish v3*
$JBOSS_HOME/server/default/deploy for JBoss 6
With Java EE 5, you'll have to package your code in a EAR.
And if you want to deploy your application from Eclipse (using the Eclipse WTP), you'll have to install the appropriate server adapter. For Eclipse Galileo and GlassFish (there is currently no adapter for JBoss 6 AFAIK), right-click the server view, select New > Server, click on Download additional server adapters and select the GlassFish adapter. Finish to define your new GlassFish v3 Java EE 6 server and deploy your application on it (right-click on your application then Run As > Run on Server). For Eclipse Helios and GlassFish, you can follow the link given by #VonC (manual install) or check this answer (install via the Update Site).

You need to add GlassFish to your Eclipse installation (see GlassFish plugin for Eclipse).
The full process is described here (with the latest Eclipse Helios 3.6M6)

You should export as EJB into your jboss<version>\server/default/deploy folder and then add the build path for it on the servlet's web project. You can "Run on Server" and choose an application server just like you would in any project, no need to export the WAR although if you do that, you're gonna have to re-export your WAR every time you modify your code
AFAIK there's no Eclipse plugin for JBoss 6 but Eclipse provides one for 5.1

Related

Deploying Java project in Weblogic server

I have created a Java project. Which has a JMS Listener onMessage. How to deploy this java project in the weblogic server? There is another webproject in the weblogic server which will place an object in the Queue, that object needs to be consumed by my Java project. I need this Java project to be deployed independently. Please help.
Thanks,
Arvinth

Configuring Mojarra 2.1.X on Eclipse Indigo

The User Library download from Properties/Project Facets/Java Server Faces only lists Apache and Mojarra 2.0.X options. And setting up a user library manually, if I add javax.faces-2.1.11.jar, it doesn't error, puts the jar in the entry, then says \jarfiles\jaf (missing). So I see no way to use Mojarra 2.1.X.
I am unable to understand completely that what are you saying? But as much as I can I understood that "you want you use Mojarra 2.1.X" in your project. Now here is the thing You should mention the server that you are using.
If you are using glassfish 3.1.x then you have to replace your javax.faces.jar present in /glassfish/modules folder with javax.faces-2.1.11.jar as the glassfish built in jar javax.faces.jar enforce glassfish to use Mojarra 2.1.6.Now if it is Tomcat then it is up to you that you have to add all jsf compulsory jars in your lib folder :) One last thing that if you are using anyother server which has built in support for JSF and you are unable to find How to replace your jar from that server or you have issue with admin access over that server then you can also upgrade JSF by placing the newer javax.faces.jar file in webapp's own /WEB-INF/lib folder and editing the /WEB-INF/glassfish-web.xml file to add the following two new entries: <class-loader delegate="false" /><property name="useBundledJsf" value="true" />.Keep in mind that you are only enforce Web servers to use your desired jars not the application servers because many applications servers are giving built in support for JSF. So Configuring Mojarra 2.1.X on Eclipse Indigo is somehow wrong to ask.You have to ask that how should I use Mojarra 2.1.x with my XXX server because eclipse is only IDE and these things are SOMEHOW managed by IDE but only in case of Webservers.Thanks :)

Eclipse doesn't import all Axis2 jars but project still runs on Tomcat?

When I develop an Axis2 web service on Eclipse, I noticed that Eclipse is automatically copying the classes from the lib folder of Axis2 to the lib folder of the new project. However, not all classes from the lib folder of Axis2 are being copied. Interestingly, the web service runs without any problem when deployed to Tomcat via Eclipse even if some the jars from Axis2 were not copied. Also, when I viewed the temp file of Tomcat, Tomcat seems to generate the jars for the listed modules on modules.list of the web service.
Can someone enlighten me regarding what is happening on this? Why Eclipse doesn't copy all the jars from Axis2? Why can the web service run on Tomcat even without the other jars from Axis2? What are those temp files for? When and why is it being generated?
I tried to run the same project on WebSphere and I am encountering a ClassDefNotFound exception because of the missing jars. My problem was solved when I copied all the Axis2 jars that was not copied by Eclipse to my project. But I'm not comfortable with my solution because Tomcat can run my project even without those jars. Is my solution really the right solution? Or am I missing a configuration setting?
This is just for clarification:
My web service is already running in Axis2. My class loading policy is set to PARENT_LAST. I know that since WebSphere has its own Axis2 configuration, the class loading policy must be set to PARENT_LAST so that WebSphere will use the Axis2 from the project itself. Aside from setting the class loading policy, I did something to make my web service run on WebSphere. I describe what I did above. My question is why such method must be taken?
WebSphere has it's own axis2 configuration as part of its Java EE server spec for JAX-WS. Change your class loading policy to PARENT_LAST and check if that solves your problem.
Edit:
As the original post already states: WebSphere is a Java EE server depending on version it supports its the standard Java JAX-WS web services. Actually web services became part of the standard jdk.
If you use JAX-WS like mentioned in Introduction to JAX-WS or building web services then you don't have to add any 3rd party library for getting your web services running. As soon as you use the non JDK implementation like axis2 you have to package it with your application.
IBM didn't just pack the axis2 into their WAS/JDK, they modified it. I'm not sure what Tomcat delivers, however as long as you use JAX-WS it shouldn't matter. With JAX-WS you don't have any direct import of the org.apache.axis packages. If you use these imports you have to supply the libraries and make sure that yours are loaded.

Java EE6 App + EJB in Glassfish 3.0/Netbeans 6.8?

Has anyone got this configuration working?
Latest Netbeans, latest Glassfish, I created an EJB project, also an EE Application.
The EJB in itself builds & deploys to Glassfish OK.
Now when I want to reference the EJB, I have to add the EJB jar to the EE Application path, if I don't do this the code does not compile.
But, the EJB jar gets packaged in the App jar and as a result when I try to deploy the app to Glassfish it says:
"java.lang.IllegalArgumentException:
Sniffers with type [ejb] and type
[appclient] should not claim the
archive at the same time. Please check
the packaging of your archive"
How do I tell Netbeans NOT TO package the EJB in the App jar? Or is the problem somewhere else?
btw. if I remove the EJB manually from the JAR then the app deploys successfully (with asadmin deploy), but when I try to run it with appclient, I get a NullPointerException.
Surely there must be a solution to this, I thought Netbeans was for web application development after all...
Edit: I found this:
http://forums.netbeans.org/topic23499.html
Which lists exactly the same steps that I did to resolve the problem.
Here is a solution candidate:
https://netbeans.org/bugzilla/show_bug.cgi?id=183488
Which basically says that Glassfish v3 is seriously broken, and it won't work.
Here is how I got it to work: the EJB and the EE Application MUST BE packaged in an EAR (project), and they MUST BE deployed within the EAR. Deploying the application jar individually WILL NOT WORK (at least not with Netbeans 6.8 + Glassfish v3).

JBoss / Eclipse RCP Integration

I've run into a problem with RCP and JBoss. I'm attempting to seperate the JBoss client libraries (i.e. the .jar files in the 'client' directory of the jboss distribution) from the ejbmodule. The dependency hierarchy goes:
company.client (ejbmodule containing ServiceRemote bean)
org.jboss.client (jboss client libraries)
The problem is that when the org.jboss.client attempts to load ServiceRemote from the server, it tries to do a lookup on ServiceRemote, it can't see it, and throws a ClassNotFoundException
Are there any resources/best practices out there of how to do jboss integration in RCP?
Found the answer - you can use the Eclipse Buddy system to allow low-level plugins to lookup classes which they couldn't normally see. More info here:
http://www.eclipsezone.com/articles/eclipse-vms/