You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by Maneesh Mehra <ma...@gmail.com> on 2014/05/26 16:36:49 UTC
NPE on running Chef Solo blueprint
Hi:
I am new to brooklyn and am trying to create a blueprint to run a chef
recipe in a solo mode. Here is what I have so far in terms of this
blueprint:
package com.mypackage;
import java.util.HashMap;
import java.util.Map;
import brooklyn.entity.basic.AbstractApplication;
import brooklyn.entity.chef.ChefConfig;
import brooklyn.entity.chef.ChefEntity;
import brooklyn.entity.proxying.EntitySpec;
public class ChefBlueprint extends AbstractApplication {
private static final Map<String, String> cookbooksAndUrls = new
HashMap<String, String>();
@Override
public void init() {
cookbooksAndUrls.put("my-server", "file:///tmp/library/my_cookbooks.zip");
addChild(EntitySpec.create(ChefEntity.class)
.configure(ChefConfig.CHEF_MODE, ChefConfig.ChefModes.SOLO)
.configure(ChefConfig.CHEF_COOKBOOK_URLS, cookbooksAndUrls)
.configure(ChefConfig.CHEF_COOKBOOK_PRIMARY_NAME, "my-server")
.configure(ChefConfig.PID_FILE, "/tmp/chef_solo")
);
}
}
However, when I run this in brooklyn 0.7.0 M1 on localhost, I am getting
this:
[root@mmamp library]# brooklyn -v launch -b <myserver> --app
com.mypackage.ChefBlueprint --location localhost
_ _ _
| |__ _ __ ___ ___ | | _| |_ _ _ __ (R)
| '_ \| '__/ _ \ / _ \| |/ / | | | | '_ \
| |_) | | | (_) | (_) | <| | |_| | | | |
|_.__/|_| \___/ \___/|_|\_\_|\__, |_| |_|
|___/ 0.7.0-M1
Launching brooklyn app: com.mypackage.ChefBlueprint in localhost
2014-05-26 09:26:02,687 INFO Started Brooklyn console at
http://<myserver>:8081/,
running classpath://brooklyn.war and []
2014-05-26 09:26:02,687 INFO Persistence disabled
*2014-05-26 09:26:02,812 WARN Failed to create entity using spec
EntitySpec{type=interface brooklyn.entity.chef.ChefEntity} (rethrowing)*
*java.lang.NullPointerException: null*
* at
brooklyn.entity.chef.ChefLifecycleEffectorTasks.getPidFile(ChefLifecycleEffectorTasks.java:68)
~[brooklyn-software-base-0.7.0-M1.jar:na]*
*2014-05-26 09:26:02,818 WARN Failed to create entity using spec
EntitySpec{type=interface brooklyn.entity.basic.StartableApplication}
(rethrowing)*
*java.lang.NullPointerException: null*
* at
brooklyn.entity.chef.ChefLifecycleEffectorTasks.getPidFile(ChefLifecycleEffectorTasks.java:68)
~[brooklyn-software-base-0.7.0-M1.jar:na]*
*2014-05-26 09:26:02,819 ERROR Error launching brooklyn:
java.lang.NullPointerException*
*java.lang.NullPointerException: null*
* at
brooklyn.entity.chef.ChefLifecycleEffectorTasks.getPidFile(ChefLifecycleEffectorTasks.java:68)
~[brooklyn-software-base-0.7.0-M1.jar:na]*
2014-05-26 09:26:07,025 INFO Launched Brooklyn; now blocking to wait for
cntrl-c or kill
^C2014-05-26 09:26:10,020 INFO BrooklynWebServer detected shut-down:
stopping web-console
I looked up the source code and seems like the following line in
ChefLifecycleEffectorTasks.java is throwing the NPE.
public String getPidFile() {
if (_pidFile!=null) return _pidFile;
*return _pidFile = entity().getConfig(ChefConfig.PID_FILE);*
}
I am suspecting that entity() is returning a null, but why ?
Thanks,
Maneesh
Re: NPE on running Chef Solo blueprint
Posted by Richard Downer <ri...@apache.org>.
Maneesh,
I suspect that things are maybe not happening in the expected order,
so I'd like to see the full exception trace. As you can see, the
console log only reports the first line of the stack trace, but you
should find a file called "brooklyn-debug.log" in the brooklyn
directory. Could you have a look and see if the full exception is
recorded in there?
Thanks
Richard.
On 26 May 2014 15:36, Maneesh Mehra <ma...@gmail.com> wrote:
> Hi:
>
> I am new to brooklyn and am trying to create a blueprint to run a chef
> recipe in a solo mode. Here is what I have so far in terms of this
> blueprint:
>
> package com.mypackage;
>
> import java.util.HashMap;
> import java.util.Map;
>
> import brooklyn.entity.basic.AbstractApplication;
> import brooklyn.entity.chef.ChefConfig;
> import brooklyn.entity.chef.ChefEntity;
> import brooklyn.entity.proxying.EntitySpec;
>
> public class ChefBlueprint extends AbstractApplication {
>
> private static final Map<String, String> cookbooksAndUrls = new
> HashMap<String, String>();
> @Override
> public void init() {
> cookbooksAndUrls.put("my-server", "file:///tmp/library/my_cookbooks.zip");
> addChild(EntitySpec.create(ChefEntity.class)
> .configure(ChefConfig.CHEF_MODE, ChefConfig.ChefModes.SOLO)
> .configure(ChefConfig.CHEF_COOKBOOK_URLS, cookbooksAndUrls)
> .configure(ChefConfig.CHEF_COOKBOOK_PRIMARY_NAME, "my-server")
> .configure(ChefConfig.PID_FILE, "/tmp/chef_solo")
> );
> }
> }
>
> However, when I run this in brooklyn 0.7.0 M1 on localhost, I am getting
> this:
>
> [root@mmamp library]# brooklyn -v launch -b <myserver> --app
> com.mypackage.ChefBlueprint --location localhost
> _ _ _
> | |__ _ __ ___ ___ | | _| |_ _ _ __ (R)
> | '_ \| '__/ _ \ / _ \| |/ / | | | | '_ \
> | |_) | | | (_) | (_) | <| | |_| | | | |
> |_.__/|_| \___/ \___/|_|\_\_|\__, |_| |_|
> |___/ 0.7.0-M1
>
> Launching brooklyn app: com.mypackage.ChefBlueprint in localhost
> 2014-05-26 09:26:02,687 INFO Started Brooklyn console at
> http://<myserver>:8081/,
> running classpath://brooklyn.war and []
> 2014-05-26 09:26:02,687 INFO Persistence disabled
> *2014-05-26 09:26:02,812 WARN Failed to create entity using spec
> EntitySpec{type=interface brooklyn.entity.chef.ChefEntity} (rethrowing)*
> *java.lang.NullPointerException: null*
> * at
> brooklyn.entity.chef.ChefLifecycleEffectorTasks.getPidFile(ChefLifecycleEffectorTasks.java:68)
> ~[brooklyn-software-base-0.7.0-M1.jar:na]*
> *2014-05-26 09:26:02,818 WARN Failed to create entity using spec
> EntitySpec{type=interface brooklyn.entity.basic.StartableApplication}
> (rethrowing)*
> *java.lang.NullPointerException: null*
> * at
> brooklyn.entity.chef.ChefLifecycleEffectorTasks.getPidFile(ChefLifecycleEffectorTasks.java:68)
> ~[brooklyn-software-base-0.7.0-M1.jar:na]*
> *2014-05-26 09:26:02,819 ERROR Error launching brooklyn:
> java.lang.NullPointerException*
> *java.lang.NullPointerException: null*
> * at
> brooklyn.entity.chef.ChefLifecycleEffectorTasks.getPidFile(ChefLifecycleEffectorTasks.java:68)
> ~[brooklyn-software-base-0.7.0-M1.jar:na]*
> 2014-05-26 09:26:07,025 INFO Launched Brooklyn; now blocking to wait for
> cntrl-c or kill
> ^C2014-05-26 09:26:10,020 INFO BrooklynWebServer detected shut-down:
> stopping web-console
>
> I looked up the source code and seems like the following line in
> ChefLifecycleEffectorTasks.java is throwing the NPE.
>
> public String getPidFile() {
> if (_pidFile!=null) return _pidFile;
> *return _pidFile = entity().getConfig(ChefConfig.PID_FILE);*
> }
>
>
> I am suspecting that entity() is returning a null, but why ?
>
> Thanks,
>
> Maneesh