when trying to run my first HelloWorld app with springBoot and Tomcat Embeded I get the following exception :
org.springframework.beans.factory.BeanDefinitionStoreException: Failed
to read candidate component class nested exception is
java.lang.IllegalStateException: Could not evaluate condition on org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$EmbeddedDatabaseConfiguration
due to org/springframework/dao/DataAccessException not found. Make
sure your own configuration does not rely on that class. This can also
happen if you are #ComponentScanning a springframework package (e.g.
if you put a #ComponentScan in the default package by mistake)
Here is my entry point Example class config:
#SpringBootApplication
public class Example extends SpringBootServletInitializer
{
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
{
return application.sources(Example.class);
}
public static void main(String[] args) throws Exception
{
SpringApplication.run(Example.class, args);
}
}
Here is my WelcomeController class:
package controler;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.Map;
#Controller
public class WelcomeController
{
// inject via application.properties
#Value("${welcome.message:test}")
private String message = "Hello World";
#RequestMapping("/")
public String welcome(Map<String, Object> model)
{
model.put("message", this.message);
return "welcome";
}
}
Here is my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.springBoot</groupId>
<artifactId>SpringbootHelloword</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Tomcat embedded container-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!-- JSTL for JSP -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<!-- Need this to compile JSP -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<!-- Need this to compile JSP,
tomcat-embed-jasper version is not working, no idea why -->
<dependency>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
<version>4.6.1</version>
<scope>provided</scope>
</dependency>
<!-- Optional, test for static content, bootstrap CSS-->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.7</version>
</dependency>
</dependencies>
</project>
i changed the server port because it was used by another app and it works correctly.
Related
I'm trying to run Vaadin app on azure and I constantly getting error 404. It's basic app with only 2 classes - from spring initializr and one my class.
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class WsbProjektZalApplication {
public static void main(String[] args) {
SpringApplication.run(WsbProjektZalApplication.class, args);
}
}
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(WsbProjektZalApplication.class);
}
}
And one my class
import com.vaadin.flow.component.html.H1;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.Route;
#Route("/co")
public class ListView extends VerticalLayout {
public ListView() {
add(new H1("dziaĆa chyba totto"));
}
}
My pom file is default and I wasn't editing it.
?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>zaliczenie</groupId>
<artifactId>wsb-projekt-zal</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>wsb-projekt-zal</name>
<description>wsb-projekt-zal</description>
<properties>
<java.version>17</java.version>
<vaadin.version>23.0.10</vaadin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>${vaadin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
I'm trying to run this app with war artifacts on tomcat 9. Problems occur only with Vaadin, I can run this app locally without any problems. Can somebody help me and tell me where I'm making mistake?
Screen of error below.
enter image description here
Try to resolve the error by adding the following in $TOMCAT_HOME/conf/server.xml
To avoid memory leaks, Tomcat disables the loading of Java driver files by default.
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" driverManagerProtection="false" />
Also, if you're creating a spring boot application, add "SpringBootServletInitializer" to your main file, as seen in the code below. As without SpringBootServletInitializer, Tomcat will see it as a regular application rather than a Spring boot application.
#SpringBootApplication
public class DemoApplication extends *SpringBootServletInitializer*{
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(DemoApplication .class);
}
public static void main(String[] args) {
SpringApplication.run(DemoApplication .class, args);
}
}
References:
The origin server did not find a current representation for the target resource or is not willing to disclose that one exists ,
Tomcat 404 error: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists [duplicate]
I am working on spring boot admin server but i want to include a spring security using the spring boot starter security dependency to create a login page. When i put my credentials username and password i get the error of this application has no explicit mapping for error. From what i saw i tried including thymeleaf dependency to resolve this problem but it didn't work. Please tell me what i am missing.
package com.example.demo;
import de.codecentric.boot.admin.server.config.EnableAdminServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
#EnableAdminServer
#SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
#Configuration
public static class SecurityConfig extends WebSecurityConfigurerAdapter {
#Override
protected void configure(HttpSecurity http) throws Exception {
http.formLogin().loginPage("/login.html").loginProcessingUrl("/login").permitAll();
http.logout().logoutUrl("/logout");
http.csrf().disable();
http.authorizeRequests().antMatchers("/login.html", "/**/*.css", "/img/**", "/third-party/**").permitAll();
http.authorizeRequests().antMatchers("/**").authenticated();
http.httpBasic();
}
}
}
Springboot Admin server already have the login page and no explicit template has to be created for it. Although i believe that it should be customizable but haven't gone deep into it. Below is my working solution for Springboot admin with default login page.
Main Application class
#EnableAdminServer
#SpringBootApplication
public class AdminApplication {
public static void main(String[] args) {
SpringApplication.run(AdminApplication.class, args);
}
}
Spring security configuration
#Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
private final String adminContextPath;
public WebSecurityConfig(AdminServerProperties adminServerProperties) {
this.adminContextPath = adminServerProperties.getContextPath();
}
#Override
protected void configure(HttpSecurity http) throws Exception {
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
successHandler.setTargetUrlParameter("redirectTo");
successHandler.setDefaultTargetUrl(adminContextPath + "/");
http.authorizeRequests()
.antMatchers(adminContextPath + "/assets/**").permitAll()
.antMatchers(adminContextPath + "/login").permitAll()
.anyRequest().authenticated()
.and()
.formLogin().loginPage(adminContextPath + "/login").successHandler(successHandler).and()
.logout().logoutUrl(adminContextPath + "/logout").and()
.httpBasic().and()
.csrf()
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
.ignoringAntMatchers(
adminContextPath + "/instances",
adminContextPath + "/actuator/**"
);
}
}
Credentials to login on Admin server is defined in application.properties as
spring.security.user.name=admin
spring.security.user.password=Admin#123
Let me know if that helps.
EDIT : I tried to replicate scenario using the files you provided. It was pom.xml that had some missing dependencies. On resolving it, i can login into admin server successfully. Can you update your pom as below and retry. Please refer the comments i added in pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version> <!-- EspringDev CHANGED this version -->
<relativePath/>
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>admin</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-boot-admin.version>2.0.2</spring-boot-admin.version> <!-- EspringDev CHANGED this version -->
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
</dependency>
<!-- EspringDev ADDED below 2 dependencies -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
</dependency>
<dependency>
<groupId>io.projectreactor.netty</groupId>
<artifactId>reactor-netty</artifactId>
<version>0.8.6.RELEASE</version>
</dependency>
<!-- dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-dependencies</artifactId>
<version>${spring-boot-admin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I trying to build a simple welcome page (in jsp) using Spring Boot.
Below is the project structure
Application
#SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
public SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
}
APIController
#Controller
public class APIController {
#RequestMapping("/")
public String home() {
System.out.println("testing");
return "welcome";
}
}
When I access http://localhost:8080/, I get below error
This application has no explicit mapping for /error, so you are seeing
this as a fallback.
Wed May 23 15:31:51 MYT 2018 There was an unexpected error (type=Not
Found, status=404). No message available
By curl
{"timestamp":1527061233703,"status":404,"error":"Not Found","message":"No message available","path":"/"}
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-boot-web-jsp</artifactId>
<packaging>war</packaging>
<name>Spring Boot Web JSP Example</name>
<description>Spring Boot Web JSP Example</description>
<version>1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!-- This is a web application -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<!-- Optional, test for static content, bootstrap CSS-->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.7</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Package as an executable jar/war -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
You have to define the prefix and suffix for you jsp file in application.properties file like following:
spring.mvc.view.prefix: /WEB-INF/jsp/
spring.mvc.view.suffix: .jsp
In directory \src\main\resources\static, Create a simple index.html file
<html>
<head>Hello, Bich Van</head>
<body>
<h3>Today is a rainny day</h3>
</body>
</html>
Then try again at http://localhost:8080
If you don't like static HTML files, you can use JSP, but need a little complicate. You need declaring JSP View resolver in Spring MVC configuration.
Reference document: https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-web-applications.html#boot-features-spring-mvc-welcome-page
Ensure that you have jasper and jstl in the list of dependencies:
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
Here is a working starter project - https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-web-jsp
It's better to use thymeleaf in your spring boot project and add the following dependency
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
In directory \src\main\resources\template, Create a simple index.html file
I'm just started working on Spring Boot and having issues while running the spring boot application. SO scenario is - i have two project
One is called Parent Project SpringBoot and
Other project called web-app is maven module which added in Parent project as module.
In Both Projects(Parent and child) i have Application classes which load the context but somehow when i start the application it gives me some exceptions like on project SpringBoot: Unable to find a suitable main class, please add a mainClass property
On top of that when i run the web-app separately then it works but when i run it through Parent Project SpringBoot it throws me exceptions
Here is my code structure of Spring Boot Project (Parent Project)
Application.java
#Configuration
#ComponentScan
#EnableAutoConfiguration
#SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Example.java
#RequestMapping("/api/**")
#RestController
public class Example {#RequestMapping(method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE})
public String index() {
return "Hello World";
}
}
Pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>SpringBoot</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.1.RELEASE</version>
</parent>
<!-- Additional lines to be added here... -->
<modules>
<module>web-app</module>
</modules
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
Second project which is web-app:
ApplicationWebApp.Java
#Configuration
#ComponentScan
#EnableAutoConfiguration
#SpringBootApplication
ApplicationWebApp
public class ApplicationWebApp {
public static void main(String[] args) {
SpringApplication.run(ApplicationWebApp.class, args);
}
}
Example.java
#RequestMapping("/apis/**")
#RestController
public class Example {#RequestMapping(method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE})
public String index() {
return "Hello World";
}
}
Pom.xml
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.example</groupId>
<artifactId>SpringBoot</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>web-app</artifactId>
</project>
I found couple of solutions on the stackoverflow and different forums by adding
<properties>
The main class to start by executing java -jar
<startclass>com.dashboard.backend.controllers.Application</startclass>
</properties>
By this way, i need to add this properly file in each n every pom.xml to load it. Since this is a web based application so I'm not sure whether its a good solution or not..
If anyone have tried any solution for this problem please share you findings
Java jclouds API fails to connect to an OpenStack provider.
Exception is thrown with the following message: java.util.NoSuchElementException: apiType compute not found in catalog [].
Other APIs (python-novaclient, ruby-fog) work just fine, so the problem looks language (API)-specific.
import static com.google.common.io.Closeables.closeQuietly;
import java.io.Closeable;
import java.util.Set;
import org.jclouds.ContextBuilder;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.domain.ComputeMetadata;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
import org.jclouds.openstack.nova.v2_0.NovaApi;
import org.jclouds.openstack.nova.v2_0.NovaAsyncApi;
import org.jclouds.openstack.nova.v2_0.domain.Server;
import org.jclouds.openstack.nova.v2_0.features.ServerApi;
import org.jclouds.rest.RestContext;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
public class jcloudsOpenStack implements Closeable {
private ComputeService compute;
private RestContext nova;
public static void main(String[] args) {
jcloudsOpenStack jcloudOpenStack = new jcloudsOpenStack();
try {
jcloudOpenStack.init();
jcloudOpenStack.listServers();
jcloudOpenStack.close();
}
catch (Exception e) {
e.printStackTrace();
}
finally {
jcloudOpenStack.close();
}
}
private void init() {
Iterable modules = ImmutableSet. of(new SLF4JLoggingModule());
String provider = "openstack-nova";
String identity = "..."; // login name
String password = "..."; // password
ComputeServiceContext context = ContextBuilder.newBuilder(provider)
.endpoint("https://UltiCloud.com:5000/v2.0/")
.credentials(identity, password)
.modules(modules)
.buildView(ComputeServiceContext.class);
compute = context.getComputeService();
nova = context.unwrap();
}
private void listServers() {
Set<? extends ComputeMetadata> nodes = compute.listNodes();
System.out.println(nodes.size());
}
public void close() {
closeQuietly(compute.getContext());
}
}
Any help or a hint is greatly appreciated
I got the same problem in last few days, and finally i got this resolved.
you should use"username:tenantname" for parameters 'identity' of 'credentials' function.
if you use "username" instead of "tenantname:username", jclouds would query tokens only instead of querying endpoint-list after token-querying, and the exception been thrown.
looks like this:
ComputeServiceContext context = ContextBuilder.newBuilder(provider)
.endpoint("https://UltiCloud.com:5000/v2.0/")
.credentials("admin:admin", "123456")
.modules(modules)
.buildView(ComputeServiceContext.class);
not like this:
ComputeServiceContext context = ContextBuilder.newBuilder(provider)
.endpoint("https://UltiCloud.com:5000/v2.0/")
.credentials("admin", "123456")
.modules(modules)
.buildView(ComputeServiceContext.class);
Hope this could help you guys
You're missing the proper dependencies to run this. It's easiest to use Maven to get them.
The bare minimum you need for the example above is the openstack-nova dependency. To get it make a file called pom.xml and copy in this code.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<jclouds.version>1.7.0</jclouds.version>
</properties>
<groupId>org.apache.jclouds.examples</groupId>
<artifactId>openstack-examples</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>openstack-nova</artifactId>
<version>${jclouds.version}</version>
</dependency>
</dependencies>
</project>
Then run mvn dependency:copy-dependencies "-DoutputDirectory=./lib" that will download all of the dependencies you need to run your example.
Don't forget to include the lib dir in your path when you compile or run it like java -classpath ".:lib/*" jcloudsOpenStack
A more complete pom.xml file for working with all of the OpenStack services supported in jclouds follows.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven 4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<jclouds.version>1.7.0</jclouds.version>
</properties>
<groupId>org.apache.jclouds.examples</groupId>
<artifactId>openstack-examples</artifactId>
<version>1.0</version>
<dependencies>
<!-- jclouds dependencies -->
<dependency>
<groupId>org.apache.jclouds.driver</groupId>
<artifactId>jclouds-slf4j</artifactId>
<version>${jclouds.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.driver</groupId>
<artifactId>jclouds-sshj</artifactId>
<version>${jclouds.version}</version>
</dependency>
<!-- OpenStack dependencies -->
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>openstack-keystone</artifactId>
<version>${jclouds.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>openstack-nova</artifactId>
<version>${jclouds.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>swift</artifactId>
<version>${jclouds.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>openstack-cinder</artifactId>
<version>${jclouds.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>openstack-trove</artifactId>
<version>${jclouds.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.labs</groupId>
<artifactId>openstack-glance</artifactId>
<version>${jclouds.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.labs</groupId>
<artifactId>openstack-marconi</artifactId>
<version>${jclouds.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.labs</groupId>
<artifactId>openstack-neutron</artifactId>
<version>${jclouds.version}</version>
</dependency>
<!-- 3rd party dependencies -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.25</version>
</dependency>
</dependencies>
</project>