FAQ
I'm building a single-page app ( started before Pedestal was announced
sadly ) and I'm using the fetch library to support RPC from client -> JVM
server.

I'm seeing a very strange behaviour. I've defined a view-model ns (full of
defrecords) for the client data. This has worked well - the client can read
and write records over the wire.

Except there's one situation where it does not work. If the client sends a
record to the server and the server has not previously sent at least one
instance of that defrecord type to the client then I see a
ClassNotFoundException. As soon as I read one instance from the server
(using fetch) then the problem goes away.

This means that the first users of new JVMs will experience this error -
not great for elastic computing.

I've tried:
1/ aot compiling the namespace
2/ reading and writing dummy view-model instances in the namespace on load
3/ importing and requiring all classes in the ns where I to the read-string

None of these seem to work.

Does anybody have an understanding of the read-string class-loading
behaviour that would explain this? Any suggestion would be much appreciated.

Steve

--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Steve Buikhuizen at Mar 21, 2013 at 2:41 pm
    I found the solution and it's a bit of a noob mistake.

    Because I'm using fetch, the server side of the RPC is defined in a noir
    host page.

    I added a :require of the view model ns to that page so that the classes
    are loaded above read-string call in the stack.

    This made it work immediately. Doh.

    --
    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en
    ---
    You received this message because you are subscribed to the Google Groups "Clojure" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Paul deGrandis at Mar 21, 2013 at 3:34 pm
    If you're up for the challenge, I'd encourage you to migrate from Noir to
    Compojure+Ring and from Fetch to Shoreleave remotes.

    I have much appreciation for Chris and his works,
    but the recent additions of the EDN reader are in the latter stack
    combination. You also get benefits like CSRF and XSS protections in you
    CLJ/CLJS app.

    For an example application to see how you might cut things over:
    https://github.com/shoreleave/shoreleave-baseline/tree/kitchen-sink

    All links to marg docs can be found here:
    https://github.com/ohpauleez/shoreleave#wheres-the-code

    Cheers,
    Paul

    --
    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en
    ---
    You received this message because you are subscribed to the Google Groups "Clojure" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Max Penet at Mar 21, 2013 at 7:02 pm
    +1

    fetch also has some bugs that will bite you sooner or later, it's not
    maintained anymore (and I don't think anyone took over).
    On Thursday, March 21, 2013 4:34:44 PM UTC+1, Paul deGrandis wrote:

    If you're up for the challenge, I'd encourage you to migrate from Noir to
    Compojure+Ring and from Fetch to Shoreleave remotes.

    I have much appreciation for Chris and his works,
    but the recent additions of the EDN reader are in the latter stack
    combination. You also get benefits like CSRF and XSS protections in you
    CLJ/CLJS app.

    For an example application to see how you might cut things over:
    https://github.com/shoreleave/shoreleave-baseline/tree/kitchen-sink

    All links to marg docs can be found here:
    https://github.com/ohpauleez/shoreleave#wheres-the-code

    Cheers,
    Paul
    --
    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en
    ---
    You received this message because you are subscribed to the Google Groups "Clojure" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Steve Buikhuizen at Mar 22, 2013 at 1:02 am
    Thanks for the support gents. Ever since Noir was deprecated I've been
    planning to switch to compojure and shoreleave.

    However I'm still in prototype mode and "it ain't broke" so I'm delaying
    that work until I need the next level of stability.

    Nice to know I'm on the right track though.

    --
    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en
    ---
    You received this message because you are subscribed to the Google Groups "Clojure" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Steve Buikhuizen at Mar 28, 2013 at 11:53 pm
    Sadly, this was not the end of the story. I discovered that my fix posted
    above did not work properly so I decided to bite the bullet and move to
    shoreleave. This held the promise of using an edn reader.

    A couple of things were tricky in making this migration, I'll list them
    here for any future readers.

    1. If using shoreleave-remote (client) and shoreleave-remote-ring
    (server) then make sure they have matching versions (currently 0.3.0)
    2. ensure you don't use cemerick.shoreleave.rpc for your middleware
    wrapper. it's there for backward compat but the latest middleware is
    shoreleave.middleware.rpc and it doesn't use the new edn reader
    3. pay careful attention to the extra required middlewares for wrap-rpc
    and the order in which they are included

    Even now that I am fully migrated I have a new problem. It appears that the
    edn reader cannot support tagged literals i.e. defrecords. I guess this
    makes sense for edn but it's a problem for anyone using defrecords for rpc
    writes. I have worked around it by removing the tag literals after
    serialisation on the client but it's a dirty hack. I'll try using non-edn
    for reading instead and I hope that it doesn't bring me full circle back to
    the ClassNotFoundException.

    At least it's good to be ported away from Noir and using the client pooled
    requests. Might provide a performance boost in my client.

    --
    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en
    ---
    You received this message because you are subscribed to the Google Groups "Clojure" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupclojure @
categoriesclojure
postedMar 21, '13 at 5:12a
activeMar 28, '13 at 11:53p
posts6
users3
websiteclojure.org
irc#clojure

People

Translate

site design / logo © 2022 Grokbase