.Choose File New Project (Ctrl-Shift-N; ⌘-Shift-N on Mac) from the main menu.Select Enterprise Application from the Maven category. Click Next.image::images/maven-newproject1.pngtitle='Maven Enterprise Application project type in the New Project wizard'.Type MavenEnterpriseApp for the the Project Name and set the Project Location.(Optional) Modify the artifact details. Click Next.image::images/maven-newproject2.pngtitle='Maven Project details in the New Project wizard'.Select GlassFish Server for the Server.Set the Java EE Version to Java EE 6 or Java EE 7.Select Create EJB Module and Create Web App Module. Click Finish. (MavenEnterpriseApp-ejb) The EJB project generally contains the source code with the business logic of the application. The EJB project is packaged as an EJB JAR archive.Webapp. (MavenEnterpriseApp-web) The Webapp project generally contains the presentation layer of the application such as JSF and JSP pages and servlets.
Build War File Netbeans
The Webapp project may also contain source code with business logic. The Webapp project is packaged as a WAR archive.Assembly. (MavenEnterpriseApp) The Assembly project is used to assemble an EAR archive from the EJB and WAR archives. The Assembly project does not contain any sources.Enterprise Application. (MavenEnterpriseApp-ear) The Enterprise Application project does not contain any sources.
The Enterprise Application only contains a POM file ( pom.xml ) with details about the modules contained in the enterprise application. After you create the enterprise application project, the enterprise application project will be badged if any dependencies are unavailable. If you expand the Dependencies node for the MavenEnterpriseApp-ear project, you can see if any required libraries are missing or not on the classpath. The enterprise application project has dependencies on the JAR and WAR that will be packaged and available after you compile the EJB project and the web project. You can see that MavenEnterpriseApp-ejb and MavenEnterpriseApp-web are listed as dependencies. To use a message-driven bean in an application, the connector resources used by the bean need to be registered with the server.
When you are deploying to the GlassFish server, you can create the resources directly on the server through the Admin Console or you can create the resources on deployment by specifying the details in the glassfish-resources.xml descriptor file. When the application is deployed to the server, the server registers the resources based on the descriptor file. When you use the New File wizard in the IDE to create a message-driven bean, the IDE will generate the elements in the descriptor file for you.Right-click the EJB module in the Projects window and choose New Other to open the New File wizard.From the Enterprise JavaBeans category, select Message-Driven Bean. Click Next.Type NewMessage for the EJB Name.Select ejb from the Package drop-down list.Click the Add button next to the Project Destination field to open the Add Message Destination dialog box.In the Add Message Destination dialog box, type jms/NewMessage and select Queue for the destination type.
Click OK.image::images/maven-messagedestination.pngtitle='Add Message Destination dialog'.Confirm that the project destination is correct. Click Next.image::images/maven-newmdb.pngtitle='New Message-Driven Bean wizard'.Accept the default settings in the Activation Config Properties. Click Finish. If you look at the pom.xml of the web project in the editor you can see that the EJB archive is declared as a dependency and the scope is specified as provided. When the value of the scope element of an artifact is provided, the artifact will not be included during packaging.
The web project requires the EJB archive as a dependency, but for this application you do not want the EJB archive to be included in the WAR during packaging because the EJB archive will be available and provided as part of the EAR archive.