Skip to main content

EJB3 deployment with eclipse

10 replies [Last post]
iceandfire
Offline
Joined: 2006-11-16

Hallo!

At the moment I"m deploying my EJB3s to the autodeploy directory of glassfish(over eclipse jar export), is this the way it ment to be or is there a better solution?

Thanks
Stephan

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
hanshin
Offline
Joined: 2006-05-09

> Thanks for the help,
>
> I'm not sure. In the example they were deploying a
> "Dynamic Web Project" to the server.
> WTP gives you an extra project type "EJB Project" but
> that seems to be EJB2 and I can't use that for EJB3.
What makes you think that? All you have to do is to replace the xml descriptor with one from Java EE 5. That will make Eclipse stop bitching about "no EJBs defined in ejb-jar.xml" (that's actually an error from the XML validator).
>
> So, should I implement my EJB3s in a "Dynamic Web
> Project" and deploy that to the server? and use a
> separate "Dynamic Web Project" for the GUI part (for
> the sake of GUI layer separation)?
No no no. The point is to have your EJBs in a separate JAR file, your web stuff(html, jsp, servlets etc) in a WAR file, and package them both in an EAR, and deploy THAT.
Set up an Enterprise Application project, and then create an EJB project and a Dynamic Web Project, linking them to the EAR project. Then deploy the EAR project on your server.
WTP 2.0 will have direct support for Java EE 5 projects, but you can get by with 1.5.x if you just replace the generated descriptors with ones from Java EE 5.
>
> Thanks
> Stephan

iceandfire
Offline
Joined: 2006-11-16

Thanks!!!
the EAR hint was the missing Link.

I created a EJB Project, removed the xmls, and it just works.

mcfish
Offline
Joined: 2005-11-08

Hello,

There is a plugin for eclipse. Here the link: https://glassfishplugins.dev.java.net/download/

iceandfire
Offline
Joined: 2006-11-16

Yes, I have tried that plugin, but i cant't find a way to deploy a EJB3 to the server. And there is no manual (only quick start) or at least a feature list for it.

bye
Stephan

mcfish
Offline
Joined: 2005-11-08

But this page https://glassfishplugins.dev.java.net/specifications/introduction.html explain how.
Click on "RUN AS", "RUN ON SERVER" and so on ( as noted below ).
I can understand you. The Quick Start Guide don't say "deploy". Maybe "RUN AS" is what you are looking for.

Bye
Jan

iceandfire
Offline
Joined: 2006-11-16

Thanks for the help,

I'm not sure. In the example they were deploying a "Dynamic Web Project" to the server.
WTP gives you an extra project type "EJB Project" but that seems to be EJB2 and I can't use that for EJB3.

So, should I implement my EJB3s in a "Dynamic Web Project" and deploy that to the server? and use a separate "Dynamic Web Project" for the GUI part (for the sake of GUI layer separation)?

Thanks
Stephan

ludo
Offline
Joined: 2003-06-10

This is a current limitation of the Eclipse IDE itself to ntot support the Java EE 5 spec (Cannot create Web apps, ejb modules or EAR files with the correct descriptor files or support for ee 5 annotations). I think this is being addressed in the coming next version for Eclipse WTP.

iceandfire
Offline
Joined: 2006-11-16

Ok, but I need now a solution, so, as I have written in the first post, I'm using a Eclipse "Simple Java Project" and export the jar to the Glassfish autodeploy directory.

But exporting a jar need over seven mouse clicks.

What is a better solution, to deploy a "Simple Java Project" with only one mouse click?

iceandfire
Offline
Joined: 2006-11-16

OK, it seems a good solution is to use: "Simple Java Project"

and ant (sth. like that)








iceandfire
Offline
Joined: 2006-11-16

OK, that works for the first time, the second time glassfish gives me an error.
I googled for the error but only found windows users with that problem.
Glassfish is started with my user.

I'm deploying a stateless session bean as webservice.

stephan@hongkong:/opt/glassfish/bin$ /opt/glassfish/bin/asadmin deploy /home/stephan/DateinVonStephan/Diplomarbeit/workspaces/j2eetest/ejb/blubb1ejb2.jar
Command deploy executed successfully.

stephan@hongkong:/opt/glassfish/bin$ /opt/glassfish/bin/asadmin undeploy blubb1ejb2
Command undeploy executed successfully.

stephan@hongkong:/opt/glassfish/bin$ /opt/glassfish/bin/asadmin deploy /home/stephan/DateinVonStephan/Diplomarbeit/workspaces/j2eetest/ejb/blubb1ejb2.jar
CLI171 Command deploy failed : Deploying application in domain failed; com.sun.enterprise.deployment.backend.IASDeploymentException: Cannot deploy. Module directory is locked and cannot be deleted: /opt/glassfish-v1-b14/domains/domain1/applications/j2ee-modules/blubb1ejb2 -- Cannot deploy. Module directory is locked and cannot be deleted: /opt/glassfish-v1-b14/domains/domain1/applications/j2ee-modules/blubb1ejb2

The code of the bean is:
import javax.ejb.Stateless;
import javax.jws.WebMethod;
import javax.jws.WebService;

@Stateless
@WebService
public class HelloServiceBean {
private String message = "Hello44445555, ";

public HelloServiceBean() {}

@WebMethod
public String sayHello(String name) {
return message + name;
//return message + name + ".";
}
}

Message was edited by: iceandfire