Version 2

    Package and Deploy EJB 3.0 Applications

     

    &12488;&12524;&12452;&12523;&65299;&12288;EJB 3.0&12450;&12503;&12522;&12465;&12540;&12471;&12519;&12531;&12398;&12497;&12483;&12465;&12540;&12472;&12531;&12464;&12392;&12487;&12503;&12525;&12452;

     

    &12399;&12376;&12417;&12395;&65288;Introduction&65289;

     

    In this trail, I will use the JBoss EJB 3.0 TrailBlazer application itself as an example to show you how to build and deploy an EJB 3.0 application. To download the TrailBlazer source code and deployable application archive files, please visit the JBoss TrailBlazer web at at http://www.jboss.com/docs/trailblazer.

     

    &12371;&12398;&12488;&12524;&12452;&12523;&12391;&12399;&12289;EJB 3.0&12450;&12503;&12522;&12465;&12540;&12471;&12519;&12531;&12398;&12499;&12523;&12489;&12392;&12487;&12503;&12525;&12452;&12398;&20363;&12392;&12375;&12390;&12289;JBoss EJB 3.0 TrailBlazer&12450;&12503;&12522;&12465;&12540;&12471;&12519;&12531;&12381;&12398;&12418;&12398;&12434;&20351;&29992;&12375;&12414;&12377;&12290;TrailBlazer&12398;&12477;&12540;&12473;&12467;&12540;&12489;&12392;&12487;&12503;&12525;&12452;&21487;&33021;&12394;&12450;&12503;&12522;&12465;&12540;&12471;&12519;&12531;&12398;&12450;&12540;&12459;&12452;&12502;&12501;&12449;&12452;&12523;&12434;&20837;&25163;&12377;&12427;&12395;&12399;&12289;JBoss TrailBlazer&12398;Web&12506;&12540;&12472;http://www.jboss.com/docs/trailblazer&12434;&35370;&21839;&12375;&12390;&12367;&12384;&12373;&12356;&12290;

     

    Important Note: After you deploy the TrailBlazer on your own server, first point your browser to http://localhost:8080/EJB3Trail/. It brings up the landing page and runs the database script on the server.

     

    &37325;&35201;&65306;TrailBlazer&12434;&12372;&33258;&20998;&12398;&12469;&12540;&12496;&12395;&12487;&12503;&12525;&12452;&12375;&12383;&12425;&12289;&12414;&12378;&12502;&12521;&12454;&12470;&12363;&12425;http://localhost:8080/EJB3Trail/&12434;&34920;&31034;&12375;&12390;&12367;&12384;&12373;&12356;&12290;&20986;&30330;&12506;&12540;&12472;&12364;&34920;&31034;&12373;&12428;&12289;&12487;&12540;&12479;&12505;&12540;&12473;&12473;&12463;&12522;&12503;&12488;&12364;&23455;&34892;&12373;&12428;&12414;&12377;&12290;

     

    TrailBlazer&12434;&12499;&12523;&12489;&12375;&12390;&23455;&34892;&12377;&12427;&65288;Build and run the TrailBlazer&65289;

     

    To build the TrailBlazer application, you can just download the source code zip file and execute build.sh (or build.bat in Windows). The build.xml uses ANT to compile and package the application. The deployable EJB3Trail.ear file is located in build/jar directory. Just copy it to your JBoss AS's server/default/deploy directory (or, server/all/deploy if you are using the zip installation), and you are done.

     

    TrailBlazer&12450;&12503;&12522;&12465;&12540;&12471;&12519;&12531;&12434;&12499;&12523;&12489;&12377;&12427;&12395;&12399;&12289;&12477;&12540;&12473;&12467;&12540;&12489;&12398;zip&12501;&12449;&12452;&12523;&12434;&12480;&12454;&12531;&12525;&12540;&12489;&12375;&12289;build.sh&65288;Windows&12398;&22580;&21512;&12399;build.bat&65289;&12434;&23455;&34892;&12375;&12414;&12377;&12290;build.xml&12434;&20803;&12395;ANT&12391;&12450;&12503;&12522;&12465;&12540;&12471;&12519;&12531;&12398;&12467;&12531;&12497;&12452;&12523;&12392;&12497;&12483;&12465;&12540;&12472;&12531;&12464;&12434;&34892;&12356;&12414;&12377;&12290;build/jar&12487;&12451;&12524;&12463;&12488;&12522;&12395;&12487;&12503;&12525;&12452;&21487;&33021;&12394;EJB3Trail.ear&12501;&12449;&12452;&12523;&12364;&20316;&25104;&12373;&12428;&12414;&12377;&12398;&12391;&12289;&12371;&12398;&12501;&12449;&12452;&12523;&12434;JBoss AS&12398;server/default/deploy&12487;&12451;&12524;&12463;&12488;&12522;&65288;zip&12501;&12449;&12452;&12523;&12391;&12469;&12540;&12496;&12434;&12452;&12531;&12473;&12488;&12540;&12523;&12375;&12383;&22580;&21512;&12399;server/all/deploy&12487;&12451;&12524;&12463;&12488;&12522;&65289;&12395;&12467;&12500;&12540;&12375;&12390;&12289;&12487;&12503;&12525;&12452;&23436;&20102;&12391;&12377;&12290;

     

    &12450;&12503;&12522;&12465;&12540;&12471;&12519;&12531;&12398;&12497;&12483;&12465;&12540;&12472;&20869;&23481;&65288;he complete application package&65289;

     

    The entire EJB 3.0 web application is packaged in an Enterprise ARchive file. It is just a JAR file with the .ear file name extension. The .ear file for this TrailBlazer application contains a beans.jar file for EJBs, and a web.war file for servlets and JSP pages. The packaging of the entity beans in the beans.jar file is explained in more detail later in this trailblazer. The EAR file also contains two configuration files in the META-INF directory: the application.xml file and the jboss-app.xml file.

     

    EAR&65288;Enterprise ARchive&65289;&12501;&12449;&12452;&12523;&12395;&12399;&12289;EJB 3.0 Web&12450;&12503;&12522;&12465;&12540;&12471;&12519;&12531;&20840;&20307;&12364;&12377;&12409;&12390;&12497;&12483;&12465;&12540;&12472;&12531;&12464;&12373;&12428;&12390;&12356;&12414;&12377;&12290;&12371;&12398;&12501;&12449;&12452;&12523;&12399;&12289;&12501;&12449;&12452;&12523;&21517;&12398;&25313;&24373;&23376;&12364;.ear&12395;&12394;&12387;&12383;&12384;&12369;&12391;&12289;JAR&12501;&12449;&12452;&12523;&12392;&21516;&12376;&12391;&12377;&12290;TrailBlazer&12450;&12503;&12522;&12465;&12540;&12471;&12519;&12531;&12398;.ear&12501;&12449;&12452;&12523;&12399;&12289;EJB&12434;&21547;&12416;beans.jar&12501;&12449;&12452;&12523;&12392;&12289;&12469;&12540;&12502;&12524;&12483;&12488;&12392;JSP&12506;&12540;&12472;&12434;&21547;&12416;web.war&12501;&12449;&12452;&12523;&12363;&12425;&25104;&12387;&12390;&12356;&12414;&12377;&12290;beans.jar&12501;&12449;&12452;&12523;&20869;&12398;&12456;&12531;&12486;&12451;&12486;&12451;Bean&12398;&12497;&12483;&12465;&12540;&12472;&12531;&12464;&26041;&27861;&12395;&12388;&12356;&12390;&12399;[24460;&36848;|http://trailblazer.demo.jboss.com/EJB3Trail/persistence/config/]]&12375;&12414;&12377;&12290;EAR&12501;&12449;&12452;&12523;&12395;&12399;&12373;&12425;&12395;&65298;&12388;&12398;&35373;&23450;&12501;&12449;&12452;&12523;&12289;application.xml&12501;&12449;&12452;&12523;&12392;jboss-aop.xml&12501;&12449;&12452;&12523;&12289;&12364;META-INF&12487;&12451;&12524;&12463;&12488;&12522;&12395;&21547;&12414;&12428;&12390;&12356;&12414;&12377;&12290;

     

    The application.xml file for the EJB 3.0 TrailBlazer application is listed as follows. It simply lists the nested JAR files contained in this .ear file.

     

    EJB 3.0 TrailBlazer&12450;&12503;&12522;&12465;&12540;&12471;&12519;&12531;&12398;application.xml&12501;&12449;&12452;&12523;&12399;&20197;&19979;&12398;&36890;&12426;&12391;&12377;&12290;&12371;&12398;&12501;&12449;&12452;&12523;&12399;&21336;&12395;&12289;.ear&12501;&12449;&12452;&12523;&12395;&21547;&12414;&12428;&12427;&20837;&12428;&23376;&12398;JAR&12501;&12449;&12452;&12523;&12434;&12522;&12473;&12488;&12375;&12390;&12356;&12414;&12377;&12290;

     

    <application ... ... >
        <display-name>EJB3Trail</display-name>
        <description>J2EE Made Easy Trail Map</description>
    
        <module>
            <ejb>beans.jar</ejb>
        </module>
    
        <module>
            <web>
                <web-uri>web.war</web-uri>
                <context-root>EJB3Trail</context-root>
            </web>
        </module>
    
    </application>
    

     

    The jboss-app.xml file defines a class loader for this application. It makes it simpler for EJB 3.0 to find the default EntityManager (see here). The content of the jboss-app.xml file is as follows.

     

    jboss-aop.xml&12501;&12449;&12452;&12523;&12399;&12450;&12503;&12522;&12465;&12540;&12471;&12519;&12531;&12398;&12463;&12521;&12473;&12525;&12540;&12480;&12434;&23450;&32681;&12375;&12390;&12356;&12414;&12377;&12290;&12371;&12398;&12501;&12449;&12452;&12523;&12399;&12289;EJB 3.0&12364;&12487;&12501;&12457;&12523;&12488;&12398;EntityManager&65288;[12371;&12371;|http://trailblazer.demo.jboss.com/EJB3Trail/persistence/config/]]&12434;&21442;&29031;&65289;&12434;&23481;&26131;&12395;&35211;&12388;&12369;&12425;&12428;&12427;&12424;&12358;&12395;&35373;&23450;&12375;&12390;&12356;&12414;&12377;&12290;

     

    <jboss-app>
      <loader-repository>
        trailblazer:app=ejb3
      </loader-repository>
    </jboss-app>
    

     

    &12414;&12392;&12417;&65288;Summary&65289;

     

    In this trail, we discussed how to build and package the EJB 3.0 trailblazer application. From the next hike, we will cover details on how to develop EJB 3.0 applications.

     

    &12371;&12398;&12488;&12524;&12452;&12523;&12391;&12399;&12289;EJB 3.0 TrailBlazer&12450;&12503;&12522;&12465;&12540;&12471;&12519;&12531;&12398;&12499;&12523;&12489;&12392;&12497;&12483;&12465;&12540;&12472;&12531;&12464;&12395;&12388;&12356;&12390;&35696;&35542;&12375;&12414;&12375;&12383;&12290;&27425;&12398;&12495;&12452;&12461;&12531;&12464;&12363;&12425;&12399;&12289;EJB 3.0&12450;&12503;&12522;&12465;&12540;&12471;&12519;&12531;&12398;&38283;&30330;&26041;&27861;&12395;&12388;&12356;&12390;&35443;&12375;&12367;&23398;&12435;&12391;&12356;&12365;&12414;&12375;&12423;&12358;&12290;

     

    (c) 2005 JBoss, Inc. All Rights Reserved