JRuby에서 Rails 3.1 응용 프로그램을 JBoss에 배포 할 때 jndi/jdbc 연결 문제가 있습니다. 데이터 소스는Rails 3.1에서 JBoss 4.2.2로 배포
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)
에게 ...
###############################################################
#################### PRODUCTION DATA ##########################
###############################################################
production:
adapter: jdbc
jndi: java:jdbc/my_datasource
driver: com.microsoft.sqlserver.jdbc.SQLServerDriver
나는 소스와 database.yml을 파일을 모두 확인했지만 내가 가진 database.yml을
존재하고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'
잘 연결 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>
에 종속
을 추가하여 모든 응용 프로그램을하기 전에 데이터 소스 파일의 로딩을 강제로 배웠습니다. 전구가 오늘 밤에 갔고 앱이 데이터 소스보다 먼저로드되고 있다는 것을 깨달았습니다. 동료가 잘 배치되었지만 JBoss를 사용할 수 없었습니다 (다른 JBoss 애플리케이션은 없었습니다). http://confluence.atlassian.com/display/CONF210/Known+Issues+for+JBoss –
은 워블 설정, 데이터 소스 등을 추가했습니다. –