Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run-app fails with BeanDefinitionStoreException #671

Closed
tgoetz opened this issue Apr 28, 2015 · 9 comments
Closed

run-app fails with BeanDefinitionStoreException #671

tgoetz opened this issue Apr 28, 2015 · 9 comments

Comments

@tgoetz
Copy link

tgoetz commented Apr 28, 2015

I followed the "helloworld" example on https://grails.org/single-page-documentation.html (Grails 3.0.1) and this is what I get when I try to run the app:

org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'grailsConfigProperties' defined in null: Could not resolve placeholder 'PWD/$HOME/~' in string value "echo -ne "\033]0;${USER}@elektra: ${PWD/$HOME/~}\007""; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'PWD/$HOME/~' in string value "echo -ne "\033]0;${USER}@elektra: ${PWD/$HOME/~}\007""
    at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:211) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
...
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'PWD/$HOME/~' in string value "echo -ne "\033]0;${USER}@elektra: ${PWD/$HOME/~}\007""
    at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:174ing-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:126) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:204) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:178) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.context.support.PropertySourcesPlaceholderConfigurer$2.resolveStringValue(PropertySourcesPlaceholderConfigurer.java:175) ~[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE]

Grails tries to parse my "export PROMPT_COMMAND" statement from my .bash_profile (and fails)!? Any hint about that?

@graemerocher
Copy link
Member

Please provide steps to reproduce

@g000444555
Copy link

I had a similar problem and it turns out my .bash_profile was causing it.

Although grails run-app used to work with same .bash_profile, the problem might be caused due to some of the dependencies, such as gradle, being updated. I don't remember updating anything manually but I'm periodically updating my homebrew and gvm dependencies which might have brought a new version for one of the dependencies.

grails -version prints the following in my environment:

| Grails Version: 3.0.1
| Groovy Version: 2.4.3
| JVM Version: 1.8.0_45

@g000444555
Copy link

In order to reproduce, add the following into your .bash_profile:

JAVA_DEBUG_PORT="50"`echo ${ITERM_SESSION_ID:1:1}${ITERM_SESSION_ID:3:1}`
export PROMPT_COMMAND='echo -ne "\033]0;${PWD##*/} (${JAVA_DEBUG_PORT})\007"'

The above is an unrelated configuration for iTerm, but it turns out causing the reported error when running grails run-app:

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'PWD##*/' in string value "echo -ne "\033]0;${PWD##*/} (${JAVA_DEBUG_PORT})\007""

@ghost
Copy link

ghost commented Jul 12, 2015

I'm sorry to say that the problem persists with Grails 3.0.3.

ERROR grails.boot.GrailsApp - Application startup failed
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'hibernateDatastore' defined in null: Could not resolve placeholder 'HOSTNAME%%.*' in string value "_update_ps1; history -a; echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:$(perl -le 'use Cwd; print Cwd::getcwd() =~ s#\A\Q$ENV{HOME}\E(?=/|\z)#~#r')"; echo -ne "\007""; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'HOSTNAME%%.*' in string value "_update_ps1; history -a; echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:$(perl -le 'use Cwd; print Cwd::getcwd() =~ s#\A\Q$ENV{HOME}\E(?=/|\z)#~#r')"; echo -ne "\007""
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'hibernateDatastore' defined in null: Could not resolve placeholder 'HOSTNAME%%.*' in string value "_update_ps1; history -a; echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:$(perl -le 'use Cwd; print Cwd::getcwd() =~ s#\A\Q$ENV{HOME}\E(?=/|\z)#~#r')"; echo -ne "\007""; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'HOSTNAME%%.*' in string value "_update_ps1; history -a; echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:$(perl -le 'use Cwd; print Cwd::getcwd() =~ s#\A\Q$ENV{HOME}\E(?=/|\z)#~#r')"; echo -ne "\007""
        at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:211) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
        at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.processProperties(PropertySourcesPlaceholderConfigurer.java:180) ~[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE]
        at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:155) ~[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE]                                                                     
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:265) ~[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE]                                                                  
        at org.springframework.beans.factory.config.PlaceholderConfigurerSupport.doProcessProperties(PlaceholderConfigurerSupport.java:211)

It seems to conflict with the global bashrc file on Mageia Linux which content is the following:

# /etc/bashrc

# System wide functions and aliases
# Environment stuff goes in /etc/profile

# It's NOT good idea to change this file unless you know what you
# are doing. Much better way is to create custom.sh shell script in
# /etc/profile.d/ to make custom changes to environment. This will
# prevent need for merging in future updates.

# By default, we want this to get set.
# Even for non-interactive, non-login shells.
if [ "`id -gn`" = "`id -un`" -a `id -u` -gt 99 ]; then
    umask 002
else
    umask 022
fi

# are we an interactive shell?
if [ "$PS1" ]; then
    case $TERM in
    xterm*)
        # Inelegant fix for MGA #1623.
        PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:$(perl -le '\''use Cwd; print Cwd::getcwd() =~ s#\A\Q$ENV{HOME}\E(?=/|\z)#~#r'\'')"; echo -ne "\007"'
        ;;
    screen)
        PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:$(perl -le '\''use Cwd; print Cwd::getcwd() =~ s#\A\Q$ENV{HOME}\E(?=/|\z)#~#r'\'')"; echo -ne "\033\\"'
        ;;
    *)
        ;;
    esac
    [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
    # You might want to have e.g. tty in prompt (e.g. more virtual machines)
    # and console windows
    # If you want to do so, just add e.g.
    # if [ "$PS1" ]; then
    #   PS1="[\u@\h:\l \W]\\$ "
    # fi
    # to your custom modification shell script in /etc/profile.d/ directory

    if [ -z "$loginsh" ]; then # We're not a login shell
    # Not all scripts in profile.d are compatible with other shells
    # TODO: make the scripts compatible or check the running shell by
    # themselves.
    if [ -n "${BASH_VERSION}${KSH_VERSION}${ZSH_VERSION}" ]; then
            for i in /etc/profile.d/*.sh; do
            if [ -r $i ]; then
                . $i
            fi
        done
        unset i
    fi
    fi
fi

unset loginsh

@graemerocher
Copy link
Member

Will take another look...

@graemerocher
Copy link
Member

@AugierLe42e Cannot reproduce locally, I tried adding the line:

 PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:$(perl -le '\''use Cwd; print Cwd::getcwd() =~ s#\A\Q$ENV{HOME}\E(?=/|\z)#~#r'\'')"; echo -ne "\007"'

To my bash_profile and it worked fine. Please upload an example application and provide steps to reproduce.

@ghost
Copy link

ghost commented Jul 13, 2015

I don't what addintional informations to give you. This is exactly the problematic line. Commenting it removes the problem, uncommenting it causes it with Grail 3.0.0, Grovy 2.4.3 and JVM 1.7.0_79. I will ping Mageia devs to add them in the loop but I can't give you more on this, sorry.

@ghost
Copy link

ghost commented Jul 13, 2015

Maybe try to source the whole script.

@ghost
Copy link

ghost commented Jul 13, 2015

Update: couldn't reproduce too on a new project. I managed to solve the problem on old project by nuking build directory and changing properties grailsVersion and gradleWrapperVersion from 3.0.2 and 2.3 to 3.0.3 and 2.5 in gradle.properties.

Sorry for the noise and thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants