Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8643305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:00:10+00:00 2026-06-12T12:00:10+00:00

I have a compiled grails project, and from a separate groovy project, I reflectively

  • 0

I have a compiled grails project, and from a separate groovy project, I reflectively load a domain class as follows

Class clazz = Class.forName('mypack.myclass', true, Thread.currentThread().contextClassLoader)
def newDomainObject = clazz.newInstance()

When running from outisde of grails (in my separate groovy project), the object is not recognized as a GroovyObject.

println newDomainObject instanceof GroovyObject // false

Since I’m running from outside of grails, I would think that groovy would treat the domain class just like any other class (and from looking at the class file, it does implement GroovyObject).

My best guess is that it has something to do with how grails compiles the domain object, but I’m not sure what’s going on here.

Note this is related to Why doesn't Class.forName work on grails domain classes, but not the same.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:00:12+00:00Added an answer on June 12, 2026 at 12:00 pm

    This seems impossible – just like javac changing classes that don’t explicitly extend a base class to extend java.lang.Object, groovyc changes all Groovy classes to implement groovy.lang.GroovyObject.

    Are you looking at a class compiled in the Groovy project from a shared .groovy class, or a compiled class in a jar?

    instanceof is tricky though due to Groovy’s order of evaluation; try adding parens:

    println (newDomainObject instanceof GroovyObject)
    

    If that still prints false, try recursively dumping all of the implemented interfaces:

    while (clazz != Object) {
       def interfaces = clazz.interfaces
       if (interfaces) {
          clazz.interfaces.each { println "$clazz.name implements $it.name" }
       }
       else {
          println "$clazz.name doesn't directly implement any interfaces"
       }
       clazz = clazz.superclass
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the Grails project that is managed and compiled by Maven. I'm trying
I have a Grails project that I created using Groovy/Grails Tool Suite version 3.0.0M3
Grails have cofig for spring bean called resources.groovy . And as i understand from
I have a grails project with some additional java source files under src/java folder.
I have compiled SQLIte3 database engine from sqlite3.c with BCC 55 using the following
I have been working Quartz framework in my grails project with lib called quartz-all-1.7.3.
I have a grails app that uses functionality from a set of custom java
I have a Grails-service implemented in Groovy, which I'd like to inject into a
In the grails class, I have specified BigDecimal amount to represent an amount of
I have compiled a program from my Ububtu 10.10 terminal by gcc file_name.c -o

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.