Topics

running the spring example

Rick Hightower
 

I am trying to run the spring example. 

Tron is running!

$ docker ps

CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                                                        NAMES

26b03fca941c        funcatron/tron:v0.2.6   "/usr/bin/java -ja..."   51 minutes ago      Up 51 minutes       0.0.0.0:3000->3000/tcp, 0.0.0.0:54657->54657/tcp, 4000/tcp   reverent_williams


From the IDE I try to run funcatron.java_spring_sample.Application

I am getting a NPE. 

With some debugging... 

The Map swagger is null.

Map swagger = ContextImpl.runOperation(Constants.GetSwaggerConst,
        new HashMap<>(),
        Logger.getAnonymousLogger(), Map.class);


The above sets swagger to null. 

Then later this line fails. Line 46.

fos.write(swagger.get("swagger").toString().getBytes("UTF-8"));

Then the rest of it gently rolls down hill. 

Disconnected from the target VM, address: '127.0.0.1:51045', transport: 'socket'
Exception in thread "main" java.lang.NullPointerException
at funcatron.java_spring_sample.Application.main(Application.java:46)
2017-04-04 16:15:18.485  INFO 49781 --- [       Thread-1] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1e16c0aa: startup date [Tue Apr 04 16:14:35 PDT 2017]; root of context hierarchy
2017-04-04 16:15:18.486  INFO 49781 --- [       Thread-1] o.s.c.support.DefaultLifecycleProcessor  : Stopping beans in phase 2147483647
2017-04-04 16:15:18.488  INFO 49781 --- [       Thread-1] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown



What am I doing wrong?

David "Funcmaster D" Pollak
 

Okay... I've got some updating to do. :-)

This issue was reported privately by another user and there's some updated code that I have to push into the public repo.

I'm working on a related issue for JPA not initializing correctly. Hope to get both fixed and pushed up today.



On Tue, Apr 4, 2017, at 04:38 PM, Rick Hightower wrote:
I am trying to run the spring example. 

Tron is running!

$ docker ps

CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                                                        NAMES

26b03fca941c        funcatron/tron:v0.2.6   "/usr/bin/java -ja..."   51 minutes ago      Up 51 minutes       0.0.0.0:3000->3000/tcp, 0.0.0.0:54657->54657/tcp, 4000/tcp   reverent_williams


From the IDE I try to run funcatron.java_spring_sample.Application

I am getting a NPE. 

With some debugging... 

The Map swagger is null.

Map swagger = ContextImpl.runOperation(Constants.GetSwaggerConst,
        new HashMap<>(),
        Logger.getAnonymousLogger(), Map.class);


The above sets swagger to null. 

Then later this line fails. Line 46.

fos.write(swagger.get("swagger").toString().getBytes("UTF-8"));

Then the rest of it gently rolls down hill. 

Disconnected from the target VM, address: '127.0.0.1:51045', transport: 'socket'
Exception in thread "main" java.lang.NullPointerException
at funcatron.java_spring_sample.Application.main(Application.java:46)
2017-04-04 16:15:18.485  INFO 49781 --- [       Thread-1] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1e16c0aa: startup date [Tue Apr 04 16:14:35 PDT 2017]; root of context hierarchy
2017-04-04 16:15:18.486  INFO 49781 --- [       Thread-1] o.s.c.support.DefaultLifecycleProcessor  : Stopping beans in phase 2147483647
2017-04-04 16:15:18.488  INFO 49781 --- [       Thread-1] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown



What am I doing wrong?





--
Funcatron, Simply Serverless http://funcatron.org
Lift, the simply functional web framework http://liftweb.net

Rick Hightower
 

I understand. 


Ok... just to wrap my head around things a bit.

I decided to try to deploy the java (no spring) version.

I just might be doing something wrong.


Docker container for Funcatron is running as follows:

$ docker ps

CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                                                        NAMES

26b03fca941c        funcatron/tron:v0.2.6   "/usr/bin/java -ja..."   51 minutes ago      Up 51 minutes       0.0.0.0:3000->3000/tcp, 0.0.0.0:54657->54657/tcp, 4000/tcp   reverent_williams 


I am in the github project folder for the java example. 

$ pwd

/Users/rick/funcatron/samples/java


As the readme states, I build 

$ mvn clean package

$ find . -name "*.jar"

./target/java_sample-0.1-SNAPSHOT-jar-with-dependencies.jar

./target/java_sample-0.1-SNAPSHOT.jar

Then deploy

$ wget -O - --post-file=target/java_sample-0.1-SNAPSHOT-jar-with-dependencies.jar      http://localhost:3000/api/v1/add_func

I get this:


--2017-04-04 17:01:17--  http://localhost:3000/api/v1/add_func

Resolving localhost... ::1, 127.0.0.1

Connecting to localhost|::1|:3000... connected.

HTTP request sent, awaiting response... 404 Not Found

2017-04-04 17:01:17 ERROR 404: Not Found.

This tells me that I am doing something wrong. 

Since I play a developer on TV, I guess I should go look for where this endpoint is bound in good old tron. 

Which is a bit of a challenge because my cloujure skills mostly equate to I know how to say the word cloujure. (Ok.. a bit more than this but...)

I found the route table in tron. 


(defn tron-routes
"Routes for Tron"
[state]
(-> (routes
(POST "/api/v1/enable" req (enable-func req state))
(POST "/api/v1/disable" req (disable-func req state))
(GET "/api/v1/stats" req (get-stats req state))
(GET "/api/v1/routes" req (get-routes req state))
(GET "/api/v1/known_funcs" req (get-known-funcs req state))
(GET "/api/v1/bundle/:sha" req (return-sha req state))
(POST "/api/v1/add_func"
req (upload-func-bundle req state)))
(wrap-json-response :pretty true :escape-non-ascii true)
rm-json/wrap-json-params
))


Hmm.. maybe ....no wait.. no clue. 


David "Funcmaster D" Pollak
 

Okay... if you're running the "dev mode" container. You cannot upload code to the dev mode container. You can only connect to the dev mode container with funcatron.devshim.Register.register() That connects to port 54657 from your app.

In order to upload a JAR file, you have to run Funcatron in a Mesos cluster and then the wget stuff is valid.

The confusing thing that I have to fix is the Mesos cluster uses port 3000 on the Tron to upload and control the cluster. The dev mode container uses port 3000 for the http request port.

My suggestion is to follow the instructions at https://www.funcatron.org/master/funcatron/info/dev_intro.html including creating a new project from the Maven template.

Feel free/encouraged to open all kinds of issues related to usability. :-(


On Tue, Apr 4, 2017, at 05:13 PM, Rick Hightower wrote:

I understand. 


Ok... just to wrap my head around things a bit.

I decided to try to deploy the java (no spring) version.

I just might be doing something wrong.


Docker container for Funcatron is running as follows:

$ docker ps

CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                                                        NAMES

26b03fca941c        funcatron/tron:v0.2.6   "/usr/bin/java -ja..."   51 minutes ago      Up 51 minutes       0.0.0.0:3000->3000/tcp, 0.0.0.0:54657->54657/tcp, 4000/tcp   reverent_williams 


I am in the github project folder for the java example. 

$ pwd

/Users/rick/funcatron/samples/java


As the readme states, I build 

$ mvn clean package

$ find . -name "*.jar"

./target/java_sample-0.1-SNAPSHOT-jar-with-dependencies.jar


./target/java_sample-0.1-SNAPSHOT.jar

Then deploy

$ wget -O - --post-file=target/java_sample-0.1-SNAPSHOT-jar-with-dependencies.jar      http://localhost:3000/api/v1/add_func

I get this:


--2017-04-04 17:01:17--  http://localhost:3000/api/v1/add_func

Resolving localhost... ::1, 127.0.0.1

Connecting to localhost|::1|:3000... connected.

HTTP request sent, awaiting response... 404 Not Found

2017-04-04 17:01:17 ERROR 404: Not Found.

This tells me that I am doing something wrong. 

Since I play a developer on TV, I guess I should go look for where this endpoint is bound in good old tron. 

Which is a bit of a challenge because my cloujure skills mostly equate to I know how to say the word cloujure. (Ok.. a bit more than this but...)

I found the route table in tron. 


(defn tron-routes
"Routes for Tron"
[state]
(-> (routes
(POST "/api/v1/enable" req (enable-func req state))
(POST "/api/v1/disable" req (disable-func req state))
(GET "/api/v1/stats" req (get-stats req state))
(GET "/api/v1/routes" req (get-routes req state))
(GET "/api/v1/known_funcs" req (get-known-funcs req state))
(GET "/api/v1/bundle/:sha" req (return-sha req state))
(POST "/api/v1/add_func"
req (upload-func-bundle req state)))
(wrap-json-response :pretty true :escape-non-ascii true)
rm-json/wrap-json-params
))


Hmm.. maybe ....no wait.. no clue. 






--
Funcatron, Simply Serverless http://funcatron.org
Lift, the simply functional web framework http://liftweb.net

Rick Hightower
 

That makes sense. 


What are you using to run mesos locally?

Do you use https://minimesos.org/?

I have used DC/OS (mesos distribution) running in AWS, and a few others. 

I have not had much luck (gave up really) running things with Vagrant. But MiniMesos looked encouraging. 

I was just wondering what your dev environment with Mesos looks like. 

Will I need to install DC/OS on AWS? or do you have a suggested env to run things on a Mac Book Pro laptop cirica 2015? :) 

Also are there any docs wrt any of these bits. 

BTW I dig the project. It makes a ton of sense. 

David "Funcmaster D" Pollak
 

I run Mesos via Vagrant on a 128gb workstation... :-)


On Tue, Apr 4, 2017, at 05:35 PM, Rick Hightower wrote:

That makes sense. 


What are you using to run mesos locally?

Do you use https://minimesos.org/?

I have used DC/OS (mesos distribution) running in AWS, and a few others. 

I have not had much luck (gave up really) running things with Vagrant. But MiniMesos looked encouraging. 

I was just wondering what your dev environment with Mesos looks like. 

Will I need to install DC/OS on AWS? or do you have a suggested env to run things on a Mac Book Pro laptop cirica 2015? :) 

Also are there any docs wrt any of these bits. 

BTW I dig the project. It makes a ton of sense. 





--
Funcatron, Simply Serverless http://funcatron.org
Lift, the simply functional web framework http://liftweb.net

Rick Hightower
 

I feel inadequate. 
I have a 32GB NUC and a mac book pro.. beyond that AWS. :) 
I need to go shopping. 


On Tue, Apr 4, 2017 at 6:42 PM, David "Funcmaster D" Pollak <funcmaster-d@...> wrote:
I run Mesos via Vagrant on a 128gb workstation... :-)


On Tue, Apr 4, 2017, at 05:35 PM, Rick Hightower wrote:

That makes sense. 


What are you using to run mesos locally?

Do you use https://minimesos.org/?

I have used DC/OS (mesos distribution) running in AWS, and a few others. 

I have not had much luck (gave up really) running things with Vagrant. But MiniMesos looked encouraging. 

I was just wondering what your dev environment with Mesos looks like. 

Will I need to install DC/OS on AWS? or do you have a suggested env to run things on a Mac Book Pro laptop cirica 2015? :) 

Also are there any docs wrt any of these bits. 

BTW I dig the project. It makes a ton of sense. 





--
Funcatron, Simply Serverless http://funcatron.org
Lift, the simply functional web framework http://liftweb.net




--
Rick Hightower
(415) 968-9037
Profile