weavejester / hiccup

Fast library for rendering HTML in Clojure
http://weavejester.github.io/hiccup
Eclipse Public License 1.0
2.68k stars 175 forks source link

escape-html already refers to: #'hiccup.core/escape-html in namespace: hiccup.page #86

Closed alexkehayias closed 11 years ago

alexkehayias commented 11 years ago

Using lein2 with dependancies of ring 1.2.0 and hiccup 1.0.4 I get the following error when loading hiccup.page:

IllegalStateException escape-html already refers to: #'hiccup.core/escape-html in namespace: hiccup.page  clojure.lang.Namespace.warnOrFailOnReplace (Namespace.java:88)
weavejester commented 11 years ago

Have you tried performing a lein clean? Sometimes weird problems like these are the result of old class files littering the classpath.

alexkehayias commented 11 years ago

Yes I did a lein clean. Also tried adding ring dependencies separately i.e. ring/ring-core. Here is my full dependency list. Interestingly, removing the hiccup dependency, cleaning, then loading a namespace that uses ring still causes the issue. Is hiccup included in ring or compojure?

  :dependencies [[org.clojure/clojure "1.5.1"]                                                                                                                                    
                 [ring/ring-core "1.2.0"]                                                                                                                                         
                 [ring/ring-devel "1.2.0"]                                                                                                                                        
                 [ring/ring-json "0.2.0"]                                                                                                                                         
                 [hiccup "1.0.4"]                                                                                                                                                 
                 [compojure "1.1.5"]                                                                                                                                              
                 [aleph "0.3.0-beta7"]                                                                                                                                            
                 [twitter-api "0.7.3"]                                                                                                                                            
                 [clj-time "0.4.4"]                                                                                                                                               
                 [com.taoensso/timbre "1.5.3"]                                                                                                                                    
                 [org.clojure/tools.nrepl "0.2.2"]                                                                                                                                
                 [cronj "0.6.1"]                                                                                                                                                  
                 [clojurewerkz/spyglass "1.0.1"]                                                                                                                                  
                 [cheshire "5.2.0"]                                                                                                                                               
                 [clj-http "0.7.2"]                                                                                                                                               
                 [com.taoensso/carmine "2.1.2"]] 
weavejester commented 11 years ago

I created a blank project with those dependencies, then ran:

(require 'hiccup.page)

And it loaded fine. Have you tried doing a "git clean" to remove any lingering files that Leiningen might have missed? Have you tried putting those dependencies into a blank project and loading up hiccup.page to see what happens?

alexkehayias commented 11 years ago

I started a new project with the same dependencies and did (require 'hiccup.page) and got the same error. Using Leiningen 2.1.2 on Java 1.7.0_25 Java HotSpot(TM) 64-Bit Server VM, not sure if that would matter.

alexkehayias commented 11 years ago

I pulled in the code from hiccup master into the project and used it directly. It works fine, which makes me think something is up with my dependencies or clojars for hiccup. Any ideas on why it would work when hiccup is directly in my project rather than as a lein dep?

weavejester commented 11 years ago

Perhaps try with a fresh .m2 folder? If you do something like:

mv $HOME/.m2 $HOME/.m2.bak

And then re-execute your application, perhaps that will solve it.

alexkehayias commented 11 years ago

Same issue after refreshing the .m2 folder (mv'd and redownloaded all deps). Changing line 17 in hiccup.core in my .m2 directory to use the fully qualified name fixes my issue hiccup.util/escape-html. Got that from this issue in Noir https://github.com/noir-clojure/noir/issues/101.

weavejester commented 11 years ago

That's an odd fix, as it shouldn't make a difference. Could you possibly provide the whole project.clj file you're using? I've so far been unable to reproduce the issue.

Also, does the problem persist with the latest version of Leiningen? I know I'm clutching at straws a little here, but I'm using Leiningen 2.3.2 on Java 1.7.0_07 Java HotSpot(TM) 64-Bit Server VM.

alexkehayias commented 11 years ago

I upgraded to the latest lein 2.3.2. I'm trying to recreate the issue again on a fresh project, but now that I tried to change the jar file back to the way it was it still works. Tried a fresh removal of the old .m2 folder and repulled deps. Issue is resolved. Maybe something got cached. I think we can close this issue with the resolution being remove and reload dependencies. Thanks for your help.

Here's the exact project file I was able to create the problem with just for posterity:

(defproject ring-test "0.1.0-SNAPSHOT"                                                                                                                                            
  :description ""                                                                                                                                   
  :url ""                                                                                                                                                
  :dependencies [[org.clojure/clojure "1.5.1"]                                                                                                                                    
                 [ring/ring-core "1.1.7"]                                                                                                                                         
                 [ring/ring-devel "1.1.7"]                                                                                                                                        
                 [ring/ring-json "0.2.0"]                                                                                                                                         
                 [aleph "0.3.0-beta7"]                                                                                                                                            
                 [twitter-api "0.7.3"]                                                                                                                                            
                 [clj-time "0.4.4"]                                                                                                                                               
                 [com.taoensso/timbre "1.5.3"]                                                                                                                                    
                 [org.clojure/tools.nrepl "0.2.2"]                                                                                                                                
                 [cronj "0.6.1"]                                                                                                                                                  
                 [clojurewerkz/spyglass "1.0.1"]                                                                                                                                  
                 [cheshire "5.2.0"]                                                                                                                                               
                 [clj-http "0.7.2"]                                                                                                                                               
                 [com.taoensso/carmine "2.1.2"]]                                                                                                                                  
  :profiles {:dev                                                                                                                                                                 
             {:dependencies [[storm "0.8.2"]]}}) 
alexkehayias commented 11 years ago

Whoops nevermind, forgot to add in hiccup as a dep in the project file. Same issue after nuking .m2 and rebuilding

(defproject test-project "0.1.0-SNAPSHOT"                                                                                                                                            
  :description ""                                                                                                                                   
  :url ""                                                                                                                                                
  :dependencies [[org.clojure/clojure "1.5.1"]                                                                                                                                    
                 [ring/ring-core "1.2.0"]                                                                                                                                         
                 [ring/ring-devel "1.2.0"]                                                                                                                                        
                 [ring/ring-json "0.2.0"]                                                                                                                                         
                 [hiccup "1.0.4"]                                                                                                                                                 
                 [compojure "1.1.5"]                                                                                                                                              
                 [aleph "0.3.0-beta7"]                                                                                                                                            
                 [twitter-api "0.7.3"]                                                                                                                                            
                 [clj-time "0.4.4"]                                                                                                                                               
                 [com.taoensso/timbre "1.5.3"]                                                                                                                                    
                 [org.clojure/tools.nrepl "0.2.2"]                                                                                                                                
                 [cronj "0.6.1"]                                                                                                                                                  
                 [clojurewerkz/spyglass "1.0.1"]                                                                                                                                  
                 [cheshire "5.2.0"]                                                                                                                                               
                 [clj-http "0.7.2"]                                                                                                                                               
                 [com.taoensso/carmine "2.1.2"]]                                                                                                                                  
  :profiles {:dev                                                                                                                                                                 
             {:dependencies [[storm "0.8.2"]]}}                                                                                                                                   
  :main test-project.app/-main) ;; This calls some ring/compojure/aleph handlers
weavejester commented 11 years ago

Aha, I can reproduce it now.

weavejester commented 11 years ago

Looks like it's an issue with Storm 0.8.2. The library is AOT-compiled, and includes compiled classes from all its dependencies, including class files from very old, pre-1.0 versions of Ring and Hiccup. Clojure prefers class files over uncompiled source files, so even though Leiningen runs your app with the latest Ring and Hiccup version, the legacy class files bundled with Storm are overriding the version you specify.

The hiccup.page namespace exists in Hiccup 1.0.4, but not in Hiccup 0.3.6 (the version of the class files in storm), so in that case there's no problem. But the hiccup.core namespace exists in both, and Clojure's preferring the class files from the 0.3.6 version. So essentially you're using hiccup.page from version 1.0.4, but hiccup.core from 0.3.6.

As for how to fix it... don't use storm? :) - If that's not an option, you might want to check with the author, or perhaps grab a later version from source. Because Storm is subverting the normal dependency resolution, there's not much else I can suggest. I guess using an ancient version of Ring (pre-1.0) would work as well, but that's obvious not recommended...

alexkehayias commented 11 years ago

An yes, makes sense. Thanks for looking into it, I didn't think to look through storms deps or include it in my bug report. Will look into any updates from Storm. I'll split my project as a workaround if that doesn't pan out. Much appreciated!

prayagupa commented 10 years ago

@alexkehayias @weavejester Issue still exists. any updates from storm?

Thanks.

weavejester commented 10 years ago

It looks like Storm's dependencies are still out of date. You probably want to talk to the Storm devs; this bug isn't anything directly to do with Hiccup.

alexkehayias commented 10 years ago

@iPrayag I ended up splitting my project into a storm only library. Is there a specific reason you need to include storm in your project or can you split them? In my case I had a server that also made a storm bolt available if you included it. I ended up refactoring so the server part was separate from the storm part (and didn't require hiccup).

prayagupa commented 10 years ago

@alexkehayias @weavejester I ended up refactoring into engine and front. Hoping this issue will get fixed, https://issues.apache.org/jira/browse/STORM-169

Thanks.