2012-01-18 16 views
2

JRubyからJRubyへのRails 3.1アプリケーションをJBossにデプロイするとき、jndi/jdbc接続の問題があります。データソースが存在し、Rails 3.1からJBoss 4.2.2へのデプロイ

17:47:20,862 ERROR [STDERR] JNDI data source unavailable: javax.naming.NameNotFoundException: jdbc not bound; trying straight JDBC 
17:47:20,926 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] unable to create shared application instance 
org.jruby.rack.RackInitializationException: jdbc adapter requires driver class and url 
    from C:/opt/jboss/jboss-4.2.2.GA-Virgin/server/default/tmp/deploy/tmp1619261931370223075MyApp-exp.war/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.2.0/lib/arjdbc/jdbc/connection.rb:21:in `configure_connection' 
    from C:/opt/jboss/jboss-4.2.2.GA-Virgin/server/default/tmp/deploy/tmp1619261931370223075MyApp-exp.war/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.2.0/lib/arjdbc/jdbc/connection.rb:84:in `initialize' 
    from C:/opt/jboss/jboss-4.2.2.GA-Virgin/server/default/tmp/deploy/tmp1619261931370223075MyApp-exp.war/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.2.0/lib/arjdbc/jdbc/adapter.rb:32:in `initialize' 
    from C:/opt/jboss/jboss-4.2.2.GA-Virgin/server/default/tmp/deploy/tmp1619261931370223075MyApp-exp.war/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.2.0/lib/arjdbc/jdbc/connection_methods.rb:6:in `jdbc_connection' 
    from org/jruby/RubyKernel.java:2097:in `send' 

細かい結ぶ...

Caused by: org.jruby.exceptions.RaiseException: (ConnectionNotEstablished) jdbc adapter requires driver class and url 
17:47:23,010 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/MyApp]] Error: application initialization failed 
org.jruby.rack.RackInitializationException: unable to create shared application instance 
    at org.jruby.rack.SharedRackApplicationFactory.init(SharedRackApplicationFactory.java:39) 
    at org.jruby.rack.RackServletContextListener.contextInitialized(RackServletContextListener.java:45) 
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3856) 

database.ymlの

############################################################### 
#################### PRODUCTION DATA ########################## 
############################################################### 

production: 
    adapter: jdbc 
    jndi: java:jdbc/my_datasource 
    driver: com.microsoft.sqlserver.jdbc.SQLServerDriver 

私は、データソースとdatabase.ymlファイルの両方をチェックしましたが、私は持っていますなぜRailsがデータソースを見つけられないのかわかりません。

更新

Warbler config 

# Disable Rake-environment-task framework detection by uncommenting/setting to false 
# Warbler.framework_detection = false 
# 
puts 'Compiling the asset manifests & other files in the pipeline to the disk' 
system('bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile') 

# Warbler web application assembly configuration file 
Warbler::Config.new do |config| 

    # Application directories to be included in the webapp. 
    config.dirs = %w(app config lib log vendor tmp) 

    # Name of the archive (without the extension). Defaults to the basename 
    # of the project directory. 
    config.jar_name = "MyApp" 

    # Control the pool of Rails runtimes. Leaving unspecified means 
    # the pool will grow as needed to service requests. It is recommended 
    # that you fix these values when running a production server! 
    config.webxml.jruby.min.runtimes = 1 
    config.webxml.jruby.max.runtimes = 1 

    # JNDI data source name 
    # config.webxml.jndi = 'jdbc/rails' 
end 

データソースの設定

<datasources>  
<xa-datasource> 
    <jndi-name>jdbc/my_datasource</jndi-name> 
    <track-connection-by-tx/> 
    <isSameRM-override-value>false</isSameRM-override-value> 
    <xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class> 
    <xa-datasource-property name="ServerName">myserver</xa-datasource-property> 
    <xa-datasource-property name="DatabaseName">mydb</xa-datasource-property> 
    <xa-datasource-property name="SelectMethod">cursor</xa-datasource-property> 
    <valid-connection-sql>SELECT 1</valid-connection-sql> 
    <user-name>user</user-name> 
    <password>pwd</password> 
     <metadata> 
     <type-mapping>MS SQLSERVER2000</type-mapping> 
     </metadata> 
    </xa-datasource> 
</datasources> 

答えて

3

私のために、次の作品.warファイルを展開Railsの3.0.xの/ JBossの5.1.0GAのためにアップしwarbled。

あなたが正常にこのようになります。XML設定ファイルを使用してデータソースを展開していると仮定すると:

<?xml version="1.0" encoding="UTF-8"?> 
<datasources> 
    <local-tx-datasource> 
     <jndi-name>my_datasource</jndi-name> 
     <connection-url>MYDATASOURCE_URL</connection-url> 
     <driver-class>your.Driver</driver-class> 
     ... define any other connection properties here ... 
    </local-tx-datasource> 
</datasources> 

あなたはあなたのデータソースが実際に稼働してあなたのJBossの管理コンソールであることを確認する必要があります。

その後、あなたはconfig/warble.rbファイルに次の持っていると仮定すると:

# JNDI data source name 
config.webxml.jndi = 'jdbc/my_datasource' 

# JBoss web-xmle file 
config.includes = 'jboss-web.xml' 

...と、さらに次のように、あなたはRailsのプロジェクトフォルダ直下にあるjboss-web.xml設定ファイルを持っていると仮定:

<jboss-web> 
    <resource-ref> 
     <res-ref-name>jdbc/my_datasource</res-ref-name> 
     <jndi-name>java:/my_datasource</jndi-name> 
     <res-type>javax.sql.DataSource</res-type> 
    </resource-ref> 
</jboss-web> 

...あなたはafaikでもOKです。

warble.rbと、データソースXML設定ファイルと、設定しているJBoss Web設定パラメータを投稿することはできますか?

[編集] 設定ファイルを投稿していただきありがとうございます。私の頭の上から、私はあなたを提供することができますアドバイスの次のビット:

  1. はあなたのdatabase.ymljava:comp/env/jdbc/my_datasourceにしてjndi値を修正します。
  2. warble.rbconfig.webxml.jndiの設定を定義し、jdbc/my_datasourceに設定してください。
  3. さらに、warble.rbの新しいJBoss web.xmlファイルへの参照をconfig.includes = jboss-web.xmlと定義します。
  4. この新しいjboss-web.xmlを作成して、JNDI名をJBossリソース参照名にマップします。あなたが共有しているファイルに基づいて、それは私が上に示したものの行に沿ったものになります。このファイルは、Railsプロジェクトのルートのすぐ下に作成します。

これは役に立ちます。

+0

に依存

<depends>jboss.jca:service=DataSourceBinding,name=mydatasource</depends> 

を追加することによって、すべてのアプリケーションの前にデータソースファイルの読み込みを強制することを学びました。電球が今夜行って、データソースの前にアプリが読み込まれている可能性があることに気付きました。私の同僚はうまく展開しましたが、私は(新鮮なJBoss、他のアプリはありませんでした)ことができませんでした。 http://confluence.atlassian.com/display/CONF210/Known+Issues+for+JBoss –

+0

にはwarble config、datasourceなどが追加されました –

2

私はブルザゼモンのアドバイスを受けました。しかし、私は誤ってwarファイルを/deploy/uuid-key-generator.sarディレクトリにコピーしてしまったことがわかりましたが、jbossスタックトレースが間違ったjruby-jarsバージョンを示した後でしか見つかりませんでした。

何の価値については、私は明日ます

/jboss-web.deployer/META-INF/jboss-service.xml 
+0

データソースの読み込み依存関係にそのビットを共有してくれてありがとう...お勧めします! – buruzaemon

関連する問題