Consider defining a bean of type 'javax.servlet.ServletContext' in your configuration - api

I'm trying to connect an API witha postgres database. And for that, I'm using Spring Boot.
When testing the api, i keep getting the error
Consider defining a bean of type 'javax.servlet.ServletContext' in your configuration.
I understand that i need a #Bean for ServletController, but I donw know exactly what this bean should do. When i made a generic one, but then the console told me to revisit it. I have no idea what to do here, and stackoverflow hasn't helped either.
Here's my Application file:
#SpringBootApplication
#SwaggerDefinition
#EnableSwagger2
#EnableConfigurationProperties(XXXXConfiguracaoApplication.class)
public class FonumS3ApiApplication {
public static void main(String[] args) {
SpringApplication.run(XXXXApiApplication.class, args);
}
#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 ApiInfo(
"API XXXX",
"API XXXX para integrações entre sistemas.",
"API V1",
"Terms of service",
new Contact("XXXX", "www.XXXX.com", "XXXX.XXXX#XXXX.com"),
"License of XXX", "API license URL", Collections.emptyList());
}
}
}
(the annotations are there, but for some reason, the stackoverflow did not accept them) and my pom is
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.13.Final</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<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>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</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>
</plugin>
</plugins>
</build>

As you have excluded Tomcat from web and added Tomcat provided scope so I assume you are trying to create war and deploy on external Tomcat, so you have to extend SpringBootServletInitializer and override configure method.
#SpringBootApplication
#SwaggerDefinition
#EnableSwagger2
#EnableConfigurationProperties(XXXXConfiguracaoApplication.class)
public class FonumS3ApiApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(XXXXApiApplication.class, args);
}
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
#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 ApiInfo(
"API XXXX",
"API XXXX para integrações entre sistemas.",
"API V1",
"Terms of service",
new Contact("XXXX", "www.XXXX.com", "XXXX.XXXX#XXXX.com"),
"License of XXX", "API license URL", Collections.emptyList());
}
}
}
Or if you are running with embedded Tomcat then don't change anything in main class and remove exclusion from web and remove Tomcat jar:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
and remove Tomcat jar below:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>

Related

Arquillian Weld EE NullPointerException (invoking method) EAR

I am trying to test with Arquillian + WELD EE in an (ShrinkWrap)EnterpriseArchive.
But I am getting a NullPointerException when I start invoking the method.
My pom.xml
<profile>
<id>arquillian-weld-ee-embedded</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-7.0</artifactId>
<version>1.0.3.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-weld-ee-embedded-1.1</artifactId>
<version>1.0.0.CR9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-spi</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.4</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core-bom</artifactId>
<version>2.3.3.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
My testclass
#RunWith(Arquillian.class)
public class NewSessionBeanTest {
public NewSessionBeanTest() {
}
#Deployment
public static Archive<?> createDeployment() {
final JavaArchive ejbJar = ShrinkWrap
.create(JavaArchive.class, "ejb-jar.jar")
.addClass(NewSessionBean.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
final WebArchive testWar = ShrinkWrap.create(WebArchive.class, "test.war")
.addClass(NewSessionBeanTest.class)
.addAsManifestResource("META-INF/test-web-beans.xml", "beans.xml")
;
final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class)
.setApplicationXML("META-INF/test-application.xml")
.addAsModule(ejbJar)
.addAsModule(testWar);
return ear;
}
#Inject
NewSessionBean sessionBean;
#Test
public void testBusinessMethod() throws Exception {
assertNotNull(sessionBean);
// With Weld-EE it gives NullPointerException here
sessionBean.businessMethod();
}
}
It fails at sessionBean.businessMethod();, there is an proxy inserted so assertNotNull passes. When I use arquillian-weld-se-embedded-1.1 (SE), then I get an error could not inject members.
This works perfectly when I test this with a wildfly-embedded container.
UPDATE: My NewSessionBean class is #Stateless + #LocalBean (also tested without #LocalBean. When I test this with #ApplicationScoped it works, but it's not what I want.
Also if I test it #Named or with #LocalBean it works. But these are non-EJB specifications.
Found test on: http://www.programcreek.com/java-api-examples/index.php?source_dir=arquillian-container-weld-master/weld-ee-embedded-1.1/src/test/java/org/jboss/arquillian/container/weld/ee/embedded_1_1/WeldEmbeddedIntegrationEARTestCase.java
UPDATE 2: I have found a workaround for this. Changing to WELD SE and adding ear.merge(ejbJar) to the Test works for the weld profile and Wildfly Managed profile.
Still I don't consider this as a solution, because I think it should be supported by WELD-EE.

Injecting #Stateless EJB in Arquillian tests

A weird problem when running Arquillian test. If I try to use an EJB annotated with #Stateless, I get this error:
org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [MyEjbRemote] with qualifiers [#Default] at injection point [[field] #Inject private com.org.app.ejb.InjectionTest.ejb]
I have the following test class + deployment for the Arquillian:
#RunWith(Arquillian.class)
public class InjectionTest extends TestCase {
#Inject
private MyEjbRemote ejb;
#Deployment
public static JavaArchive createDeployment() {
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "test.jar").addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"));
jar.addClass(MyEjbRemote.class);
jar.addClass(MyEjb.class);
}
#Test
public void checkInjection() {
TestCase.assertNotNull(ejb);
}
}
The EJB looks like this:
#Stateless
#Default
public class MyEjb implements MyEjbRemote {
public MyEjb() {
}
}
The remote interface just has #Remote annotation.
If I change the #Stateless to #Named, it works. But I wan to use the #Stateless.
pom.xml:
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.1.9.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
In order to test injection of Stateless EJBs that are not Singletons you need to deploy to an embedded container.
I had the same issue and this blog post pointed me in the right direction.
https://blog.payara.fish/how-to-test-applications-with-payara-server-micro-with-arquillian
My working pom.xml
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.6.0.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-glassfish-embedded-3.1</artifactId>
<version>1.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>fish.payara.extras</groupId>
<artifactId>payara-embedded-all</artifactId>
<version>5.2020.4</version>
<scope>test</scope>
</dependency>
</dependencies>

Jersey MessageBodyWriter not found for media type=text/html

I am going to display html using "Thymeleaf", but the following errors are given.
The server using is tomcat8.
My code looks like.
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.abc.def</groupId>
<artifactId>jersey_de</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>jersey_de</name>
<build>
<finalName>jersey_de</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- my setting -->
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.21</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.21</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-apache-connector</artifactId>
<version>2.21</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>2.21</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-mvc</artifactId>
<version>2.21</version>
</dependency>
<!--
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-mvc-jsp</artifactId>
<version>2.21</version>
</dependency>
-->
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>2.1.4.RELEASE</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
Jersey Web Application
org.glassfish.jersey.servlet.ServletContainer
jersey.config.server.provider.packages
com.abc.def.jersey_de
com.abc.def.jersey_de.ThymeleafViewProcessor
/WEB-INF/view/
1
Jersey Web Application
/webapi/*
javacode
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.glassfish.jersey.server.mvc.Viewable;
import com.abc.def.jersey_de.domain.TestPOJO;
#Path("top")
#Produces(MediaType.TEXT_PLAIN)
public class DemoCtrl {
#GET
#Produces(MediaType.TEXT_HTML)
public Viewable getIt() {
Viewable vb = new Viewable("test",new TestPOJO());
System.out.println("top end");
return vb;
}
}
ThymeleafViewProcessor
#Provider
public class ThymeleafViewProcessor implements TemplateProcessor<String> {
#Context
private HttpServletRequest request;
#Context
private HttpServletResponse response;
#Context
private ServletContext servletContext;
private final TemplateEngine templateEngine;
/**
* コンストラクタ
*/
public ThymeleafViewProcessor() {
TemplateResolver resolver = new ServletContextTemplateResolver();
resolver.setPrefix("/WEB-INF/view/");
resolver.setSuffix(".html");
resolver.setTemplateMode("HTML5");
resolver.setCacheTTLMs(3600000L);
templateEngine = new TemplateEngine();
templateEngine.setTemplateResolver(resolver);
System.out.println("ThymeleafViewProcessor end");
}
/**
* 参照させるファイル名を解決する。
*/
#Override
public String resolve(String name, MediaType mediaType) {
return name;
}
#Override
public void writeTo(String templateReference, Viewable viewable, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream out) throws IOException {
WebContext context = new WebContext(request, response, servletContext);
//HTML内でモデルオブジェクトを使用できるようにしている。
//ここはモデル名をそのまま使用できるようにした方が良い。
context.setVariable("item", viewable.getModel());
Writer writer = new OutputStreamWriter(out);
templateEngine.process(templateReference, context, writer);
writer.flush();
}
}
ApplicationSetting
#ApplicationPath("/service")
public class ApplicationSetting extends ResourceConfig {
public ApplicationSetting() {
packages(this.getClass().getPackage().getName());
register(ThymeleafViewProcessor.class);
register(MvcFeature.class);
register(LoggingFilter.class);
System.out.println("ApplicationSetting ");
}
}
It was settled.
The points that I revised are as follows.
web.xml
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.abc.def.jersey_de.MyApplication</param-value>
</init-param>
pom
<dependencies>
<dependency>
<groupId>javax</groupId><!-- 動きが変わらないので不要? -->
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
<version>8.0.15</version>
</dependency>
<dependency><!-- 不要? -->
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-mvc</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>2.1.4.RELEASE</version>
</dependency>
</dependencies>
<properties>
<jersey.version>2.21</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

JAX-WS Cannot initialize endpoint... arg0 is not a valid property on class

I have a very strange problem.
Previously, for bigger projects we used EAR packaging (one EJB + JPA + JAX-WS project with one JSF + JAX-RS project).
No we have a smaller project, where we only needed some (5) services and no UI, so we decided to go with WAR packaging in one project (EJB + JPA + JAX-WS + JAX-RS).
Maven dependencies:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.moxy</artifactId>
<version>${moxy.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>jsonp-jaxrs</artifactId>
<version>1.0</version>
</dependency>
So, most of what we do is we create a simple interface:
#WebService
#SOAPBinding( style = Style.DOCUMENT )
public interface ILog extends Serializable{
#WebMethod public long createEventLog(EventLog log);
}
We put an EJB over it, for implementation:
#Stateless
#LocalBean
#WebService (endpointInterface = "....interfaces.ILog")
public class LogService implements ILog {
public long createEventLog(EventLog log) {
em.persist(log);
em.flush();
return log.getId();
}
}
Then we have a JAX-RS class over it, which calls the upper EJB method.
#Path("/log")...
First we create the EJB + WS combos, and create simple test client codes, to make sure they work:
private URL url;
private QName qname;
private Service wsService;
private ILog logService;
#Before
public void init() throws MalformedURLException{
url = new URL("http://localhost:8080/LogServiceService/LogService?wsdl");
qname = new QName("http://.../","LogServiceService");
wsService = Service.create(url, qname);
logService = wsService.getPort(ILog.class);
}
Everything is rendered / generated for us by glassfish 4.1, so we don't create any more configuration class, or anything (the above code just works...).
So this works at this step. After these, we introduced the JAX-RS services (with JSON formatting), that meant the REST services are working, but now I think the above API-s doesn't like each other very much, and now the JAX-WS code isn't working, and giving the following error for all the JAX-WS services:
2015-09-18T14:15:36.712+0200|Severe: Cannot initialize endpoint : error is :
javax.xml.ws.WebServiceException: class ....interfaces.jaxws.CreateEventLog do not have a property of the name arg0
at com.sun.xml.ws.server.sei.EndpointArgumentsBuilder$DocLit.<init>(EndpointArgumentsBuilder.java:610)
at com.sun.xml.ws.server.sei.TieHandler.createArgumentsBuilder(TieHandler.java:143)
at com.sun.xml.ws.server.sei.TieHandler.<init>(TieHandler.java:115)
at com.sun.xml.ws.db.DatabindingImpl.<init>(DatabindingImpl.java:116)
at com.sun.xml.ws.db.DatabindingProviderImpl.create(DatabindingProviderImpl.java:74)
at com.sun.xml.ws.db.DatabindingProviderImpl.create(DatabindingProviderImpl.java:58)
at com.sun.xml.ws.db.DatabindingFactoryImpl.createRuntime(DatabindingFactoryImpl.java:120)
at com.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:521)
at com.sun.xml.ws.server.EndpointFactory.create(EndpointFactory.java:300)
at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:164)
at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:577)
at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:560)
at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:639)
at org.glassfish.webservices.EjbRuntimeEndpointInfo.prepareInvocation(EjbRuntimeEndpointInfo.java:275)
at org.glassfish.webservices.EjbRuntimeEndpointInfo.initRuntimeInfo(EjbRuntimeEndpointInfo.java:352)
at org.glassfish.webservices.WebServiceEjbEndpointRegistry.registerEndpoint(WebServiceEjbEndpointRegistry.java:127)
at com.sun.ejb.containers.BaseContainer.initializeHome(BaseContainer.java:1247)
at com.sun.ejb.containers.StatelessSessionContainer.initializeHome(StatelessSessionContainer.java:190)
at com.sun.ejb.containers.StatelessContainerFactory.createContainer(StatelessContainerFactory.java:63)
at org.glassfish.ejb.startup.EjbApplication.loadContainers(EjbApplication.java:221)
at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:291)
at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:99)
at org.glassfish.internal.data.ModuleInfo.load(ModuleInfo.java:206)
at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:313)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:496)
at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:406)
at com.sun.enterprise.v3.server.ApplicationLoaderService.postConstruct(ApplicationLoaderService.java:243)
at org.jvnet.hk2.internal.ClazzCreator.postConstructMe(ClazzCreator.java:329)
at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:377)
at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:461)
at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.findOrCreate(AsyncRunLevelContext.java:227)
at org.glassfish.hk2.runlevel.RunLevelContext.findOrCreate(RunLevelContext.java:84)
at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2258)
at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:105)
at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:87)
at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.oneJob(CurrentTaskFuture.java:1162)
at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.run(CurrentTaskFuture.java:1147)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: javax.xml.bind.JAXBException: arg0 is not a valid property on class ....interfaces.jaxws.CreateEventLog
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getElementPropertyAccessor(JAXBContextImpl.java:969)
at com.sun.xml.ws.db.glassfish.JAXBRIContextWrapper.getElementPropertyAccessor(JAXBRIContextWrapper.java:120)
at com.sun.xml.ws.server.sei.EndpointArgumentsBuilder$DocLit.<init>(EndpointArgumentsBuilder.java:598)
... 39 more
Now I don't know what could I do to make the two types of Services work together (I wouldn't like to go back to EAR packaging with two projects, this service interface is way too small for that).
Can anyone help me?
Thank You!

"IllegalStateException: No generator was provided" when using Jersey-Client on Glassfish 3 in Java EE 7 application

For a project I'm using Jersey-Client to interface with another project's REST interface.
I am using the following code:
public boolean canLogin(String server, String username, String password) {
Client client = null;
try {
ClientConfig config = new ClientConfig();
// Install the all-trusting trust manager
client = ClientBuilder.newBuilder().build();
HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(username, password);
client.register(feature);
Response resp = client.target(server + "/management").request().get();
return resp.getStatus() == 400;
} catch (Exception ex) {
return false;
} finally {
if (client != null) {
client.close();
}
}
}
When using it, I get the following exception in ex
java.lang.IllegalStateException: No generator was provided and there is no default generator registered
The code is being run on GlassFish Server Open Source Edition 3.1.2.2 (build 5)
All of the dependencies:
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.bundles.repackaged</groupId>
<artifactId>jersey-guava</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-locator</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-utils</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-core</artifactId>
<version>2.0.5</version>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>be.dkv</groupId>
<artifactId>PasswordManagement-api</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
</dependency>
</dependencies>