EJB remote lookup namenotfoundexception - ejb

I try to remotely access an EJB in an (eclipse) EJB-Project, packaged as a jar, deployed on a WildFly 10.1.0 Final. The server side is no maven-project, so i added ejb-3.0.jar, javaee-api-7.0.jar, jboss-ejb3-ext-api-1.1.0.jar to the java build path.
My server code is:
package org.maometto.api;
public interface IMyBeanRemote {
void sayHello();
}
package org.maometto.businesslogic;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import org.maometto.api.IMyBeanLocal;
import org.maometto.api.IMyBeanRemote;
#Stateless
#Remote(IMyBeanRemote.class)
public class MyBeanImpl implements IMyBeanRemote {
#Override
public void sayHello() {
System.out.println("I am Server");
}
}
When I start the server from within eclipse the log shows:
21:06:19,015 INFO [org.jboss.as.ejb3.deployment] (MSC service thread
1-4) WFLYEJB0473: JNDI bindings for session bean named 'MyBeanImpl' in
deployment unit 'deployment "MyFirstEJB.jar"' are as follows:
java:global/MyFirstEJB/MyBeanImpl!org.maometto.api.IMyBeanRemote java:app/MyFirstEJB/MyBeanImpl!org.maometto.api.IMyBeanRemote
java:module/MyBeanImpl!org.maometto.api.IMyBeanRemote
java:jboss/exported/MyFirstEJB/MyBeanImpl!org.maometto.api.IMyBeanRemote
java:global/MyFirstEJB/MyBeanImpl java:app/MyFirstEJB/MyBeanImpl
java:module/MyBeanImpl
My Client - a converted maven project in an own project- code is as follows:
package com.maometto.client;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.maometto.api.IMyBeanRemote;
public class EJbClient {
public static void main(String[] args) {
Properties jndiProps = new Properties();
//jndiProps.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
jndiProps.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");
jndiProps.put("jboss.naming.client.ejb.context", true);
try {
InitialContext initialContext = new InitialContext(jndiProps);
IMyBeanRemote iMyBeanRemote = (IMyBeanRemote) initialContext.lookup("java:global/MyFirstEJB/MyBeanImpl!org.maometto.api.IMyBeanRemote");
iMyBeanRemote.sayHello();
} catch (NamingException e) {
e.printStackTrace();
}
}
}
To get the remote interface in the client, i added the ejb-project to the java build path of the client project.
The POM of the client is:
<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>MyEJBClient</groupId>
<artifactId>MyEJBClient</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-jms-client-bom</artifactId>
<version>10.0.0.Final</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-naming</artifactId>
<version>7.1.3.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.marshalling</groupId>
<artifactId>jboss-marshalling-river</artifactId>
<version>1.4.0.Final</version>
</dependency>
<dependency>
<groupId>jboss</groupId>
<artifactId>jbossall-client</artifactId>
<version>4.2.2.GA</version>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.ejb</groupId>
<artifactId>jboss-ejb-api_3.1_spec</artifactId>
<version>1.0.2.Final</version>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-ejb-client</artifactId>
<version>4.0.8.Final</version>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-ejb-client-bom</artifactId>
<version>11.0.0.Final</version>
<type>pom</type>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
When I execute the client, i get following stacktrace in the log:
javax.naming.NameNotFoundException: global/MyFirstEJB/MyBeanImpl!org.maometto.api.IMyBeanRemote -- service jboss.naming.context.java.jboss.exported.global.MyFirstEJB."MyBeanImpl!org.maometto.api.IMyBeanRemote"
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:106)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:184)
at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:127)
at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:73)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
I tried it with the other jndiBindings as well.
I also tried it with the "ejb:" namespace and its convention ("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName). Still same error. I don't know what I'm missing or what I'm doing wrong.
Can anyone help me, please?

Related

Firebase send request with oauth2 token example not working

Trying to get simple google oauth example from Firebase docs to work using Firebase service account json file https://firebase.google.com/docs/cloud-messaging/auth-server#windows :
private static String getAccessToken() throws IOException {
GoogleCredentials googleCredentials = GoogleCredentials
.fromStream(new FileInputStream("service-account.json"))
.createScoped(Arrays.asList(SCOPES));
googleCredentials.refreshAccessToken();
return googleCredentials.getAccessToken().getTokenValue();
} //Messaging.java
Following is my code in Netbeans IDE:
import com.google.auth.oauth2.GoogleCredentials;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template
*/
/**
*
* #author Administrator
*/
public class TrOauth2 {
private static final String MESSAGING_SCOPE = "https://www.googleapis.com/auth/firebase.messaging";
private static final String[] SCOPES = {MESSAGING_SCOPE};
private static String comeon;
public static void main(String[] args) {
try {
System.out.println("Hello World!");
comeon = getAccessToken();
System.out.println(comeon);
} catch (IOException ex) {
Logger.getLogger(TrOauth2.class.getName()).log(Level.SEVERE, null, ex);
System.out.println("Exception when calling getAcessToken();");
}
}
private static String getAccessToken() throws FileNotFoundException, IOException {
GoogleCredentials googleCredentials = GoogleCredentials.fromStream(new FileInputStream("C:\\Users\\administrator\\Downloads\\lora-alarm-firebase-adminsdk-xxx-xxx.json")).createScoped(Arrays.asList(SCOPES));
System.out.println("googleCredentials: " + googleCredentials.toString());
return googleCredentials.getAccessToken().getTokenValue();
}
}
Maven code:
<?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.midniteit</groupId>
<artifactId>TrOauth2</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
<exec.mainClass>TrOauth2</exec.mainClass>
</properties>
<dependencies>
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client</artifactId>
<version>1.34.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.13.4</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.6.1</version>
</dependency>
<dependency>
<groupId>xpp3</groupId>
<artifactId>xpp3</artifactId>
<version>1.1.4c</version>
</dependency>
<dependency>
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-oauth2-http</artifactId>
<version>1.11.0</version>
<type>jar</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<mainClass>TrOauth2</mainClass>
</configuration>
<executions>
<execution>
<id>execute-after-compile</id>
<goals><goal>java</goal></goals>
<phase>compile</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I get the following results from Netbeans IDE when I run it:
Hello World!
googleCredentials: ServiceAccountCredentials{clientId=xxx, clientEmail=firebase-adminsdk-xxx#lora-alarm.iam.gserviceaccount.com, privateKeyId=xxx, transportFactoryClassName=com.google.auth.oauth2.OAuth2Utils$DefaultHttpTransportFactory, tokenServerUri=https://oauth2.googleapis.com/token, scopes=[https://www.googleapis.com/auth/firebase.messaging], defaultScopes=[], serviceAccountUser=null, quotaProjectId=null, lifetime=3600, useJwtAccessWithScope=false, defaultRetriesEnabled=true}
java.lang.NullPointerException
at TrOauth2.getAccessToken (TrOauth2.java:43)
at TrOauth2.main (TrOauth2.java:29)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254)
at java.lang.Thread.run (Thread.java:835)
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
When I run program through command line, I get this, without the googleCredentials line being printed:
C:\Users\administrator\Documents\NetBeansProjects\TrOauth2\target\classes>"c:\progra~1\java\jdk-12~1.1\bin\java" TrOauth2
Hello World!
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/auth/oauth2/GoogleCredentials
at TrOauth2.getAccessToken(TrOauth2.java:41)
at TrOauth2.main(TrOauth2.java:29)
Caused by: java.lang.ClassNotFoundException: com.google.auth.oauth2.GoogleCredentials
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 2 more
How is this happening, or what might I be doing wrong? Any ideas would be appreciated.

Apache Camel - Multipart File upload

Using Apache-Camel ESB, trying to upload a xlsx file to Spring Rest Web application. Upload fails from apache-camel ESB. But upload works fine from Postman. Shared code snippets below.
Processor Code in Router of Camel looks like
from("file://data/PASInput").process(new Processor() {
#Override
public void process(Exchange exchange) throws Exception {
MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
multipartEntityBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
String filename = (String) exchange.getIn().getHeader(Exchange.FILE_NAME);
File file = exchange.getIn().getBody(File.class);
multipartEntityBuilder.addPart("file",
new FileBody(file, ContentType.MULTIPART_FORM_DATA, filename));
ByteArrayOutputStream out = new ByteArrayOutputStream();
multipartEntityBuilder.build().writeTo(out);
InputStream inputStream = new ByteArrayInputStream(out.toByteArray());
exchange.getOut().setBody(inputStream);
}
}).to("http://localhost:8080/Pastel/api/convertor/pas/pastel")
.log(LoggingLevel.ERROR, "RESPONSE BODY ${body}").end();
Pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>2.21.0.fuse-000077-redhat-1</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cxf</artifactId>
<version>2.21.0.fuse-000077-redhat-1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-http</artifactId>
<version>2.21.0.fuse-000077-redhat-1</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-http4</artifactId>
<version>2.17.2</version>
</dependency>
Error
org.apache.camel.http.common.HttpOperationFailedException: HTTP operation failed invoking http://localhost:8080/Pastel/api/convertor/pas/pastel with statusCode: 500
at org.apache.camel.component.http.HttpProducer.populateHttpOperationFailedException(HttpProducer.java:274)
at org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:183)
at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:452)
at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:219)
at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:183)
at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174)
at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
When we hit the webservice using postman, there are no errors. Able to upload the servers successfully. Spring mvc code,
#RequestMapping(value = "/pas/pastel", method = RequestMethod.POST)
#ResponseBody
public void convertPASToPastel(HttpServletRequest request, HttpServletResponse response,
#RequestParam(value = "file") final MultipartFile pasFile) {
try {
System.out.print("Here");
}
}
You can probably see this error message in your Spring backend log:
org.springframework.web.multipart.MultipartException: Current request is not a multipart request.
You need to set correct ContentType header. Please refer this similar question for solution, if you want to implement it in this way.
But you can get out this mess, if you switch co camel-http4 component (you already have this component in pom.xml). This component contains logic for converting HttpEntity to InputStream. Then you can set HttpEntity directly to exchange body.
Then your route will look something like this:
from("file://data/PASInput").process(new Processor() {
#Override
public void process(Exchange exchange) throws Exception {
MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
multipartEntityBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
String filename = exchange.getIn().getHeader(Exchange.FILE_NAME, String.class);
File file = exchange.getIn().getBody(File.class);
multipartEntityBuilder.addPart("file",
new FileBody(file, ContentType.MULTIPART_FORM_DATA, filename));
exchange.getOut().setBody(multipartEntityBuilder.build());
}
}).to("http4://localhost:8080/Pastel/api/convertor/pas/pastel")
.log(LoggingLevel.ERROR, "RESPONSE BODY ${body}").end();
And just a note. Never mix component versions, always use for components the same version as Apache Camel version. Otherwise you can see upredictable results. And why you have annotation #ResponseBody in Spring controller, when the method is void? You don`t need that.

Spring Cloud Contract org.junit.ComparisonFailure: expected: <[200]> but was:<[404]> while running tests

I've setup a sample project to use Spring Cloud Contract 2.0.0.RC1 just to get it working. When I run the tests I receive the error message:
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 3.188 sec <<< FAILURE!
validate_shouldGetProfile(com.example.contractdemoserver.ContractdemoserverTest) Time elapsed: 0.443 sec <<< FAILURE!
org.junit.ComparisonFailure: expected:<[200]> but was:<[404]>
at com.example.contractdemoserver.ContractdemoserverTest.validate_shouldGetProfile(ContractdemoserverTest.java:27)
The project builds and runs fine otherwise. I've tried numerous things to resolve this test error including checking to see if the ContractVerifieriBase is being called by adding a System.out.println() message to Contractdemoserverbase.setup() (see below), and it is being called.
I've been trying to follow/emulate just the producer project from here (which runs and tests fine):
https://github.com/spring-cloud-samples/spring-cloud-contract-samples
What am I doing wrong?
Project Structure is laid out in idea like so:
ContractdemoserverApplication:
package com.example.contractdemoserver;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class ContractdemoserverApplication {
public static void main(String[] args) {
SpringApplication.run(ContractdemoserverApplication.class, args);
}
}
ServerDefaultController:
package com.example.contractdemoserver;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
#Controller
public class ServerDefaultController {
public static final String controllerName = "test";
public static final String controllerPath = "/" + controllerName;
#RequestMapping(value = controllerPath, headers={"application/json"})
#ResponseBody
public TestObject get(){
return new TestObject(1001, new String[0]);
}
}
TestObject:
package com.example.contractdemoserver;
public class TestObject {
private int id;
private String[] cards;
public TestObject(){}
public TestObject(int id, String[] cards){
setId(id);
setCards(cards);
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String[] getCards() {
return cards;
}
public void setCards(String[] cards) {
this.cards = cards;
}
}
ContractdemoserverBase:
package com.example.contractdemoserver;
import io.restassured.module.mockmvc.RestAssuredMockMvc;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
#RunWith(SpringRunner.class)
#SpringBootTest
public abstract class ContractdemoserverBase {
#Before
public void setup() {
RestAssuredMockMvc.standaloneSetup(new ServerDefaultController());
}
}
shouldGetProfile.groovy:
package contracts.contractdemoserver
import org.springframework.cloud.contract.spec.Contract
Contract.make {
description("""
Represents a successful scenario of getting a response from the /test endpoint.
```
given:
nothing
when:
a request for a Test is made
then:
returns a test object with id 1001 and no cards
```
""")
request {
method 'GET'
url '/test'
headers {
contentType(applicationJson())
}
}
response {
status 200
body("""
{
"id":1001,
"cards":[]
}
""")
headers {
contentType(applicationJson())
}
}
}
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>contractdemoserver</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>server</name>
<description>POC Server for Service Contract Testing</description>
<properties>
<docker-maven-plugin-version>0.25.0</docker-maven-plugin-version>
<java.version>1.8</java.version>
<maven-resources-plugin.version>3.0.2</maven-resources-plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot-dependencies-version>2.0.1.RELEASE</spring-boot-dependencies-version>
<spring-cloud.version>Finchley.BUILD-SNAPSHOT</spring-cloud.version>
<spring-cloud-contract.version>2.0.0.BUILD-SNAPSHOT</spring-cloud-contract.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-contract-verifier</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot-dependencies-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>
<version>2.0.2.RELEASE</version>
</plugin>
<plugin>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-maven-plugin</artifactId>
<version>${spring-cloud-contract.version}</version>
<extensions>true</extensions>
<configuration>
<!-- <baseClassForTests>com.example.contractdemoserver.ContractVerifierBase</baseClassForTests> -->
<packageWithBaseClasses>com.example.contractdemoserver</packageWithBaseClasses>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>http://repo.spring.io/release</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-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-plugin-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/plugins-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-plugin-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/plugins-release-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
Any suggestions would be greatly appreciated.
The method #RequestMapping(value = controllerPath, headers={"application/json"}) is missing/requires the property produces = "application/json" in order for Contract testing to work. Classic Spring feedback.

Swagger 2 + Spring MVC + WAS 8.5.5 throwing java.lang.VerifyError: JVMVRFY013 for AOP classes

I am new to swagger, and trying to integrate swagger2 with my Spring MVC (4.3.10 release) application which will be deployed into WAS 8.5.5. At the time of application startup, I am getting the below error,
Caused by: java.lang.VerifyError: JVMVRFY013 class loading constraint violated; class=org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint, method=getSourceLocation()Lorg/aspectj/lang/reflect/SourceLocation;, pc=0
at java.lang.J9VMInternals.verifyImpl(Native Method)
at java.lang.J9VMInternals.verify(J9VMInternals.java:85)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:162)
at org.springframework.aop.aspectj.AspectJAroundAdvice.lazyGetProceedingJoinPoint(AspectJAroundAdvice.java:81)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:68)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
My swagger configurations are as below,
Added swagger dependencies in pom.xml
<!-- Swagger dependencies -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.2.2</version>
</dependency>
Added below annotations to my controller classes/operations
#Api(value="someController", description="services API")
#ApiOperation(value = "someOperation")`
Swagger reource configuration in applicationContext.xml
<mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>
<mvc:resources mapping="/swagger-ui.html" location="classpath:/META-INF/resources/swagger-ui.html"/>
<mvc:default-servlet-handler/>
<bean id="swagger2Config" class="springfox.documentation.swagger2.configuration.Swagger2DocumentationConfiguration"/>
SwaggerConfig class
#Configuration
#EnableSwagger2
public class SwaggerConfig {
#Bean
public Docket api(){
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build()
.apiInfo(apiInfo());
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("TITLE")
.description("Description")
.version("1.0")
.build();
}
}
Any help on this would be greatly appreciated. Thanks

google cloud storage tried to access method com.google.cloud.ServiceOptions.getFromServiceLoader error

I am trying to test google cloud storage in local mvn jetty server.
defining the following java servlet I get the following error during servlet initiallization.
#WebServlet(name = "receiveImage", value = "receiveImage")
#SuppressWarnings("serial")
#MultipartConfig()
public class receiveImage extends HttpServlet {
private static final String BUCKET_NAME = "testbucket";
private static Storage storage = null;
#Override
public void init() {
storage = StorageOptions.defaultInstance().service();
}
HTTP ERROR 500
Problem accessing /receiveImage. Reason:
Server Error
Caused by:
java.lang.IllegalAccessError: tried to access method com.google.cloud.ServiceOptions.getFromServiceLoader(Ljava/lang/Class;Ljava/lang/Object;)Ljava/lang/Object; from class com.google.cloud.HttpServiceOptions
at com.google.cloud.HttpServiceOptions.(HttpServiceOptions.java:154)
at com.google.cloud.storage.StorageOptions.(StorageOptions.java:69)
at com.google.cloud.storage.StorageOptions.(StorageOptions.java:27)
at com.google.cloud.sto
i define the following maven dependency in pom file:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>0.4.0</version>
</dependency>
Appreciate for helps.
I could resolve the issue:
there is a conflict between these two dependencies:
dependency>
<groupId>com.google.cloud</groupId>
<artifactId>gcloud-java-datastore</artifactId>
<version>0.2.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>0.5.1</version>
</dependency>
I just changed the first dependency to
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-datastore</artifactId>
<version>0.5.1</version>
</dependency>

Resources