Groovy + Spring + Java + Grape == Cannot Find the bean!

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Groovy + Spring + Java + Grape == Cannot Find the bean!

jferguson
System Info:
------------
Groovy Version: 1.8.4 JVM: 1.6.0_33

Spring: 3.0.5

OS: Windows XP

Issue Summary:
---------------
While using a groovy script for command line I cannot get the script to load my Java based SPring Beans.  In my scenario Bean A uses Bean B in its application context.  Even though I can import the class for Bean B, and call Class.formName on Bean B....Spring's ClassPathXmlApplicationContext cannot load Bean A because it cannot find Bean B.  I can get a Java application using the same jars to work as desired... we would rather use Groovy and Grape to make this work "out of the box" for anyone using it.

I have tried Stack Overflow, RTFM and Google.... I have circled back around to my own Stack Overflow post.  Anybody ever use Groovy to drive Java spring beans?  What am I doing wrong?

What I am using:
----------------

+ Grape to grab the jars for all the classes.  Which I can then find in my Groovy cache.
+ Groovy for the script
+ Spring ClassPathXmlApplicationContext to load the config files.

What I am seeing:
-----------------
See gist for stack trace:
https://gist.github.com/InvisibleTech/81422d42b412e8a5b4cf

What my code looks like:
-----------------------
See gist for code:
https://gist.github.com/InvisibleTech/0fa0487bd7667b65ad48
Reply | Threaded
Open this post in threaded view
|

Re: Groovy + Spring + Java + Grape == Cannot Find the bean!

Andre Steingress
Hi,

could you provide us with a gist of the full stack trace? If a bean is not found, it could be there was an initialisation error prohibiting the creation of this bean.  

Cheers, André
Reply | Threaded
Open this post in threaded view
|

Re: Groovy + Spring + Java + Grape == Cannot Find the bean!

Jim White-2
In reply to this post by jferguson
I don't know enough about how Grapes is implemented to have any idea if this is relevant or not, but I would be quite suspicious of using two @Grapes annotations since the point of that form is that the @Grabs all need to be together.  So I'm doubtful that you can use two resolvers like that.  

I would get the Grapes/Ivy config set up so it can use one resolver and a single @Grapes annotation and try that.  And why can't all those other dependencies be resolved transitively anyhow?

Jim
 
On Mon, Feb 11, 2013 at 1:34 PM, jferguson <[hidden email]> wrote:
System Info:
------------
Groovy Version: 1.8.4 JVM: 1.6.0_33

Spring: 3.0.5

OS: Windows XP

Issue Summary:
---------------
While using a groovy script for command line I cannot get the script to load
my Java based SPring Beans.  In my scenario Bean A uses Bean B in its
application context.  Even though I can import the class for Bean B, and
call Class.formName on Bean B....Spring's ClassPathXmlApplicationContext
cannot load Bean A because it cannot find Bean B.  I can get a Java
application using the same jars to work as desired... we would rather use
Groovy and Grape to make this work "out of the box" for anyone using it.

I have tried Stack Overflow, RTFM and Google.... I have circled back around
to my own Stack Overflow post.  Anybody ever use Groovy to drive Java spring
beans?  What am I doing wrong?

What I am using:
----------------

+ Grape to grab the jars for all the classes.  Which I can then find in my
Groovy cache.
+ Groovy for the script
+ Spring ClassPathXmlApplicationContext to load the config files.

What I am seeing:
-----------------
See gist for stack trace:
https://gist.github.com/InvisibleTech/81422d42b412e8a5b4cf

What my code looks like:
-----------------------
See gist for code:
https://gist.github.com/InvisibleTech/0fa0487bd7667b65ad48




--
View this message in context: http://groovy.329449.n5.nabble.com/Groovy-Spring-Java-Grape-Cannot-Find-the-bean-tp5713005.html
Sent from the groovy - dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email




Reply | Threaded
Open this post in threaded view
|

RE: Groovy + Spring + Java + Grape == Cannot Find the bean!

jferguson
In reply to this post by Andre Steingress
I have re-run with --debug to get more stack trace.... and I revised the original gist for the stack trace.  Also, I will look into getting the logging levels up for Spring...
 


From: Andre Steingress [via Groovy] [mailto:ml-node+[hidden email]]
Sent: Monday, February 11, 2013 5:34 PM
To: Ferguson, John
Subject: Re: Groovy + Spring + Java + Grape == Cannot Find the bean!

Hi,

could you provide us with a gist of the full stack trace? If a bean is not found, it could be there was an initialisation error prohibiting the creation of this bean.  

Cheers, André


If you reply to this email, your message will be added to the discussion below:
http://groovy.329449.n5.nabble.com/Groovy-Spring-Java-Grape-Cannot-Find-the-bean-tp5713005p5713008.html
To unsubscribe from Groovy + Spring + Java + Grape == Cannot Find the bean!, click here.
NAML

This message and any attachments are solely for the use of intended recipients. The information contained herein may include trade secrets, protected health or personal information, privileged or otherwise confidential information. Unauthorized review, forwarding, printing, copying, distributing, or using such information is strictly prohibited and may be unlawful. If you are not an intended recipient, you are hereby notified that you received this email in error, and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system. Thank you for your cooperation

Reply | Threaded
Open this post in threaded view
|

Re: Groovy + Spring + Java + Grape == Cannot Find the bean!

Guillaume Laforge-4
In reply to this post by Andre Steingress
I've been told the resource loading has changed a bit in Spring 3.2 vs that old version, perhaps there's a problem with the path you've defined for finding all the app context files? Could you also double check with a more version of Spring like 3.2 (and at the same occasion, with a newer version of Groovy as well, like 2.1.0)

It could look like as if not all xml config files were found.

Guillaume


On Mon, Feb 11, 2013 at 11:34 PM, Andre Steingress <[hidden email]> wrote:
Hi,

could you provide us with a gist of the full stack trace? If a bean is not
found, it could be there was an initialisation error prohibiting the
creation of this bean.

Cheers, André



--
View this message in context: http://groovy.329449.n5.nabble.com/Groovy-Spring-Java-Grape-Cannot-Find-the-bean-tp5713005p5713008.html
Sent from the groovy - dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one
Reply | Threaded
Open this post in threaded view
|

Re: Groovy + Spring + Java + Grape == Cannot Find the bean!

jferguson
I will try to get that set up soon, in the mean time... I would like to enhance the logging for Spring.  In Java I often just have a log4j in my classpath that looks like this:
 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="null" threshold="null">
 
 <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
  <layout class="org.apache.log4j.PatternLayout">
   <param name="ConversionPattern" value="%d{ISO8601}\t%p\t%c{3}\t%m%n" />
  </layout>
 </appender>
 
 <root>
  <level value="DEBUG" />
  <appender-ref ref="CONSOLE" />
 </root>
 
</log4j:configuration>
I threw the log4j.xml under a directory: d:\scripts per a search hit on stackoverflow.  I added it to the class path.  I am not interested in a logger for my trivial groovy class... I am interested in telling Spring under the covers to log DEBUG.  As part of debugging this issue... do you have any links to working advice for doing this?
 
This command did not result in Console output from Spring.  In fact I am not sure if log4j itself is in my classpath.... it is not in my .groovy cache for the grapes.
 
groovy -cp d:\scripts --debug gapAnalyzer.groovy
 
 


From: Guillaume Laforge [mailto:[hidden email]]
Sent: Tuesday, February 12, 2013 8:34 AM
To: dev
Subject: Re: [groovy-dev] Re: Groovy + Spring + Java + Grape == Cannot Find the bean!

I've been told the resource loading has changed a bit in Spring 3.2 vs that old version, perhaps there's a problem with the path you've defined for finding all the app context files? Could you also double check with a more version of Spring like 3.2 (and at the same occasion, with a newer version of Groovy as well, like 2.1.0)

It could look like as if not all xml config files were found.

Guillaume


On Mon, Feb 11, 2013 at 11:34 PM, Andre Steingress <[hidden email]> wrote:
Hi,

could you provide us with a gist of the full stack trace? If a bean is not
found, it could be there was an initialisation error prohibiting the
creation of this bean.

Cheers, André



--
View this message in context: http://groovy.329449.n5.nabble.com/Groovy-Spring-Java-Grape-Cannot-Find-the-bean-tp5713005p5713008.html
Sent from the groovy - dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one

This message and any attachments are solely for the use of intended recipients. The information contained herein may include trade secrets, protected health or personal information, privileged or otherwise confidential information. Unauthorized review, forwarding, printing, copying, distributing, or using such information is strictly prohibited and may be unlawful. If you are not an intended recipient, you are hereby notified that you received this email in error, and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system. Thank you for your cooperation

Reply | Threaded
Open this post in threaded view
|

Re: Groovy + Spring + Java + Grape == Cannot Find the bean!

TensaiRiceKing!
This post has NOT been accepted by the mailing list yet.
In reply to this post by jferguson
I did finally get my answer but it happened while working on a Grails app to front end the same beans.  I was able to get good logging there and there were others who had posted questions with answers about similar issues.  

The solution to my misery was to cleanup the pattern given to Spring:

        ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath*:META-INF/applicationContext.xml");


This classpath pattern now consistently works for me.  So, being more direct vs. the ** and and extra *'s seems to be what got it to work.

Thanks.