ushidayの日記

主に「IBMi」のメモに・・・

IBM iにGrailsを入れるも...続き

以前の続きでIBM iでGrailsを動かしてみました

テストアプリを作成
  • まずは「grails create-app os400demo」でテストアプリを作成。
grails create-app os400demo
Welcome to Grails 1.0.5 - http://grails.org/                               
Licensed under Apache Standard License 2.0                                 
Grails home is set to: /usr/local/grails/grails-1.0.5
Base Directory: /home/ushida5035/grails/1.0.5                              
Note: No plugin scripts found                                              
Running script /usr/local/grails/grails-1.0.5/scripts/CreateApp.groovy     
Environment set to development                                             
    [mkdir] Created dir: /home/ushida5035/grails/1.0.5/os400demo/src       
    [mkdir] Created dir: /home/ushida5035/grails/1.0.5/os400demo/src/java  
    [mkdir] Created dir: /home/ushida5035/grails/1.0.5/os400demo/src/groovy
    [mkdir] Created dir: /home/ushida5035/grails/1.0.5/os400demo/grails-app
--------------------------- 中 略 ------------------------------------------
Created Grails Application at /home/ushida5035/grails/1.0.5/os400demo 
$                                                                     

こんな感じで無事動きました。

ドメインクラスとコントローラを作成
grails create-domain-class author
Running script /usr/local/grails/grails-1.0.5/scripts/CreateDomainClass.groov
y                                                                            
Environment set to development                                               
     [copy] Copying 1 file to /home/ushida5035/grails/1.0.5/os400demo/grails-
app/domain                                                                   
Created Domain Class for Author                                              
     [copy] Copying 1 file to /home/ushida5035/grails/1.0.5/os400demo/test/in
tegration                                                                    
Created Tests for Author                                                     
$                                                                            

grails create-controller author
Running script /usr/local/grails/grails-1.0.5/scripts/CreateController.groovy
Environment set to development                                               
     [copy] Copying 1 file to /home/ushida5035/grails/1.0.5/os400demo/grails-
app/controllers                                                              
Created Controller for Author                                                
    [mkdir] Created dir: /home/ushida5035/grails/1.0.5/os400demo/grails-app/v
iews/author                                                                  
     [copy] Copying 1 file to /home/ushida5035/grails/1.0.5/os400demo/test/in
tegration                                                                    
Created ControllerTests for Author                                           
$

無事動きました。

appを実行してみる
  • Author.classに適当な項目を追加
  • AuthorController.classに「def scaffold=true」を追加
  • grails run-app」でアプリを動かす。

まず気が付いたのが、ターミナルとrun-appが切り離されてしまった。
ターミナルから、appの終了が出来なくなってしまったので、wrkactjobで該当のジョブを強制終了。
今度は「grails interactive」をやってから「run-app」

--------------------------------------------------------                     
Interactive mode ready, type your command name in to continue (hit ENTER to r
un the last command):                                                        
run-app                                                                      
Note: No plugin scripts found                                                
Running script /usr/local/grails/grails-1.0.5/scripts/RunApp.groovy          
Environment set to development                                               
    [mkdir] Created dir: /home/ushida5035/.grails/1.0.5/projects/os400demo/cl
asses                                                                        
  [groovyc] Compiling 8 source files to /home/ushida5035/.grails/1.0.5/projec
----------------------- 中 略 --------------------------------------------
[0] spring.GrailsWebApplicationContext Bean factory for application context [
org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext@6a6d075
3]: org.springframework.beans.factory.support.DefaultListableBeanFactory@3aa3
b931                                                                         
2009-05-28 14:31:52.377:/os400demo:INFO:  Initializing Spring FrameworkServle
t 'grails'                                                                   
2009-05-28 14:31:52.212::INFO:  Started SelectChannelConnector@0.0.0.0:8080  
Server running. Browse to http://localhost:8080/os400demo                    
--------------------------------------------------------                     
Application loaded in interactive mode, type 'exit' to shutdown server or you
r command name in to continue (hit ENTER to run the last command):           
2009-05-28 14:32:15.573:/os400demo:INFO:  GSP servlet initialized            

ん?特にエラーは出てないが、無事動いたのか?
恐る恐るurlにアクセス。


CRUDは無事、動いちゃいました。流石、Javaの血統とも言うべきか、プラットフォームを選ばない。
ちなみに「generate-controller,generate-views」でやってもOKでした。
次は1.1系を試すのと、データベースをDB2iにしてみたいと思います。