When I hit the service externally, both fields of type LocalDate are resolved okey, and the service works.
But when I try to test the very same endpoint using a TestRestTemplate the fields arrive to the controller as null.
What's the problem?
UPDATE:
The problem is even worst. When I tried to test another service I found the deserialization done by the TestRestTemplate made a list of LocalDate to be build as an empty list.
I experiment with custom serializer and deserializer and nothing works. =/
Controller
#RestController
public class ReservationController {
#PostMapping("/reservation")
public String makeReservation(#RequestBody Reservation Reservation) {
return this.reservationService.makeReservation(Reservation);
}
}
Test
#RunWith(SpringRunner.class)
#SpringBootTest(classes = AppRunner.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ReservationControllerTest {
#LocalServerPort
private int port;
private TestRestTemplate restTemplate = new TestRestTemplate();
#Test
public void attemp4(){
LocalDate from = LocalDate.of(2019,1, 1);
LocalDate to = LocalDate.of(2019,1, 21);
Reservation Reservation = new Reservation(from, to);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<Reservation> entity = new HttpEntity<>(Reservation, headers);
String uri = "http://localhost:"+port+"/reservation";
ResponseEntity<String> response = restTemplate.postForEntity(uri, entity, String.class);
Assert.assertNotNull(response);
}
}
Reservation / API DTO
public class Reservation {
private LocalDate checkIn;
private LocalDate checkOut;
public Reservation(LocalDate checkin, LocalDate checkout) {
this.checkIn = checkin;
this.checkOut = checkout;
}
public LocalDate getCheckIn() {
return checkIn;
}
public LocalDate getCheckOut() {
return checkOut;
}
}
Just in case, pom.xml
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>com.mysystem</groupId>
<artifactId>spring-boot-2-jdbc-with-h2</artifactId>
<version>0.0.4-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<findbugs-maven-plugin.version>3.0.4</findbugs-maven-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>27.0.1-jre</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<profiles>
<profile>
<id>integration-test</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-test-source</id>
<phase>initialize</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/integration-test/java</source>
<source>src/test/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-resource</id>
<phase>initialize</phase>
<goals>
<goal>add-test-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/integration-test/resources</directory>
</resource>
<resource>
<directory>src/test/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<runOrder>random</runOrder>
</configuration>
</plugin>
</plugins>
</build>
</profiles>
Thanks in advance!
I'm trying to create a war file, and the push that to my tomcat8 webserver.
The problem is, that tomcat throws the following error while trying to access the webapp:
java.io.FileNotFoundException: /var/lib/tomcat8/webapps/tdc-stress-test-2.0-Web.war!/WEB-INF/classes (No such file or directory)
then after comes:
java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: Basedevice is not mapped [Select t from Basedevice t]
The database is located on the server on which I have pushed the war-file. The persistence.xml is configured to use the database on the server.
This works fine if I run it by jetty::run local, but not when I push it to the server.
What is going on?
The plugin for creating the war:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<!-- Exclude an unnecessary file generated by the GWT compiler. -->
<packagingExcludes>WEB-INF/classes/VAADIN/widgetsets/WEB-INF/**</packagingExcludes>
</configuration>
</plugin>
The full one:
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>tdc.otva.stress</groupId>
<artifactId>tdc-stress-test</artifactId>
<packaging>war</packaging>
<version>2.0-Web</version>
<name>tdc-stress-test</name>
<prerequisites>
<maven>3</maven>
</prerequisites>
<properties>
<vaadin.version>7.7.4</vaadin.version>
<vaadin.plugin.version>7.7.4</vaadin.plugin.version>
<jetty.plugin.version>9.3.9.v20160517</jetty.plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<!-- If there are no local customisations, this can also be "fetch" or "cdn" -->
<vaadin.widgetset.mode>local</vaadin.widgetset.mode>
</properties>
<repositories>
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>${vaadin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-server</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-push</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.1.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.37</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiled</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.6.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.rxtx/rxtx -->
<dependency>
<groupId>org.rxtx</groupId>
<artifactId>rxtx</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-themes</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<!-- Exclude an unnecessary file generated by the GWT compiler. -->
<packagingExcludes>WEB-INF/classes/VAADIN/widgetsets/WEB-INF/**</packagingExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://xxxx.xxx.net:8080/manager/text</url>
<username>admin</username>
<password>admin123</password>
<path>/HelloWorld</path>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.plugin.version}</version>
<executions>
<execution>
<goals>
<goal>update-theme</goal>
<goal>update-widgetset</goal>
<goal>compile</goal>
<!-- Comment out compile-theme goal to use on-the-fly theme compilation -->
<goal>compile-theme</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<!-- Clean up also any pre-compiled themes -->
<configuration>
<filesets>
<fileset>
<directory>src/main/webapp/VAADIN/themes</directory>
<includes>
<include>**/styles.css</include>
<include>**/styles.scss.cache</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
<!-- The Jetty plugin allows us to easily test the development build by
running jetty:run on the command line. -->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.plugin.version}</version>
<configuration>
<scanIntervalSecScreenshot from 2017-03-31 12-42-18onds>2</scanIntervalSeconds>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<!-- Vaadin pre-release repositories -->
<id>vaadin-prerelease</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<repositories>
<repository>
<id>vaadin-prereleases</id>
<url>http://maven.vaadin.com/vaadin-prereleases</url>
</repository>
<repository>
<id>vaadin-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>vaadin-prereleases</id>
<url>http://maven.vaadin.com/vaadin-prereleases</url>
</pluginRepository>
<pluginRepository>
<id>vaadin-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
The War does contain the /classes.
Best regardsScreenshot from 2017-03-31 12-42-18
I switched from Juno Eclipse to Kepler and imported my Maven project. However "Maven Dependencies" doesn't show up under Project-Properties-Java Build Path-Libraries and thus i can't compile my project. In Maven Repositories view i can see all my dependencies jar files under Local Repositories. I can manually add External Jar Files but there must be a right way to load them dynamically. I can run "maven install" successfully from Eclipse. I've tried all suggestions from this forum such as - run Maven-Update Project, unchecked Maven-Resolve dependencies from Workspace projects, Window-Preferences-check "Download repository index updates on startup" and "Update Maven projects on startup". Something is weird about Kepler Eclipse. What am i missing?
Here is my pom.xml
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxx.xxx</groupId>
<artifactId>actives</artifactId>
<version>3.1.0</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<id>jar-with-dependencies</id>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<mainClass>com.xxx.xxx.xxx.xxx.XXX</mainClass>
</manifest>
</archive>
<descriptors>
<descriptor>src/main/assembly/bin.xml</descriptor>
</descriptors>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef> <!-- Include all depedencies in build -->
</descriptorRefs>
<!--<appendAssemblyId>false</appendAssemblyId> -->
</configuration>
</plugin>
</plugins>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.3</version>
</extension>
</extensions>
</build>
<properties>
<root>.</root>
<xxx.releases>http://xxx.xxx.local/mave</xxx.releases>
<xxxx.releases>http://xxx.xxx.local/xxx/releases</xxx.releases>
<xxx.snapshots>http://xxx.associatesys.local/xxx/snapshots</xxx.snapshots>
<xxx.releases.distribution>scp://xxx.associatesys.local/../../../srv/www/release/xxxx/releases</xxx.releases.distribution>
<xxx.snapshots.distribution>scp://xxx.xxx.local/../../../srv/www/release/xxx/snapshots</xxx.snapshots.distribution>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>central</id>
<name>central</name>
<url>http://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>xxx-central</id>
<name>XXXCentral</name>
<url>http://xxx.xxx.local/maven2/central</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>xxx-releases</id>
<name>Internal ReleasesRepository</name>
<url>${xxx.releases}</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>xxx-releases</id>
<name>XXXReleases Repository</name>
<url>${xxx.releases}</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>xxx-snapshots</id>
<name>XXXX Snapshots Repository</name>
<url>${xxx.snapshots}</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>interval:30</updatePolicy>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>sqljdbc</groupId>
<artifactId>sqljdbc</artifactId>
<version>4</version>
</dependency>
<dependency>
<groupId>xxxx</groupId>
<artifactId>xxx-xxx</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.xxx.xxx.client</groupId>
<artifactId>xxx-client</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.xxx.xxx.xxx</groupId>
<artifactId>xxx-xxx</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.xxx.xxx.common</groupId>
<artifactId>xxx-common</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>xxx-releases</id>
<name>XXXXReleases Repository</name>
<url>${xxx.releases.distribution}</url>
</repository>
<snapshotRepository>
<id>xxx-snapshots</id>
<name>XXXSnapshots Repository</name>
<url>${xxx.snapshots.distribution}</url>
</snapshotRepository>
</distributionManagement>
UPDATE: i solved this problem by copy and paste .classpath and .project files from another Maven project in Eclipse (Kepler) that was created with no issues. I made minor adjustments to these 2 files. I compared pom.xml files and found no discrepancies that would prevent Eclipse from creating my Maven project. It's not an ideal solution but it works for now, no time to solving Eclipse "mysteries". Thanks for the below comments, they pointed me into a right direction and helped to understand a problem better.
I am creating a web app and at the moment I'm trying to get a tomcat server to run. However I get this error message when ran from the cmd line.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tomcat/uti
l/http/mapper/Mapper
at org.apache.catalina.core.StandardContext.<init>(StandardContext.java:457)
at org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:532)
at org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:526)
at org.apache.catalina.startup.Tomcat.addWebapp(Tomcat.java:207)
at hello.Server.createTomcatServer(Server.java:34)
at hello.Application.main(Application.java:57)
Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.util.http.mapper.
Mapper
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 6 more
This 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>org.springframework</groupId>
<artifactId>gs-relational-data-access</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.0.RC4</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>7.0.52</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
</dependencies>
<properties>
<start-class>hello.Application</start-class>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.2</version>
<configuration>
<!-- put your configurations here -->
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
And finally my tomcat server code:
public void createTomcatServer() throws ServletException, LifecycleException{
Tomcat tomcat = null;
Integer webPort = new Integer(9696);
tomcat.setPort(webPort);
tomcat.addWebapp("/", new File(webappDirLocation).getAbsolutePath());
System.out.println("configuring app with basedir: " + new File("./" + webappDirLocation).getAbsolutePath());
tomcat.start();
tomcat.getServer().await();
}
I thought I had included all the correct dependencies, etc. But I just cant find out why its not working - I've looked all over google already - so any help would be greatly appreciated.
I encountered the same problem as well and solved it by depending on the embed module instead.
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>${embedded.tomcat.version}</version>
</dependency>
i am struggling with CXF and pom files.
I want to add a dependency to the axis2 to it, so I added this to my pom.
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2</artifactId>
<version>1.5.2</version>
</dependency>
It downloads the dependency correctly and everything seems to work. When I deploy, I get this message:
The bundle could not be resolved. Reason: Missing Constraint: Import-Package: org.apache.axis2.databinding; version="0.0.0"
So I changed my plugin tag to add the org.apache.axis2.databinding reference:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Bundle-Activator>de.innoshgs.iai.services.pruefentxschema_uas_01.Activator</Bundle-Activator>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Import-Package>
javax.jws,
javax.wsdl,
javax.xml.bind,
javax.xml.bind.annotation,
javax.xml.namespace,
javax.xml.soap,
javax.xml.transform,
javax.xml.ws,
javax.xml.ws.handler,
javax.xml.ws.handler.soap,
META-INF.cxf,
META-INF.cxf.osgi,
org.apache.cxf.bus,
org.apache.cxf.bus.spring,
org.apache.cxf.bus.resource,
org.apache.cxf.configuration.spring,
org.apache.cxf.feature,
org.apache.cxf.resource,
org.apache.cxf.transport.http_osgi,
org.apache.cxf.interceptor,
org.apache.servicemix.util,
org.springframework.beans.factory.config,
org.apache.camel.osgi,
org.apache.axis2.databinding,
sun.misc;resolution:=optional,
!de.innoshgs.iai.services.pruefentxschema_uas_01,
!de.innoshgs.iai.namespace,
*
</Import-Package>
<Require-Bundle>org.apache.cxf.bundle</Require-Bundle>
<Private-Package>
de.innoshgs.iai.services.pruefentxschema_uas_01,
de.innoshgs.iai.namespace,
</Private-Package>
</instructions>
</configuration>
</plugin>
But I keep getting the same error.
I am not a java dev, I am starting with it,so I am a lost with it. I have been searching and I could get som e hints until I got to this point, but now I seem to get stuck.
What do I have to do, so maven is able to find this databinding reference?
The whole pom file is here:
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.servicemix.examples</groupId>
<artifactId>examples</artifactId>
<version>4.2.0-fuse-01-00</version>
</parent>
<groupId>de.innoshgs.iai.Services</groupId>
<artifactId>PruefenTXSchema_UAS_01</artifactId>
<packaging>bundle</packaging>
<version>4.2.0-fuse-01-00</version>
<name>PruefenTXSchema_UAS_01</name>
<!-- Add fusesource repositories for snaphots and releases -->
<pluginRepositories>
<pluginRepository>
<id>fusesource.m2-snapshot</id>
<name>FuseSource Snapshots Repository</name>
<url>http://repo.fusesource.com/maven2-snapshot/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
<pluginRepository>
<id>fusesource.m2</id>
<name>FuseSource Repository</name>
<url>http://repo.fusesource.com/maven2/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>fusesource.m2-snapshot</id>
<name>FuseSource Snapshots Repository</name>
<url>http://repo.fusesource.com/maven2-snapshot/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
<repository>
<id>fusesource.m2</id>
<name>FuseSource Repository</name>
<url>http://repo.fusesource.com/maven2/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>${commons.logging.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-ftp</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-ws-metadata_2.0_spec</artifactId>
<version>${geronimo.wsmetadata.version}</version>
</dependency>
<dependency>
<groupId>org.apache.servicemix</groupId>
<artifactId>servicemix-utils</artifactId>
<version>${servicemix-utils.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>5.3.1-fuse-02-00</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cxf</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.servicemix.kernel</groupId>
<artifactId>org.apache.servicemix.kernel.main</artifactId>
<version>1.1.0.1-fuse</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2</artifactId>
<version>1.5.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/src/main/java</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/PruefenTXSchema_UAS_01Service.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Bundle-Activator>de.innoshgs.iai.services.pruefentxschema_uas_01.Activator</Bundle-Activator>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Import-Package>
javax.jws,
javax.wsdl,
javax.xml.bind,
javax.xml.bind.annotation,
javax.xml.namespace,
javax.xml.soap,
javax.xml.transform,
javax.xml.ws,
javax.xml.ws.handler,
javax.xml.ws.handler.soap,
META-INF.cxf,
META-INF.cxf.osgi,
org.apache.axis2.databinding,
org.apache.cxf.bus,
org.apache.cxf.bus.spring,
org.apache.cxf.bus.resource,
org.apache.cxf.configuration.spring,
org.apache.cxf.feature,
org.apache.cxf.resource,
org.apache.cxf.transport.http_osgi,
org.apache.cxf.interceptor,
org.apache.servicemix.util,
org.springframework.beans.factory.config,
org.apache.camel.osgi,
sun.misc;resolution:=optional,
!de.innoshgs.iai.services.pruefentxschema_uas_01,
!de.innoshgs.iai.namespace,
*
</Import-Package>
<Require-Bundle>org.apache.cxf.bundle</Require-Bundle>
<Private-Package>
de.innoshgs.iai.services.pruefentxschema_uas_01,
de.innoshgs.iai.namespace,
</Private-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
Thanks a lot,
Oscar
Edit: just to make it clear: the server and the computer I am using to develop are different machines.
Can you try adding axis2-adb dependency and see if the error persists?
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-adb</artifactId>
<version>1.5.2</version>
</dependency>
The issue seems to be that the dependency you want to add to your project does not exist in the server. You need your JAR to provide the dependency on the server. Try adding:
<Embed-Dependency>axis2</Embed-Dependency>
after the Import-Package element of your maven bundle plugin configuration. This will embed the axis2 jar into your compiled jar, expose it and allow it to be called within the server. Further reading about the embed dependency can be found at Apache Felix - Embedding Dependencies although I will admit it is not all that helpful to know when/why to use it.