swagger-api / swagger-core

Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API
http://swagger.io
Apache License 2.0
7.36k stars 2.17k forks source link

Swagger-play2-util compilation error - Missing Health,Health Snapshot and Memory #33

Closed brainwatch closed 12 years ago

brainwatch commented 12 years ago

Its a very nice tool and hoping to see the admin side of swagger with monitoring capabilities. Swagger-play2-util is not compiling. Stack trace of the error attached for your reference. Health,Health Snapshot and Memory not found in the referenced libraries.

[info] Compiling 1 Scala source to D:\eWorkspace\appify\modules\wordnik-swagger- core-b2bf80d\modules\swagger-play2-utils\target\scala-2.9.1\classes... [error] D:\eWorkspace\appify\modules\wordnik-swagger-core-b2bf80d\modules\swagge r-play2-utils\app\controllers\HealthController.scala:17: HealthSnapshot is not a member of com.wordnik.util.perf [error] import com.wordnik.util.perf.HealthSnapshot [error] ^ [error] D:\eWorkspace\appify\modules\wordnik-swagger-core-b2bf80d\modules\swagge r-play2-utils\app\controllers\HealthController.scala:18: Health is not a member of com.wordnik.util.perf [error] import com.wordnik.util.perf.Health [error] ^ [error] D:\eWorkspace\appify\modules\wordnik-swagger-core-b2bf80d\modules\swagge r-play2-utils\app\controllers\HealthController.scala:19: Memory is not a member of com.wordnik.util.perf [error] import com.wordnik.util.perf.Memory [error] ^

ayush commented 12 years ago

These supporting classes come from wordnik-oss and were recently committed You'll need to build and deploy the latest swagger-oss, specifically the common-utils modules in there.

Please try that and and let me know if there are still problems with using the monitoring stuff. The routes and Build.scala in scala-play2 sample app have been updated to use this.

brainwatch commented 12 years ago

Swagger-play2-util got published with no issues by adding Health library from wordnik-oss. Followed the documentation for routes and build file changes and the UI came out smooth. Ping service works with "OK" message, but not reflected in the swagger UI. Health report unfortunately does not work. Find the stacktrace.

play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[Illega lAccessError: sun/management/ManagementFactory]] at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:134) [ play_2.9.1.jar:2.0.1] at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:115) [ play_2.9.1.jar:2.0.1] at akka.actor.Actor$class.apply(Actor.scala:311) [akka-actor.jar:2.0.1] at play.core.ActionInvoker.apply(Invoker.scala:113) [play_2.9.1.jar:2.0. 1] at akka.actor.ActorCell.invoke(ActorCell.scala:619) [akka-actor.jar:2.0. 1] at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:196) [akka-actor.j ar:2.0.1] Caused by: java.lang.IllegalAccessError: sun/management/ManagementFactory at com.wordnik.util.perf.HealthSnapshot$.get(Health.scala:69) ~[common-u tils_2.9.1-1.1-SNAPSHOT.jar:1.1-SNAPSHOT] at controllers.HealthController$$anonfun$getHealth$1.apply(HealthControl ler.scala:39) ~[swagger-play2-utils_2.9.1.jar:2.0.1] at controllers.HealthController$$anonfun$getHealth$1.apply(HealthControl ler.scala:37) ~[swagger-play2-utils_2.9.1.jar:2.0.1] at play.api.mvc.Action$$anon$1.apply(Action.scala:170) ~[play_2.9.1.jar: 2.0.1] at play.core.ActionInvoker$$anonfun$receive$1$$anonfun$6.apply(Invoker.s cala:126) ~[play_2.9.1.jar:2.0.1] at play.core.ActionInvoker$$anonfun$receive$1$$anonfun$6.apply(Invoker.s cala:126) ~[play_2.9.1.jar:2.0.1]

ayush commented 12 years ago

Hmm this is computed using the ManagementFactory class. Can you confirm if you're able to call its getThreadMXBean method directly?

brainwatch commented 12 years ago

Tried accessing ThreadMXBean in my code. It works fine.

And more trace issue regarding Health. But its from different library. Not sure about the referencing.

[error] c.w.s.c.u.TypeUtil$ - Unable to load class com.wordnik.swagger.discover.Health [error] c.w.s.p.HelpApi - Unable to resolve class com.wordnik.swagger.discover.Health

fehguy commented 12 years ago

@brainwatch, the wordnik-oss snapshots have been updated in sonatype

fehguy commented 12 years ago

@brainwatch also addressed some missing routes, as well the cause of the response type error that you mentioned above. I'm going to close this out--please reopen if you see issues.