Feign client building URL using app name instead of hostname - spring-cloud

In a nutshell:
feign client tries to call http://MyApp/endpoint instead of http://10.0.1.24:8080/endpoint
I have an application with instances in AWS registering to an Eureka server and a feign client on the same Eureka server trying to communicate with the application (server is also client of itself if you will).
This is an sample of the /eureka/apps output on the server:
<application>
<name>JSAPI</name>
<instance>
<hostName>10.0.1.24</hostName>
<app>JSAPI</app>
<ipAddr>10.0.1.24</ipAddr>
<status>UP</status>
<overriddenstatus>UNKNOWN</overriddenstatus>
<port enabled="true">8080</port>
<securePort enabled="false">443</securePort>
<countryId>1</countryId>
<dataCenterInfo class="com.netflix.appinfo.AmazonInfo">
<name>Amazon</name>
<metadata>
<public-ipv4>52.91.157.255</public-ipv4>
<accountId>831427253318</accountId>
<local-hostname>10.0.1.24</local-hostname>
<public-hostname>ec2-52-91-157-255.compute-1.amazonaws.com</public-hostname>
<instance-id>i-1f86e68c</instance-id>
<local-ipv4>10.0.1.24</local-ipv4>
<instance-type>m4.large</instance-type>
<vpc-id>vpc-3c5e155b</vpc-id>
<ami-id>ami-ee5737f9</ami-id>
<mac>0e:3c:e0:fa:3f:1c</mac>
<availability-zone>us-east-1a</availability-zone>
</metadata>
</dataCenterInfo>
<leaseInfo>
<renewalIntervalInSecs>30</renewalIntervalInSecs>
<durationInSecs>90</durationInSecs>
<registrationTimestamp>1478146401223</registrationTimestamp>
<lastRenewalTimestamp>1478152383740</lastRenewalTimestamp>
<evictionTimestamp>0</evictionTimestamp>
<serviceUpTimestamp>1478146378932</serviceUpTimestamp>
</leaseInfo>
<metadata class="java.util.Collections$EmptyMap"/>
<homePageUrl>http://10.0.1.24:8080/</homePageUrl>
<statusPageUrl>http://10.0.1.24:8080/info</statusPageUrl>
<healthCheckUrl>http://10.0.1.24:8080/health</healthCheckUrl>
<vipAddress>JSAPI</vipAddress>
<secureVipAddress>JSAPI</secureVipAddress>
<isCoordinatingDiscoveryServer>false</isCoordinatingDiscoveryServer>
<lastUpdatedTimestamp>1478146401223</lastUpdatedTimestamp>
<lastDirtyTimestamp>1478110734306</lastDirtyTimestamp>
<actionType>ADDED</actionType>
</instance>...
The client code is like so:
#FeignClient("JSAPI")
public interface JsapiCustomerClient {
#RequestMapping(method = RequestMethod.POST, value = "/customers")
public void createCustomer(#Valid #RequestBody CustomerConfig customer);
}
I get the following error when trying to execute the method:
Connection refused executing POST http://JSAPI/customers
I expected it to try and call POST http://10.0.1.24:8080/customers
Any clue? This works on my local, fails once in the cloud.
Thanks
EDIT: Adding pom.xml
<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>
<parent>
<groupId>com.knetikcloud</groupId>
<artifactId>clustermanager</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>clustermanager-server</artifactId>
<name>clustermanager-server</name>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>com.knetikcloud</groupId>
<artifactId>clustermanager-core</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.45</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-acm</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- Packages the application to run in Elastic Beanstalk -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptor>assembly/beanstalk.xml</descriptor>
<finalName>${project.name}</finalName>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<description>A Eureka server paired with JSAPI apps specific status endpoints. The server is used to manage instance and customer status within a JSAPI cluster.</description>
</project>

Could you post your eureka-client settings?
I believe you would need to set #FeignClient's name (JSAPI in this case) to a mapping in application.yml (or .properties) and not to the service name.
I recently blogged about Service registration and discovery using Spring Cloud, Eureka, Ribbon, Feign, ... but here is an extract of the accompanying source code:
#FeignClient(name = ActorsClient.ACTORS_SERVIDE_ID)
public interface ActorsClient {
String ACTORS_SERVIDE_ID = "the-demo-registration-api-1";
String ACTORS_ENDPOINT = "/actors";
String ACTOR_BY_ID_ENDPOINT = "/actors/{id}";
...
Demo Service 2’s application.yml
...
eureka:
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://localhost:8000/eureka/
instance:
hostname: ${hostName}
statusPageUrlPath: ${management.context-path}/info
healthCheckUrlPath: ${management.context-path}/health
preferIpAddress: true
metadataMap:
instanceId: ${spring.application.name}:${server.port}
...
the-demo-registration-api-1:
ribbon:
# Eureka vipAddress of the target service
DeploymentContextBasedVipAddresses: demo-registration-api-1
#listOfServers: localhost:${SERVER.PORT}
NIWSServerListClassName: com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList
# Interval to refresh the server list from the source (ms)
ServerListRefreshInterval: 30000
...
You could see the-demo-registration-api-1 is a key in yml file mapped to a registered service with name: demo-registration-api-1

You can specify eureka.instance.preferIpAddress in your Eureka configuration then the ip instead of the hostname will be used.
If you want to use hostnames you can specify eureka.instance.hostname: ${vcap.application.uris[0]} for example from environment.
More info:
http://cloud.spring.io/spring-cloud-static/Brixton.SR6/#_eureka_metadata_for_instances_and_clients

Related

Can't import Spring Cloud dependencies for enabling Eureka client

I work on app in which I try to register Eureka client on server but stuck on the first step where I need dependency which make enable #EnableEurekaClient annotation.
I followed cloud.spring.io instructions which did not work:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
II) I then found some latest stack & tried (as follows) which did not work as well:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
I wonder, as all folder suddenly disappear in case I put above dependency in the pom.xml (I use Intellij)
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.5.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.eurekaproject.learn</groupId>
<artifactId>microservice-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>microservice-app</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
application.yml
spring:
application:
name: microservice-app
datasource:
url: jdbc:mysql://localhost:3306/microservice-app
username: root
password: 12345
jpa:
hibernate:
ddl-auto: none
server:
port: 8092
eureka:
client:
service-url:
defaultZone: http://localhost:8081/eureka
info:
app:
name: ${spring.application.name}
You need to add the Spring Cloud BOM to your pom.xml as follows:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>2020.0.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Once this is added, all Spring Cloud dependencies including spring-cloud-starter-netflix-eureka-client will resolve, and you should be able to use annotations such as #EnableDiscoveryClient for activating the Eureka discovery client.

Spring Cloud Config Server OAuth2 authorization

I have a config server and spring boot microservices running with config server requiring basic authentication user/pw. I have a Keycloak server I want to use for authentication and authorization of the microservice to the config server.
I have added the keycloak spring boot adapter to the config server so now the config server requires an OAuth2 token and have verified with Postman that it works as expected.
This is my microservice pom
<?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.3.7.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo-3</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo-3</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<spring-cloud.version>Hoxton.SR9</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</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>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
this is my bootstrap.yml
spring:
application:
name: appAuthzRestSpringBoot
cloud:
config:
uri: ${SOA_CONFIG_URI}
fail-fast: true
security:
oauth2:
client:
registration:
keycloak:
authorization-grant-type: client_credentials
client-id: app-authz-rest-springboot
client-secret: secret
provider:
keycloak:
token-uri: http://localhost:8080/auth/realms/spring-boot-quickstart/protocol/openid-connect/token
The bootstrap call to the config server does not have an OAuth2 bearer token.
What am I missing?

Hazelcast member discovery with PCF Registry Service and hazelcast-eureka-plugin

Running several instances of application with embedded hazelcast on PCF. My goal is to chain hazelcast members into cluster. For purpose of member discovery I am using hazelcast-eureka plugin. I am able to achieve member discovery using simple Eureka Server app, passing eureka URL to hazelcast-eureka plugin, using this example.
Now I want to use PCF Registry Service instead of Eureka Server app. For that purpose I am using EurekaOneDiscoveryStrategyFactory with EurekaClient autowired which is configured with PCF Registry Service properies.
Issue is - my hazelcast members do net get registered by PCF Registry Service, hence can not discover each other. Though I can see my application instances get registered by PCF Registry Service.
Instance config:
#Autowired
private EurekaClient eurekaClient;
#Bean
public HazelcastInstance hazelcastInstance() {
return Hazelcast.newHazelcastInstance(cloudConfig());
}
#Bean
public Config cloudConfig(){
Config config = new Config();
config.getGroupConfig().setName( "hazelcast-test" );
config.setProperty("hazelcast.discovery.enabled", Boolean.TRUE.toString());
JoinConfig join = config.getNetworkConfig().getJoin();
join.getMulticastConfig().setEnabled(false);
EurekaOneDiscoveryStrategyFactory.setEurekaClient(eurekaClient);
final EurekaOneDiscoveryStrategyFactory eurekaOneDiscoveryStrategyFactory = new EurekaOneDiscoveryStrategyFactory();
DiscoveryStrategyConfig discoveryStrategyConfig =new DiscoveryStrategyConfig(eurekaOneDiscoveryStrategyFactory);
discoveryStrategyConfig.addProperty("self-registration", true);
discoveryStrategyConfig.addProperty("namespace", "hazelcast-test");
discoveryStrategyConfig.addProperty("use-classpath-eureka-client-props", false);
discoveryStrategyConfig.addProperty("shouldUseDns", false);
discoveryStrategyConfig.addProperty("datacenter", "cloud");
discoveryStrategyConfig.addProperty("name", "hazelcast-test");
discoveryStrategyConfig.addProperty("use-metadata-for-host-and-port", false);
discoveryStrategyConfig.addProperty("skip-eureka-registration-verification", false);
DiscoveryConfig discoveryConfig = new DiscoveryConfig();
discoveryConfig.addDiscoveryStrategyConfig( discoveryStrategyConfig );
join.setDiscoveryConfig( discoveryConfig );
return config;
}
pom.xml:
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.19.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>eureka-client-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>eureka-client-demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud-services.version>1.6.6.RELEASE</spring-cloud-services.version>
<spring-cloud.version>Edgware.SR5</spring-cloud.version>
</properties>
<dependencies>
<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>io.pivotal.spring.cloud</groupId>
<artifactId>spring-cloud-services-starter-service-registry</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-eureka-one</artifactId>
<version>1.0.2</version>
</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>io.pivotal.spring.cloud</groupId>
<artifactId>spring-cloud-services-dependencies</artifactId>
<version>${spring-cloud-services.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>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>

Log4j warning while using axis2-wsdl2code-maven-plugin to generate SOAP client

I am using axis2-wsdl2code-maven-plugin to generate my SOAP service client. The plugin itself works correctly and it generates a correct SOAP client, but I get following warning in console with every build:
log4j:WARN No appenders could be found for logger (org.apache.axiom.locator.DefaultOMMetaFactoryLocator).
log4j:WARN Please initialize the log4j system properly.
I know I need to configure Log4j properties, but I haven't found any functional way to do this in context of axis2-wsdl2code-maven-plugin...
This is my pom.xml file:
<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>powerauth-java-client-axis</artifactId>
<version>0.13.0</version>
<name>powerauth-java-client-axis</name>
<description>PowerAuth 2.0 Service Client - Axis</description>
<parent>
<groupId>io.getlime.security</groupId>
<artifactId>powerauth-parent</artifactId>
<version>0.13.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2</artifactId>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-adb</artifactId>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
<version>1.2.20</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-impl</artifactId>
<version>1.2.20</version>
</dependency>
<dependency>
<groupId>org.apache.ws.security</groupId>
<artifactId>wss4j</artifactId>
<version>1.6.19</version>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<!-- tag::wsdl[] -->
<plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-wsdl2code-maven-plugin</artifactId>
<version>1.6.4</version>
<executions>
<execution>
<goals>
<goal>wsdl2code</goal>
</goals>
<configuration>
<packageName>io.getlime.powerauth.soap</packageName>
<wsdlFile>${basedir}/src/main/resources/soap/wsdl/service.wsdl</wsdlFile>
</configuration>
</execution>
</executions>
</plugin>
<!-- end::wsdl[] -->
</plugins>
</build>
</project>
This is actually a bug. The fix for AXIS2-5364 added a dependency on log4j to axis2-wsdl2code-maven-plugin. The problem is that some of the code executed by the plugin uses Commons Logging and therefore started to use log4j. That generates the warning you have seen because in a Maven environment, log4j isn't configured.
What the plugin should do is to redirect logs to SLF4J, because that API is supported by recent Maven versions. The -X option (which enables debug logging on the Maven command line) then works for these logs as well.
This problem will be addressed in AXIS2-5827.

Jersey + JPA deployment on Glassfish not working without restart

For a webapp project, I am using Eclipse + Jax-RS Jersey 2.5 + JPA 2.0, and I am facing some weird problems after deploying the application on Glassfish server from Eclipse.
In fact, everything works fine if I hit "Run on server", let the deployment end and then restart the Glassfish server ; btw, it's not very effective when developing, 'cause it leads to a lot a wasted time...
If I just hit "Run on server", then none of my EJB's are being injected, resulting in NullPointerException that prevent me from doing anything.
I used Maven for dependencies management, could it come from it ? Should I use another way than "Run on server" to redeploy my application after code change ?
Thanks
EDIT : Here is the architecture of the project :
src/
main/
java/
/* Application packages */
resources/
META-INF/
persistence.xml
webapp/
WEB(INF/
beans.xml
/* App templates */
pom.xml
EDIT 2 :
Even with this script it does not work :
/opt/apache-maven-3.1.1/bin/mvn clean package
/opt/glassfish4/glassfish/bin/asadmin --host localhost --port 4848 --user admin --passwordfile /opt/glassfish4/glassfish/domains/domain1/config/admin-keyfile --interactive=false --echo=true --terse=false undeploy --keepreposdir=true --isredeploy=false --cascade=false --_ignorecascade=false --_classicstyle=false configurator
/opt/glassfish4/glassfish/bin/asadmin --host localhost --port 4848 --user admin --passwordfile /opt/glassfish4/glassfish/domains/domain1/config/admin-keyfile --interactive=false --echo=true --terse=false deploy --name configurator --force=false --precompilejsp=false --verify=false --generatermistubs=false --availabilityenabled=false --asyncreplication=true --keepreposdir=true --keepfailedstubs=false --isredeploy=false --logreportederrors=true --_classicstyle=false --upload=false /home/jeremy/workspace-configurator-v2/trunk/configurator/target/configurator.war
EJB are injected with EJB annotation, and specifying the LOOKUP name :
#EJB( name=CustomApplicationService.LOOKUP_NAME )
private CustomApplicationService customApplicationService;
Class :
#Stateless
public class CustomApplicationService {
public final static String LOOKUP_NAME = "java:global/configurator/CustomApplicationService";
#PersistenceContext( name=UtilConsts.DATABASE_POOL )
private EntityManager em;
/**** */
}
Finally, my pom.xml :
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.virtualsensitive</groupId>
<artifactId>configurator</artifactId>
<packaging>war</packaging>
<version>2</version>
<name>configurator</name>
<dependencies>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.5.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.5.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.5.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.ejb</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.servlet</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom2</artifactId>
<version>2.0.5</version>
</dependency>
</dependencies>
<build>
<finalName>configurator</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<jersey.version>2.5.1</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>