Questions tagged [spark-java]

Spark is a lightweight web application framework inspired by Ruby's Sinatra. DO NOT USE FOR QUESTIONS ABOUT APACHE SPARK.

Spark is a lightweight web application framework inspired by Ruby's Sinatra. Its main focus is rapid development in pure Java with no need for extensive, additional XML configuration.

510 questions
32
votes
4 answers

Where to put static files for Spark Web Framework?

Where do I put files when trying to serve static files with the Spark web framework? I haven't been able to find anything online - I'm beginning to suspect I don't understand anything about class paths, relative paths etc. for an Eclipse and Java…
creatsin
  • 321
  • 1
  • 3
  • 4
25
votes
4 answers

java.lang.ClassCastException using lambda expressions in spark job on remote server

I'm trying to build a web api for my apache spark jobs using sparkjava.com framework. My code is: @Override public void init() { get("/hello", (req, res) -> { String sourcePath = "hdfs://spark:54310/input/*"; …
Mehraban
  • 2,747
  • 3
  • 32
  • 56
23
votes
2 answers

How to get the request parameters using get in Spark Java framework?

I'm new to sparkjava. I want to read my request params using spark java but I'm not able to find the correct syntax. please help me out. Below is my route method and the client call to it: my client request…
anup kumar agarwal
  • 233
  • 1
  • 2
  • 6
19
votes
2 answers

How do you send data in a Request body using HttpURLConnection?

I am using HttpURLConnection to make a POST request to a local service deployed locally and created using JAVA Spark. I want to send some data in request body when I make the POST call using the HttpURLConnection but every time the request body in…
utkarsh31
  • 1,197
  • 2
  • 10
  • 18
18
votes
4 answers

How to deploy a spark Java web app?

I used spark web framework to create a webapp, but I don't know how to deploy this webapp. I'm sorry if this is very basic, but I'm new to spark framework and I cannot find any document that guide me how to deploy a spark webapp.: How to deploy a…
MichaelP
  • 2,691
  • 3
  • 29
  • 35
17
votes
5 answers

How to get data from form with spark java?

I'm pretty new with all these things but hope that you guys can help me understand how does it work. I got a form with field . How do i get data from client back? Was looking for some information but couldnt find.
15
votes
1 answer

Use https in spark-java

How can i use custom SSLContext and custom SSLServerSocketFactory in spark-java framework? I've searched in SparkServerImpl but have no idea how to inject sslfactory, any suggestions?
ilya.stmn
  • 1,554
  • 5
  • 21
  • 39
14
votes
2 answers

Connection pooling in Spark Java framework

Java Spark framework uses embedded Jetty as as web server. Jetty supports connection pooling with tools such as HikariCP and provides configuration options in XML files. However, according to these posts, Spark does allow to configure Jetty. There…
Jan Bodnar
  • 8,285
  • 5
  • 54
  • 62
13
votes
2 answers

Spark Framework: Match with or without trailing slash

I have noticed something in the Spark Framework. It does not match trailing slashes with a mapped route. So it considers /api/test and /api/test/ as different URIs. That's fine if there is a way to wildcard them together, but there doesn't seem to…
mtyson
  • 7,100
  • 13
  • 56
  • 97
11
votes
4 answers

spark java: how to handle multipart/form-data input?

I am using spark to develop a web application; the problem occurs when I want to upload a file: public final class SparkTesting { public static void main(final String... args) { Spark.staticFileLocation("/site"); …
fge
  • 110,072
  • 26
  • 223
  • 312
10
votes
2 answers

Why is Sparkjava not suitable for production?

No, not Apache Spark. Sparkjava I have found to be the simplest approach to APIs and the one that clicks the most with me, but everyone states that it shouldn't be used for production, but no one has given me a good answer why. Do any of you know…
cody.tv.weber
  • 419
  • 4
  • 11
10
votes
1 answer

How download file using java spark?

I want to write simple rest api for file download. I cant find docs about it as I understood I need to set mimetype='application/zip' for response, but not clear how to return stream. http://sparkjava.com/ update: resolved here example code: public…
kain64b
  • 2,129
  • 2
  • 13
  • 23
10
votes
3 answers

How do I add headers to a response from spark, when using a transformer

I have this: get ("/test", (req, resp) -> { return repository.getAll(); }, new JsonTransformer()); My transformer looks like: public class JsonTransformer implements ResponseTransformer { ObjectMapper om = new ObjectMapper(); public…
albertjan
  • 7,411
  • 5
  • 39
  • 70
10
votes
1 answer

Getting "Unsupported major.minor version 52.0" exception while using Spark Web Application framework

Getting following exception: Exception in thread "main" java.lang.UnsupportedClassVersionError: spark/Route : Unsupported major.minor version 52.0 trying to use spark web application framework, when I execute file, it throws this exception. Spark…
user3181500
  • 371
  • 1
  • 3
  • 11
9
votes
3 answers

Multiple Spark servers in a single JVM

Is there any way to run multiple instances of Sparkjava server in the same JVM? I am using it in a "plugin" software and based on external circumstances multiple instances of my plugin might be started up which then…
jabal
  • 10,627
  • 10
  • 46
  • 88
1
2 3
33 34