Application packages can contain Java components to be run in container clusters. The most common component types are:
Components are constructed by dependency injection and are reloaded safely on deployment without restarts. See the container documentation for more details.
See the sample applications in getting started, to find examples of applications containing Java components. Also see troubleshooting.
The development cycle consists of creating the component, deploying the application package to Vespa, writing tests, and iterating. These steps refer to files in album-recommendation-java:
All the Vespa sample applications use the bundle plugin to build the components.
A key Vespa feature is code and configuration consistency, deployed using an application package. This ensures that code and configuration is in sync, and loaded atomically when deployed. This is done by generating config classes from config definition files. In Vespa and application code, configuration is therefore accessed through generated config classes - read more in the Cloud Configuration System.
The Maven target
After generating config classes, they will resolve in tools like IntelliJ IDEA.
Examples unit tests are found in
Read more in unit testing.
To debug a Searcher / Document Processor / Component running in the container, set up a remote debugging configuration in the IDEA - IntelliJ example:
+to add a new configuration.
<container id="default" version="1.0"> <nodes> <jvm options="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005" />
$ docker run --detach --name vespa --hostname vespa-container \ --publish 8080:8080 --publish 19071:19071 --publish 5005:5005 \ vespaengine/vespa
If using IntelliJ, install the Vespa IntelliJ plugin to simplify working with schema files: