部署/运行带有glassfish的java ee的dukesbank示例应用程序

时间:2012-09-28 14:51:46

标签: java oracle java-ee sample

我正在尝试运行dukesbank示例应用程序。

http://docs.oracle.com/javaee/5/tutorial/doc/bncna.html

我正在尝试按照以下说明进行操作:

Building, Packaging, and Deploying Duke’s Bank Using Ant

To compile and package the enterprise beans, application client, and web client into dukesbank.ear, go to the tut-install/javaeetutorial5/examples/dukesbank/ directory of the tutorial distribution and execute the command:

ant

Run the following command to deploy dukesbank.ear:

ant deploy

This task calls the create-tables task to initialize the database tables.
  1. 我正在使用ubuntu 12.04。我已经安装了glassfish应用程序服务器,我可以正常启动和停止它。我已经下载了javaeetutorial5。

  2. 我在javaeetutorial5 / example / common / admin-passwd.txt文件中写了glassfish的密码。

  3. 我在javaeetutorial5 / examples / bp-project / build.properties.sample文件中为参数赋值,然后我将文件重命名为build.properties。

  4. 现在,当我到达终端的目录javaeetutorial / example / dukesbank并输入"ant"时,它运行正常。但是当我尝试输入“ant run”时,它会给我以下信息:

    创建-表:           [sql]执行资源:/home/ragini/javaeetutorial5/examples/common/sql/javadb/tutorial.sql           [sql] 181 of 181 SQL语句成功执行

        deploy:
             [exec] Deprecated syntax, instead use:
             [exec] asadmin --user admin --passwordfile /home/ragini/javaeetutorial5/examples/common/admin-password.txt --host localhost --port 4848 deploy [options] ...
             [exec] Command deploy failed.
             [exec] Authentication failed for user: admin
             [exec] with password from password file: /home/ragini/javaeetutorial5/examples/common/admin-password.txt
             [exec] (Usually, this means invalid user name and/or password)
    
  5. 请注意,直到创建表,一切都成功执行然后它给我显示的错误。 有人可以说出它实际上会说些什么吗?

    我在javaeetutorial / examples / bp-project /中的build.properties文件如下所示:

    # Set the property javaee.home, using the path to your 
    # GlassFish installation.
    # C:/Program Files/glassfish-v3 is the GlassFish v3 default installation 
    # path on Windows.
    # 
    javaee.home=/usr/local/glassfish-3.1.2.2
    
    # Set the property javaee.tutorial.home to the location where you 
    # installed the Java EE Tutorial bundle.
    #
    javaee.tutorial.home=/home/ragini/javaeetutorial5
    
    # machine name (or the IP address) where the applications will be deployed.
    javaee.server.name=localhost
    
    # port number where GlassFish applications are accessed by users
    javaee.server.port=8080
    
    # port number where the Admin Console of GlassFish is available
    
    javaee.adminserver.port=4848
    
    
    # Uncomment the property javaee.server.username, 
    # and replace the administrator username of the app-server 
    javaee.server.username=admin
    
    # Uncomment the property javaee.server.passwordfile, 
    # and replace the following line to point to a file that 
    # contains the admin password for your app-server. 
    # The file should contain the password in the following line: 
    #
    # AS_ADMIN_PASSWORD=admin
    #
    # Notice that the password is adminadmin since this is 
    # the default password used by GlassFish.
    #
    javaee.server.passwordfile=${javaee.tutorial.home}/examples/common/admin-password.txt
    
    appserver.instance=server
    
    # Uncomment and set this property to the location of the browser you 
    # choose to launch when an application is deployed.
    # On Windows and Mac OS X the OS default browser is used.
    #default.browser=/Applications/Firefox.app/Contents/MacOS/firefox-bin
    
    # Database vendor property for db tasks
    # JavaDB is the default database vendor. See the settings in javadb.properties
    db.vendor=javadb
    
    # Digital certificate properties for mutual authentication
    keystore=${javaee.tutorial.home}/examples/jaxws/simpleclient-cert/support/client_keystore.jks
    truststore=${javaee.home}/domains/domain1/config/cacerts.jks
    keystore.password=changeit
    truststore.password=changeit
    

    我非常确定glassfish的用户名和密码。

1 个答案:

答案 0 :(得分:0)

晚会,但这个答案可能仍然会为其他有类似问题的人提供帮助。

简而言之,您似乎尝试在与用于Ant脚本的不同Glassfish版本上运行教程。

要解决此问题,您必须调整/home/ragini/javaeetutorial5/examples/bp-project/app-server-ant.xml文件。

特别是,查找名为“ deploy ”的目标(第367行左右)并更改

<exec executable="${asadmin}" failonerror="${failonerror}">
        <arg line=" deploy "/>
        <arg line=" --user ${javaee.server.username}" />
        <arg line=" --passwordfile ${javaee.server.passwordfile}" />
        <arg line=" --host ${javaee.server.name}" />
        <arg line=" --port ${javaee.adminserver.port}" />
        <arg line=" --name ${module.name}"/>
...
</exec>

<exec executable="${asadmin}" failonerror="${failonerror}">
        <arg line=" --user ${javaee.server.username}" />
        <arg line=" --passwordfile ${javaee.server.passwordfile}" />
        <arg line=" --host ${javaee.server.name}" />
        <arg line=" --port ${javaee.adminserver.port}" />
        <arg line=" deploy "/>
        <arg line=" --name ${module.name}"/>
...
</exec>

换句话说,多年来,deploy命令的指令顺序似乎发生了变化。为了支持其他目标(例如 undeploy ),您可能需要以类似的方式更改目标。