Tomee+Microprofile UnsatisfiedResolutionException - ejb

everybody!
Could you give me advice about such an issue.
I have a simple test project in order to test using Microprofile config.
Field of my test class I test:
#Inject
#ConfigProperty(name = "injected.value")
private String injectedValue;
So this is the dependencies section of my pom:
<dependencies>
<!-- https://mvnrepository.com/artifact/org.eclipse.microprofile/microprofile -->
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>3.3</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
</dependencies>
I build the war and then:
1. when i deploy war into the tomee 8.0.1-microprofile (tomee-maven-plugin with tomeeClassifier set up to microprofile) -> then all works OK.
2. BUT when i deploy war into the tomee 8.0.1-plus (tomee-maven-plugin with tomeeClassifier set up to plus) -> then i got exception:
org.apache.webbeans.exception.WebBeansDeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Api type [java.lang.String] is not found with the qualifiers
Qualifiers: [#org.eclipse.microprofile.config.inject.ConfigProperty(name=injected.value, defaultValue=org.eclipse.microprofile.config.configproperty.unconfigureddvalue)]
for injection into Field Injection Point, field name : injectedValue, Bean Owner : ...
More over in case 1 (deploy to tomee 8.0.1-microprofile) when i change pom dependencies to:
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.config</groupId>
<artifactId>microprofile-config-api</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
i got the error:
org.apache.webbeans.exception.WebBeansDeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Api type [java.lang.String] is not found with the qualifiers
Qualifiers: [#org.eclipse.microprofile.config.inject.ConfigProperty(name=injected.value, defaultValue=org.eclipse.microprofile.config.configproperty.unconfigureddvalue)]...
Please could anybody help me with this issue?
I need to use Microptofile in the prod and for now, I can't do it.

for the plus and plume version to work, you must include the following property in system.properties:
tomee.mp.scan = all
reference:
http://tomee-openejb.979440.n4.nabble.com/MicroProfile-Integration-in-Plus-and-Plume-td4686818i60.html
another way is using the tomee plugin and adding this property in pom.xml :
<systemVariables>
<tomee.mp.scan>all</tomee.mp.scan>
</systemVariables>

Related

Embedded Kafka test cases are error after adding jsonschema2pojo-core

I have an application that created with Spring boot and Spring kafka libraries. Now I added jsonschema2pojo-core library to my pom file. After adding this jar file my test cases are failing with below error
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'embeddedKafka': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: scala/runtime/java8/JFunction0$mcZ$sp
Caused by: java.lang.NoClassDefFoundError: scala/runtime/java8/JFunction0$mcZ$sp
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1.RELEASE</version>
<relativePath />
</parent>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jsonschema2pojo</groupId>
<artifactId>jsonschema2pojo-core</artifactId>
<version>1.0.2</version>
</dependency>
It's probably similar to this https://docs.spring.io/spring-kafka/docs/2.5.11.RELEASE/reference/html/#jacksonscala-incompatibility
with the library pulling in an incompatible scala library.
Yes, adding
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.12.11</version>
</dependency>
fixed it for me; but I can't guarantee that jsonschema2pojo will work with that version.
The scala folks are notorious for breaking API changes in patch releases.

Spring MVC with boot and NEO4j

I am building an application where Rest endpoints uses, boot bindings to send Neo4j Entitites to Neo4j Repo, and thats the pattern we repeated few times across jpa backed repositories. In current configuration;
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
</dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
JPA repositories and neo4j repositories works ok, until i add;
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
Erros i am facing are;
APPLICATION FAILED TO START
Description:
Constructor in org.springframework.data.neo4j.repository.config.Neo4jOgmEntityInstantiatorConfigurationBean required a single bean, but 2 were found:
- mvcConversionService: defined by method 'mvcConversionService' in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]
- integrationConversionService: defined in null
:: Spring Boot :: (v2.1.0.M2)
:: Java 8
Updating project dependencies to
<spring.boot.version>2.1.0.RELEASE</spring.boot.version>
<spring.cloud.version>2.1.0.RC3</spring.cloud.version>
has fixed the issue as per #meistermeier suggestion.

class file for javax.servlet.ServletException not found [duplicate]

I'm trying to include Spring Security to my web project, i'm following this tutorial http://docs.spring.io/spring-security/site/docs/current/guides/html5//helloworld.html
I've done everything in the tutorial with the given maven project and works fine. But when i'm trying to include it to my project a compilation error appear. Specifically when i extends from AbstractSecurityWebApplicationInitializer appear the given error
Multiple markers at this line
The type javax.servlet.ServletContext cannot be resolved. It is indirectly referenced from required .class files
The type javax.servlet.ServletException cannot be resolved. It is indirectly referenced from required .class files
The 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>
<groupId>spring.primefaces</groupId>
<artifactId>primefaces.testwebapp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>SpringPrimefacesWebApp</name>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- JSF 2.2 core and implementation -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.11</version>
</dependency>
<!-- Prime Faces -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.2</version>
</dependency>
<!-- Spring security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>4.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>4.0.1.RELEASE</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.1.6.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Thanks for the help!
Using mvn clean install -U
Just add the javax.servlet API to the compile time dependencies. You don't need to include it in the build, it's already provided by the target servlet container.
Your current pom suggests that you're deploying to a barebones servlet container (Tomcat, Jetty, etc) instead of a full fledged Java EE application server (WildFly, TomEE, GlassFish, Liberty, etc), otherwise you'd have run into classloading-related trouble by providing JSF along with the webapp instead of using the container-provided one.
In that case, adding the below dependency should do for a Servlet 3.1 container like Tomcat 8:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
Or if you're actually targeting an older Servlet 3.0 container like Tomcat 7, change the <version> to 3.0.1 (note: there's no 3.0 due to a mistake on their side).
If you happen to actually deploy to a Java EE 7 application server like WildFly 8, use the below dependency instead. It covers the entire Java EE API, including javax.servlet (and javax.faces, so you'd then remove those individual JSF API/impl dependencies):
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
Also here, if you're targeting an older Java EE 6 application server like JBoss AS 7, change the <version> to 6.0.
See also:
How to properly configure Jakarta EE libraries in Maven pom.xml for Tomcat?
This worked for me: if above supplied solution doesnt work
Project > Properties > Java Build Path > Libraries > Add library from library tab > Choose server runtime > Next > choose Apache Tomcat v 7.0> Finish > Ok
another way if you working on eclipse ide please open the project folder select Properties and click maven shows the view 'Active Maven Profiles(comma separated)'please input "dev"..after refresh problem solved
try setting the updated parent, like this:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.6.RELEASE</version>
<relativePath></relativePath>
</parent>
this solved for me.
What helped for me was deleting the repository in directory .m2
and after deleting run maven: package

Magnolia could not be started java.lang.NoClassDefFoundError

I am running an magnolia Application using magnolia-blossom.
I have added this dependency jar below :
<dependency>
<groupId>info.magnolia</groupId>
<artifactId>magnolia-module-standard-templating-kit</artifactId>
<version>2.7</version>
<type>jar</type>
</dependency>
I am getting the error :
Oops, Magnolia could not be started java.lang.NoClassDefFoundError:info/magnolia/dam/provider/AssetProviderNotFoundException
for which Tomcat server is unable to start.
Can anyone suggest me that how can i resolve this Error.
You're missing Magnolia DAM, use this dependency snippet:
<dependency>
<groupId>info.magnolia.dam</groupId>
<artifactId>magnolia-dam</artifactId>
<version>1.2</version>
</dependency>
I found the version used by STK 2.7 by looking at its POM here https://nexus.magnolia-cms.com/content/repositories/magnolia.public.releases/info/magnolia/standard-templating-kit-parent/2.7/standard-templating-kit-parent-2.7.pom

Spring MVC Initialization Causes Log4J Exception

In my webapp, I am using Spring MVC as my controller layer. However, using the tags provided by the MVC context:
<mvn:annotation-driven />
<mvc:resources />
causes a log4j exception:
<Mar 26, 2012 1:49:50 PM EDT> <Warning> <HTTP> <BEA-101162> <User defined listener
org.springframework.web.context.ContextLoaderListener failed:
java.lang.NoClassDefFoundError: org/apache/log4j/spi/ThrowableInformation.
java.lang.NoClassDefFoundError: org/apache/log4j/spi/ThrowableInformation
at org.apache.log4j.spi.LoggingEvent.<init>(LoggingEvent.java:165)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.log(Category.java:856)
at org.slf4j.impl.Log4jLoggerAdapter.log(Log4jLoggerAdapter.java:597)
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.error(SLF4JLocationAwareLog.java:225)
Truncated. see log file for complete stacktrace
(LoggingEvent.java:165)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.log(Category.java:856)
at org.slf4j.impl.Log4jLoggerAdapter.log(Log4jLoggerAdapter.java:597)
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.error(SLF4JLocationAwareLog.java:225)
Truncated. see log file for complete stacktrace
Basic stuff:
log4j-1.2.16.jar is defined in the maven POM and is in the application library.
Since it's a weblogic server, I have the following in the weblogic.xml file to try to prevent conflicts:
<wls:prefer-application-packages>
<wls:package-name>org.apache.log4j.*</wls:package-name>
</wls:prefer-application-packages>
(Update) I manually excluded commons-logging in the maven POM for the application.
(Update) I already had the slf4j jars in my Maven POM (removing the jcl-over-slf4j has no effect):
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.5.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.8</version>
<scope>runtime</scope>
</dependency>
Basically, I need to exclude the basic css and js directories as web as a single directory under WEB-INF/ that contains some jspf files that I do NOT wish to write a controller for (dropdown menus definitions used by jquery superfish).
Any help?
Add slf4j-log4 connector to the POM:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j-version}</version>
<scope>runtime</scope>
</dependency>

Resources