javascript_include_tag and stylesheet_link_tag not generating digestions #199

Closed
Aetherus opened this Issue Oct 16, 2013 · 43 comments

Comments

Projects
None yet

Environment: jruby-1.7.4, rails-4.0.0, warbler-1.3.8.
When I run my rails app with command

$ RAILS_ENV=production rails s

and open the page, all is fine.
The css/javascript including tags look like

<link data-turbolinks-track="true" href="/assets/application-29d20dadfd08a69de6a40cb4902f678e.css" media="all" rel="stylesheet">
<script data-turbolinks-track="true" src="/assets/application-e648e41b78977658f78cefb35c859061.js"></script>

When pack the app with command

$ RAILS_ENV=production warble executable war

run the war file, then open the page,
I found there is no digestion in the file name 'application.js' and 'application.css' in the html. They look like

<link data-turbolinks-track="true" href="/stylesheets/application.css" media="all" rel="stylesheet">
<script data-turbolinks-track="true" src="/javascripts/application.js"></script>

Here is my config/warble.rb:

Warbler::Config.new do |config|
  config.includes = FileList["db"]
  config.bundle_without = ['development', 'test']
  config.jar_name = "ROOT"
  config.webxml.rails.env = ENV['RAILS_ENV'] || 'production'
  config.webxml.jruby.min.runtimes = 1
  config.webxml.jruby.max.runtimes = 1
end

And here is my config/environments/production.rb:

...
config.serve_static_assets = false
config.assets.js_compressor = :uglifier
config.assets.compile = false
config.assets.digest = true
...

I did assets precompiling before packing the app. All the files are with digestions.

@ghost ghost assigned guilleiguaran Oct 23, 2013

Member

guilleiguaran commented Oct 23, 2013

assigned to myself, I'll investigate this

what version of Rails are you using?

Rails 4.0.0

I'm having the same issue with Rails 4.0.1, jruby-1.7.6, and warbler 1.4.0.

BTW, this is a very major bug, which makes Rails 4 completely unusable in production/compiled mode. If you need help reproducing it let me know. I can reproduce it with a simple scaffolded starter app. (Steps 1-4 in the Rails Getting Started Guide http://guides.rubyonrails.org/getting_started.html). Also, I'm running Windows, if that helps.

Thanks.

FYI, this seems to be caused by the setting

config.assets.compile = false

However, setting this value to true tries to call the js and css compressors on the fly in production and blows up.

I was able to work around this issue for now, by disabling the compressors

  # Compress JavaScripts and CSS.
  # TODO Uncomment these lines when https://github.com/jruby/warbler/issues/199 is fixed
  #config.assets.js_compressor = :uglifier
  #config.assets.css_compressor = :yui

  # Don't fallback to assets pipeline if a precompiled asset is missed.
  # TODO Set to false these lines when https://github.com/jruby/warbler/issues/199 is fixed
  config.assets.compile = true

I also had to make sure that warbler was including the sources for the assets in the WAR file. We were previously excluding them:

  # Additional files/directories to exclude
  config.excludes = FileList[
    'config/config.yml',
    'config/database.yml',
    # TODO Uncomment these lines when https://github.com/jruby/warbler/issues/199 is fixed
    #'app/assets/**/*',
    #'lib/assets/**/*',
    #'vendor/assets/**/*',
    'tmp/**/*'
  ]

So, now my production environment is working, but we no longer have compressed javascript and css. Also, I'm not really sure what's going on with the compiling of assets in production. Is Rails trying to re-compile the assets even though they've already been pre-compiled? If not, then why does it break if the compressors are enabled?

I'm also experiencing this issue. The assets do not include a digest; instead they link to:

  <link data-turbolinks-track="true" href="/stylesheets/application.css" media="all" rel="stylesheet" />
  <script data-turbolinks-track="true" src="/javascripts/application.js"></script>

Settings to reproduce:

config.serve_static_assets = true
config.assets.js_compressor = :uglifier
config.assets.css_compressor = :sass
config.assets.compile = false
config.assets.digest = true

# config.action_controller.asset_host and config.assets.precompile were both commented out.

Rails version: 4.0.2
Ruby version: jruby-1.7.8
Warbler version: 1.4.0

Steps to reproduce:

  • rake assets:precompile
  • warble compiled war
  • Deploy
  • The LINK and SCRIPT tags are incorrect, ie linking to /stylesheets/application.css and /javascripts/application.js

If config.assets.compile is set to true I have verified the digests are included, however this is not a good setting for production.

I've started to understand this issue a little better; the problem is that the JSON Manifest is not accessible to sprocket-rails here: https://github.com/rails/sprockets-rails/blob/master/lib/sprockets/railtie.rb#L67

The above manifest_path points to root.war/WEB-INF/public even when I specify an empty config.assets.prefix. Since the assets are actually at root.war/assets the manifest is not available and as a result asset_digest_path fails: https://github.com/rails/sprockets-rails/blob/master/lib/sprockets/rails/helper.rb#L87

As a test I hard-coded the manifest_path in sprockets-rails and then my assets work in production. I have a feeling the solution to this is to place the manifest into WEB-INFO/public/assets, which I'm hopeful can be done via configuration.

I wasn't able to get this to work via the existing configuration, but assets are working correctly after adding this to my CI job:

mkdir -p WEB-INF/public/assets
cp public/assets/manifest-*.json WEB-INF/public/assets/
jar uf example.war WEB-INF/public/assets/manifest-*json
Member

jkutner commented Dec 15, 2013

I think we should be able to add a config option to do this for you, but I'll to read through the details again to make sure. I'll probably start by trying to create a failing spec.

I'm having the same issue in my environment:

Rails version: 4.0.2
Ruby version: jruby-1.7.9
Warbler version: 1.4.0

Copying the manifest-*json' into WEB-INF/public/assets/ as suggested by @JeremyChase does not work, whereas setting config.assets.compile = true as suggested by @sanelson2000 works, but is not a good idea for production.

Is there a fix in sight?

The same for me, - reproduced on:

  • Windows XP PC
  • JRuby 1.7.10
  • warbler 1.4.1

Still no idea ?

I had the same issue and finally fixed it by copying the manifest-*json into WEB-INF/public/assets/ as suggested by @JeremyChase and... it works!

My config is mostly a default Rails 4 app:

  config.serve_static_assets = false
  config.assets.js_compressor = :uglifier
  config.assets.compile = false
  config.assets.digest = true

My environment:

  • Windows 7 x64
  • JRuby 1.7.10
  • Tomcat 7.0.52
  • Rails 4.0.3
  • Warbler 1.4.1
  1. On Windows XP, JRuby 1.7.10, Rails 4.0.2, Tomcat 7.0.50 that produced the below error:
java.util.zip.ZipException: zip file is empty
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(ZipFile.java:215)
        at java.util.zip.ZipFile.<init>(ZipFile.java:145)
        at java.util.jar.JarFile.<init>(JarFile.java:153)
        at java.util.jar.JarFile.<init>(JarFile.java:90)
        at sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:93)
        at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:69)
        at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:109)
        at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)
        at sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:89)
        at org.apache.tomcat.util.scan.FileUrlJar.<init>(FileUrlJar.java:41)
        at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:34)
        at org.apache.catalina.startup.ContextConfig$FragmentJarScannerCallback.scan(ContextConfig.java:2704)
        at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:259)
        at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:178)
        at org.apache.catalina.startup.ContextConfig.processJarsForWebFragments(ContextConfig.java:1960)
        at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1263)
        at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:880)
        at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:378)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5343)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:634)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1074)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1858)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744)
  1. As for copying the manifest manifest-*json into WEB-INF/public/assets/ I have not such a folder. Here is a Tomcat structure:
webapps
 |_myapp
   |_assets
   |_META-INF
   |_WEB-INF
      |_standard RoR app structure
   |_404.html
   |_422.html
   |_500.html
   |_favicaon.ico
   |_robots.txt

After adding zip-zip gem to the Gemfile and rebuilding the war the error is still the same :(

@javix You have to add the folder yourself after making the war. @JeremyChase 's suggestion works do these steps in your local myapp folder.

  1. mkdir -p WEB-INF/public/assets
  2. RAILS_ENV=production rake assets:precompile
  3. cp public/assets/manifest-*.json WEB-INF/public/assets/
  4. warble war
  5. jar uf myapp.war WEB-INF/public/assets/manifest-*json

The first error you mentioned ZipException may be a result of tomcat trying to deploy the war file before it is fully transferred if you are porting it to a remote server. I had that problem and ended up just copying the war to the tomcat folder and then copying it to the webapps folder on the server.

I did as described but got the (same ?) error:

Avertissement: Failed to scan JAR [file:/C:/apache-tomcat-7.0.50/webapps/blog/WEB-INF/lib/gems-gems-warbler-1.4.1-spec-
ample_war-some.jar] from WEB-INF/lib
java.util.zip.ZipException: zip file is empty
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(ZipFile.java:215)
        at java.util.zip.ZipFile.<init>(ZipFile.java:145)
        at java.util.jar.JarFile.<init>(JarFile.java:153)
        at java.util.jar.JarFile.<init>(JarFile.java:90)
        at sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:93)
        at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:69)
        at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:109)
        at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)
        at sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:89)
        at org.apache.tomcat.util.scan.FileUrlJar.<init>(FileUrlJar.java:41)
        at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:34)
        at org.apache.catalina.startup.ContextConfig$FragmentJarScannerCallback.scan(ContextConfig.java:2704)
        at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:259)
        at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:178)
        at org.apache.catalina.startup.ContextConfig.processJarsForWebFragments(ContextConfig.java:1960)
        at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1263)
        at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:880)
        at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:378)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5343)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:634)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1074)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1858)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744)

fÚvr. 20, 2014 9:30:58 AM org.apache.catalina.startup.ContextConfig processServletContainerInitializers
Grave: Failed to process JAR found at URL [jar:file:/C:/apache-tomcat-7.0.50/webapps/blog/WEB-INF/lib/gems-gems-warbler
1.4.1-spec-sample_war-some.jar!/] for ServletContainerInitializers for context with name [/blog]
fÚvr. 20, 2014 9:30:58 AM org.apache.catalina.startup.ContextConfig configureStart
Grave: Cette application est marquÚe comme non disponible suite aux erreurs prÚcÚdentes
fÚvr. 20, 2014 9:31:01 AM org.apache.catalina.startup.TldConfig tldScanJar
Avertissement: Failed to process JAR [jar:file:/C:/apache-tomcat-7.0.50/webapps/blog/WEB-INF/lib/gems-gems-warbler-1.4.
-spec-sample_war-some.jar!/] for TLD files
java.util.zip.ZipException: zip file is empty
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(ZipFile.java:215)
        at java.util.zip.ZipFile.<init>(ZipFile.java:145)
        at java.util.jar.JarFile.<init>(JarFile.java:153)
        at java.util.jar.JarFile.<init>(JarFile.java:90)
        at sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:93)
        at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:69)
        at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:109)
        at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)
        at sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:89)
        at org.apache.tomcat.util.scan.FileUrlJar.<init>(FileUrlJar.java:41)
        at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:34)
        at org.apache.catalina.startup.TldConfig.tldScanJar(TldConfig.java:482)
        at org.apache.catalina.startup.TldConfig.access$100(TldConfig.java:61)
        at org.apache.catalina.startup.TldConfig$TldJarScannerCallback.scan(TldConfig.java:293)
        at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:259)
        at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:178)
        at org.apache.catalina.startup.TldConfig.execute(TldConfig.java:266)
        at org.apache.catalina.startup.TldConfig.lifecycleEvent(TldConfig.java:562)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5343)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:634)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1074)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1858)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744)

fÚvr. 20, 2014 9:31:01 AM org.apache.catalina.startup.TaglibUriRule body
Infos: TLD skipped. URI: urn:org.jruby.rack is already defined
fÚvr. 20, 2014 9:31:01 AM org.apache.catalina.core.StandardContext startInternal
Grave: Error getConfigured
fÚvr. 20, 2014 9:31:01 AM org.apache.catalina.core.StandardContext startInternal
Grave: Erreur de dÚmarrage du contexte [/blog] suite aux erreurs prÚcÚdentes
fÚvr. 20, 2014 9:31:01 AM org.apache.catalina.startup.HostConfig deployDirectory
Infos: DÚploiement du rÚpertoire C:\apache-tomcat-7.0.50\webapps\docs de l'application web
fÚvr. 20, 2014 9:31:02 AM org.apache.catalina.startup.HostConfig deployDirectory
Infos: DÚploiement du rÚpertoire C:\apache-tomcat-7.0.50\webapps\examples de l'application web
fÚvr. 20, 2014 9:31:04 AM org.apache.catalina.startup.HostConfig deployDirectory
Infos: DÚploiement du rÚpertoire C:\apache-tomcat-7.0.50\webapps\host-manager de l'application web
fÚvr. 20, 2014 9:31:04 AM org.apache.catalina.startup.HostConfig deployDirectory
Infos: DÚploiement du rÚpertoire C:\apache-tomcat-7.0.50\webapps\manager de l'application web
fÚvr. 20, 2014 9:31:04 AM org.apache.catalina.startup.HostConfig deployDirectory
Infos: DÚploiement du rÚpertoire C:\apache-tomcat-7.0.50\webapps\ROOT de l'application web
fÚvr. 20, 2014 9:31:04 AM org.apache.coyote.AbstractProtocol start
Infos: Starting ProtocolHandler ["http-apr-8080"]
fÚvr. 20, 2014 9:31:04 AM org.apache.coyote.AbstractProtocol start
Infos: Starting ProtocolHandler ["ajp-apr-8009"]
fÚvr. 20, 2014 9:31:04 AM org.apache.catalina.startup.Catalina start
Infos: Server startup in 85637 ms

More of that, after copy-pasting the generated war into Tomcat webapps locally, the application (named blog) is not accessible at all (locally on Tomcat) at http://localhost:8080/blog, just get error 404 page.

I had the 404 page when using warbler 1.4.1, try using 1.4.0 if you haven't already.

Not better:

  • created a new rails project jruby -S rails new my app
  • add warbler 1.4.0 to the Gemfile: gem 'warbler', '1.4.0'
  • run jruby -S bundle
  • Got the following error when running config :
C:\...\projects\myapp> jruby -S warble config
warble aborted!
You have already activated warbler 1.4.1, but your Gemfile requires warbler 1.4.0. Prepending `bundle exec` to your comm
and may solve this.
org/jruby/RubyArray.java:1613:in `each'
org/jruby/RubyKernel.java:1083:in `require'
C:/.../projects/myapp/config/boot.rb:1:in `(root)'
org/jruby/RubyKernel.java:1083:in `require'
C:/.../projects/myapp/config/boot.rb:4:in `(root)'
org/jruby/RubyKernel.java:1083:in `require'
C:/..../projects/myapp/config/application.rb:1:in `(root)'
org/jruby/RubyKernel.java:1099:in `load'
C:/.../projects/myapp/config/application.rb:1:in `(root)'
org/jruby/RubyArray.java:1613:in `each'
C:/.../projects/myapp/rakefile:1:in `(root)'
C:/.../projects/myapp/rakefile:4:in `(root)'
org/jruby/RubyArray.java:1613:in `each'
org/jruby/RubyKernel.java:1099:in `load'
(See full trace by running task with --trace)
C:\...projects\myapp>

Either

  1. Uninstall 1.4.1 version of warbler gem uninstall warbler (it will ask you which versions you would like to uninstall)
    or
  2. run with bundle exec bundle exec warble config
  • Completely removed warbler and then reinstall 1.4.0 version:
  • Uninstall 1.4.1: jruby -S gem uninstall warbler
  • Install 1.4.0: jruby -S gem install warbler -v 1.4.0
  • created a new project: jruby -S rails new myapp -T
  • added warbler 1.4.0 to the Gemfile
  • run jruby -S bundle

Followed the described earlier steps:

mkdir -p WEB-INF/public/assets
RAILS_ENV=production rake assets:precompile
cp public/assets/manifest-*.json WEB-INF/public/assets/
warble war
jar uf myapp.war WEB-INF/public/assets/manifest-*json
  • Copy-pasted the generated WAR into TOMCAT_HOME/webapps
  • Run catalina.bat start
  • Got a new ERROR:
Grave: Failed to initialize end point associated with ProtocolHandler ["http-apr-8080"]
java.lang.Exception: Socket bind failed: [730048] Une seule utilisation de chaque adresse de socket (protocole/adresse r
Úseau/port) est habituellement autorisÚe.
        at org.apache.tomcat.util.net.AprEndpoint.bind(AprEndpoint.java:430)
        at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:640)
        at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:434)
        at org.apache.catalina.connector.Connector.initInternal(Connector.java:981)
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
        at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
        at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:814)
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:639)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:664)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455)

fÚvr. 21, 2014 5:15:05 PM org.apache.catalina.core.StandardService initInternal
Grave: Failed to initialize connector [Connector[HTTP/1.1-8080]]
org.apache.catalina.LifecycleException: Failed to initialize component [Connector[HTTP/1.1-8080]]
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:106)
        at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
        at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:814)
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:639)
        at org.apache.catalina.startup.Catalina.load(Catalina.java:664)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455)
Caused by: org.apache.catalina.LifecycleException: L''initialisation du gestionnaire de protocole a ÚchouÚ
        at org.apache.catalina.connector.Connector.initInternal(Connector.java:983)
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
        ... 12 more
Caused by: java.lang.Exception: Socket bind failed: [730048] Une seule utilisation de chaque adresse de socket (protocol
e/adresse rÚseau/port) est habituellement autorisÚe.
        at org.apache.tomcat.util.net.AprEndpoint.bind(AprEndpoint.java:430)
        at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:640)
        at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:434)
        at org.apache.catalina.connector.Connector.initInternal(Connector.java:981)
        ... 13 more

fÚvr. 21, 2014 5:15:05 PM org.apache.coyote.AbstractProtocol init
Infos: Initializing ProtocolHandler ["ajp-apr-8009"]
fÚvr. 21, 2014 5:15:05 PM org.apache.catalina.startup.Catalina load
Infos: Initialization processed in 908 ms
fÚvr. 21, 2014 5:15:05 PM org.apache.catalina.core.StandardService startInternal
Infos: DÚmarrage du service Catalina
fÚvr. 21, 2014 5:15:05 PM org.apache.catalina.core.StandardEngine startInternal
Infos: Starting Servlet Engine: Apache Tomcat/7.0.50
fÚvr. 21, 2014 5:15:05 PM org.apache.catalina.startup.HostConfig deployDescriptor
Infos: DÚploiement du descripteur de configuration C:\apache-tomcat-7.0.50\conf\Catalina\localhost\jsp_draft.xml
fÚvr. 21, 2014 5:15:06 PM org.apache.catalina.startup.HostConfig deployWAR
Infos: DÚploiement de l'archive C:\apache-tomcat-7.0.50\webapps\myapp.war de l'application web
fÚvr. 21, 2014 5:15:07 PM org.apache.catalina.startup.HostConfig deployDirectory
Infos: DÚploiement du rÚpertoire C:\apache-tomcat-7.0.50\webapps\docs de l'application web
fÚvr. 21, 2014 5:15:07 PM org.apache.catalina.startup.HostConfig deployDirectory
Infos: DÚploiement du rÚpertoire C:\apache-tomcat-7.0.50\webapps\examples de l'application web
fÚvr. 21, 2014 5:15:07 PM org.apache.catalina.startup.HostConfig deployDirectory
Infos: DÚploiement du rÚpertoire C:\apache-tomcat-7.0.50\webapps\host-manager de l'application web
fÚvr. 21, 2014 5:15:07 PM org.apache.catalina.startup.HostConfig deployDirectory
Infos: DÚploiement du rÚpertoire C:\apache-tomcat-7.0.50\webapps\manager de l'application web
fÚvr. 21, 2014 5:15:07 PM org.apache.catalina.startup.HostConfig deployDirectory
Infos: DÚploiement du rÚpertoire C:\apache-tomcat-7.0.50\webapps\ROOT de l'application web
fÚvr. 21, 2014 5:15:07 PM org.apache.coyote.AbstractProtocol start
Infos: Starting ProtocolHandler ["ajp-apr-8009"]
fÚvr. 21, 2014 5:15:07 PM org.apache.catalina.startup.Catalina start
Infos: Server startup in 1962 ms

The url localhost:8080 is no more accessible. Really weird :(

@jkutner If you haven't started on this I'll work on a PR to implement your idea of making a config option to put the manifest into the war.

Without that it is cumbersome to deploy a rails app using Warbler in a production environment that requires only a servlet server as an endpoint. As you can see in this thread many people have been hitting this issue.

+1, - personally, I believed this solution (deploy to a servlet container like Tomcat, for ex.) to be the easiest one. Unfortunately, it is not the case.

Member

jkutner commented Feb 22, 2014

@JeremyChase i haven't had time to work on this, but if you can start a PR, then I'll get it merged ASAP and help you where I can. Ping me if you have issues.

Could you guys please add a note in your README that warble is not compatible with Rails 4 and perhaps add a link to this issue? I just spent a day doing upgrades to an app only to get tied up by this issue which I found only have 30 minutes of googling.

Edit: found a related issue which may work as a tempfix for some people. #169

Again, it would be nice that if the README has a Rails 4 section to it informing people that public needs to be included in the config.dirs in order to serve assets properly 👍

Owner

kares commented Mar 3, 2014

@BrandonMathis it's a bug and bugs should be fixed not documented (or at least not at the official repo) ...
if you'd like to help I would suggest writing a blog post about it ...

I can do that :)

Perhaps just add something to the readme that that details configuration
instructions for rails 4 and rails 3 until this issue can be resolved then?
I'd be more than happy to write it up myself. Warbler has been such a
useful tool for me and I would like to help out any way I can.
On Mar 3, 2014 12:08 PM, "Karol Bucek" notifications@github.com wrote:

@BrandonMathis https://github.com/BrandonMathis it's a bug and bugs
should be fixed not documented (or at least not at the official repo) ...
if you'd like to help I would suggest writing a blog post about it ...


Reply to this email directly or view it on GitHubhttps://github.com/jruby/warbler/issues/199#issuecomment-36532422
.

Coming back to this issue, I don't think that it is actually a bug. More a missing dedicated feature.
I personally have multiple Rails 4 apps (with or without using the asset pipeline) deployed using Tomcat container.

Related to this assets' problem, I reported above that it worked for me by copying the manifest file(s). But instead of doing so manually, you can use the config.includes option in your warble.rb file:

config.includes = FileList["public/assets/manifest-*.json"]

Does the issue persist even with this option?

And I agree with @BrandonMathis, it should certainly be documented.

pparidans added a commit to pparidans/warbler that referenced this issue Mar 5, 2014

added documentation for issues #199 and #169
Document the Asset Pipeline precompiled assets detection and inclusion of the manifest file on Rails 3.1+.

belgoros commented Mar 5, 2014

After integrating the suggested config option, it worked for me !
Just recreated a new JRuby app on a Windows XP box:

#Gemfile
gem 'rails', '4.0.3'
gem 'activerecord-jdbcsqlite3-adapter'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'therubyrhino'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'

group :development do
  gem "warbler", '1.4.1'
end
  • Run jruby -S bundle
  • Create scaffold jruby -S rails g scaffold post title:string
  • Run migrations (both in dev and prod):
jruby -S rake db:migrate
jruby -S rake db:migrate RAILS_ENV=production
  • Run warbler config: jruby -S warble config.
  • Add the following optin to %rails_app%/config/warbler.rb into the Warbler::Config.new do |config|block:
config.includes = FileList["public/assets/manifest-*.json"]
  • Compile assets: jruby -S rake assets:precompile.
  • Create a war with warbler: jruby -S warble war.
  • Copy-paste the created war locally into %tomcat_home%/webappsfolder.
  • Start the Tomcat server: %tomcat_home%/bin/startup.bat. Wait the war deployment and startup to end.
  • Open your browser and navigate to localhost:8080/%name_of_your_app%.
  • Create some records and see the flash works fine and all the CSS used.

I used JRuby 1.7.11 version.

Member

jkutner commented Mar 5, 2014

if adding that config setting fixes this, it might be possible to detect config.assets.enabled=true in the app's config/application.rb. We do something similar for threadsafe! but it's pretty ugly:
https://github.com/jruby/warbler/blob/master/lib/warbler/traits/rails.rb#L62

We could do something like that for config.assets.enabled and set warbler's config.include for you...

belgoros commented Mar 5, 2014

Yep, it would be grate and put all the crosses on 't'-s 👍

Member

atambo commented Mar 6, 2014

@jkutner, a default rails 4.1 app no longer has config.assets.enabled in the application.rb anymore because it is enabled by default:

https://github.com/rails/rails/blob/master/railties/lib/rails/generators/rails/app/templates/config/application.rb

Member

jkutner commented Mar 6, 2014

thanks @atambo. for that reason, and some others, I'm just going to include the manifest if the manifest file exists. I can't think of a reason that would cause a problem.

Member

jkutner commented Mar 6, 2014

Can those of you who have experienced this issue test out my attempt at a fix in #199 and report back? thanks.

Member

jkutner commented Mar 6, 2014

That is ... #247 has the attempt at a fix.

belgoros commented Mar 6, 2014

@jkutner : Do you mean by testing the fix to add the below lines in the application warble.rb?

config.includes += FileList["public/assets/manifest-*.json"].existing
config.includes += FileList["public/assets/manifest.yml"].existing

Thnx

I can confirm that adding FileList["public/assets/manifest-*.json"] to config.includes fixes the issue for me. Did you want us to try the PR without adding these lines to warble.rb? If so, can you please tell me what to put in the gemfile? Thanks.

Member

jkutner commented Mar 6, 2014

i would like you to test the PR. you can do this by putting the following in your Gemfile:

gem 'warbler', :git => 'git://github.com/jruby/warbler.git', :branch => 'fix_asset_pipeline'

No changes should be required to your warble.rb (that is, you should not need to add the manifest to config.includes)

My build failed:

[10:03:58]Step 11/13: Build WAR (Command Line) (23s)
[10:04:02][Step 11/13] Starting: C:\TeamCity\buildAgent\temp\agentTmp\custom_script5216718108877998241.cmd
[10:04:02][Step 11/13] in directory: C:\TeamCity\buildAgent\work\2db8e267635f37c5
[10:04:21][Step 11/13] warble aborted!
[10:04:21][Step 11/13] Compile failed
[10:04:21][Step 11/13] org/jruby/RubyProc.java:271:in `call'
[10:04:21][Step 11/13] org/jruby/RubyArray.java:1613:in `each'
[10:04:21][Step 11/13] org/jruby/RubyArray.java:1613:in `each'
[10:04:21][Step 11/13] org/jruby/RubyProc.java:271:in `call'
[10:04:21][Step 11/13] org/jruby/RubyArray.java:1613:in `each'
[10:04:21][Step 11/13] org/jruby/RubyArray.java:1613:in `each'
[10:04:21][Step 11/13] org/jruby/RubyArray.java:1613:in `each'
[10:04:21][Step 11/13] org/jruby/RubyKernel.java:1101:in `load'
[10:04:21][Step 11/13] C:\jruby\jruby-1.7.6\bin\warble:23:in `(root)'
[10:04:21][Step 11/13] Tasks: TOP => war:compiled
[10:04:21][Step 11/13] (See full trace by running task with --trace)
[10:04:21][Step 11/13] Process exited with code 1
[10:04:21][Step 11/13] Step Build WAR (Command Line) failed

With full trace:

[10:10:56]Step 11/13: Build WAR (Command Line)
[10:10:59][Step 11/13] Starting: C:\TeamCity\buildAgent\temp\agentTmp\custom_script7660824092320915202.cmd
[10:10:59][Step 11/13] in directory: C:\TeamCity\buildAgent\work\2db8e267635f37c5
[10:11:17][Step 11/13] ** Invoke default (first_time)
[10:11:17][Step 11/13] ** Invoke war (first_time)
[10:11:17][Step 11/13] ** Execute war
[10:11:17][Step 11/13] ** Invoke war:compiled (first_time)
[10:11:17][Step 11/13] ** Execute war:compiled
[10:11:17][Step 11/13] warble aborted!
[10:11:17][Step 11/13] Compile failed
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/bundler/gems/warbler-cf2d24e4c2cb/lib/warbler/jar.rb:54:in `run_javac'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/bundler/gems/warbler-cf2d24e4c2cb/lib/warbler/jar.rb:42:in `compile'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/bundler/gems/warbler-cf2d24e4c2cb/lib/warbler/task.rb:109:in `define_compiled_task'
[10:11:17][Step 11/13] org/jruby/RubyProc.java:271:in `call'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:236:in `execute'
[10:11:17][Step 11/13] org/jruby/RubyArray.java:1613:in `each'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:231:in `execute'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:175:in `invoke_with_call_chain'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/1.9/monitor.rb:211:in `mon_synchronize'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:161:in `invoke'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/bundler/gems/warbler-cf2d24e4c2cb/lib/warbler/task.rb:88:in `define_main_task'
[10:11:17][Step 11/13] org/jruby/RubyArray.java:1613:in `each'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/bundler/gems/warbler-cf2d24e4c2cb/lib/warbler/task.rb:82:in `define_main_task'
[10:11:17][Step 11/13] org/jruby/RubyProc.java:271:in `call'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:236:in `execute'
[10:11:17][Step 11/13] org/jruby/RubyArray.java:1613:in `each'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:231:in `execute'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:175:in `invoke_with_call_chain'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/1.9/monitor.rb:211:in `mon_synchronize'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:197:in `invoke_prerequisites'
[10:11:17][Step 11/13] org/jruby/RubyArray.java:1613:in `each'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:195:in `invoke_prerequisites'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:174:in `invoke_with_call_chain'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/1.9/monitor.rb:211:in `mon_synchronize'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/task.rb:161:in `invoke'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:149:in `invoke_task'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:106:in `top_level'
[10:11:17][Step 11/13] org/jruby/RubyArray.java:1613:in `each'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:106:in `top_level'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:115:in `run_with_threads'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:100:in `top_level'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:78:in `run'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:165:in `standard_exception_handling'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/gems/rake-10.1.1/lib/rake/application.rb:75:in `run'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/bundler/gems/warbler-cf2d24e4c2cb/lib/warbler/application.rb:77:in `run'
[10:11:17][Step 11/13] C:/jruby/jruby-1.7.6/lib/ruby/gems/shared/bundler/gems/warbler-cf2d24e4c2cb/bin/warble:11:in `(root)'
[10:11:17][Step 11/13] org/jruby/RubyKernel.java:1101:in `load'
[10:11:17][Step 11/13] C:\jruby\jruby-1.7.6\bin\warble:23:in `(root)'
[10:11:17][Step 11/13] Tasks: TOP => war:compiled
[10:11:17][Step 11/13] Process exited with code 1
[10:11:17][Step 11/13] Step Build WAR (Command Line) failed
Member

jkutner commented Mar 6, 2014

@sanelson2000 that's a little strange. can you change the warbler branch in your Gemfile to master just to make sure that works.

master failed as well. I had been using 1.4.0 without issues.

Member

jkutner commented Mar 6, 2014

yea, so that means there's something not working with the git gems. it's not specific to my changes in #247.

Yeah, 1.4.1 fails, too. It looks like it may be a Windows issue. I'll create another issue for it.

@jkutner I just tested your changes and it works! Thanks!

Environment:

  • Rails 4.0.3,
  • JRuby 1.7.11,
  • Win7 64bit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment