0

based on this answer, while I was looking for tut-install, I poked around in glassfish and found:

thufir@dur:~$ 
thufir@dur:~$ ll glassfish4/samples/ejb/hello-stateless-ejb/hello-stateless-ejb-bean/src/main/java/enterprise/hello_stateless_ejb/StatelessSession.java 

In and of itself, the code is minimal:

package enterprise.hello_stateless_ejb;

import javax.ejb.Remote;

@Remote
public interface StatelessSession {

    public String hello();

}

I would like to run this sample, there's a pom file. How can I load this project into glassfish? I was trying to load tut-install, which would also be useful. However, this example looks like, perhaps, a simpler version.

A stateless "hello world" sample is where I would like to start, preferably just by loading the pom. I've glanced through some older EJB books, but they're woefully out of date; working code would be preferable.

the pom is:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
                <groupId>org.glassfish-samples</groupId>
        <artifactId>ejb-samples</artifactId>
        <version>4.0-SNAPSHOT</version>
    </parent>
    <artifactId>hello-stateless-ejb</artifactId>
    <packaging>pom</packaging>
    <name>hello-stateless-ejb</name>
    <modules>
        <module>hello-stateless-ejb-bean</module>
        <module>hello-stateless-ejb-client</module>
    </modules>
</project>
Community
  • 1
  • 1
Thufir
  • 8,216
  • 28
  • 125
  • 273

1 Answers1

1

You need to package and deploy the project to run it on GlassFish (or any other application server). I would recommend to use NetBeans because it has a good GlassFish integration and also comes with a lot of working Java EE examples.

  1. If you don't already have, download and install the NetBeans Java EE version from https://netbeans.org/downloads/. If you already have a running GlassFish server you can deselect the included GlassFish in the installation wizard.
  2. If GlassFish is already running, shut it down.
  3. In NetBeans, go to the Services tab, click on Servers and add your GlassFish instance.
  4. Click on File -> Open Project and load the pom.xml. This should open 3 projects.
  5. You probably want to deploy the hello-stateless-ejb-bean, right-click on the project and click Run, if it asks for a server select your GlassFish instance.
  6. This should start GlassFish and deploy the project, you can see GlassFish logging in the output window of NetBeans.
unwichtich
  • 13,712
  • 4
  • 53
  • 66