I try to run integration test with Arquillian and Wildfly.
My dependencies in Maven look as follows:
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.1.2.Final-wildfly-1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-embedded</artifactId>
<version>8.0.0.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-embedded</artifactId>
<version>8.0.0.Final</version>
</dependency>
Is it necessary to include both the wildfly-arquillian-container-embedded and wildfly-embedded?
When running the test, I get the following error:
[main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider
Cannot not load JBoss LogManager. The LogManager has likely been accessed prior to this initialization.
[main] INFO org.jboss.msc - JBoss MSC version 1.2.0.Final
Feb 18, 2014 11:34:08 AM org.jboss.as.server.ApplicationServerService start
INFO: JBAS015899: WildFly 8.0.0.Final "WildFly" starting
Feb 18, 2014 11:34:13 AM org.jboss.as.controller.AbstractOperationContext executeStep
ERROR: JBAS014612: Operation ("parallel-extension-add") failed - address: ([])
java.lang.RuntimeException: JBAS014670: Failed initializing module org.jboss.as.logging
at org.jboss.as.controller.extension.ParallelExtensionAddHandler$1.execute(ParallelExtensionAddHandler.java:99)
at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:591)
at org.jboss.as.controller.AbstractOperationContext.doCompleteStep(AbstractOperationContext.java:469)
at org.jboss.as.controller.AbstractOperationContext.completeStepInternal(AbstractOperationContext.java:273)
at org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:268)
at org.jboss.as.controller.ModelControllerImpl.boot(ModelControllerImpl.java:314)
at org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:294)
at org.jboss.as.server.ServerService.boot(ServerService.java:356)
at org.jboss.as.server.ServerService.boot(ServerService.java:331)
at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:256)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalStateException:
JBAS011592: The logging subsystem requires the log manager to be
org.jboss.logmanager.LogManager. The subsystem has not be initialized and cannot be
used.
To use JBoss Log Manager you must add the system property "java.util.logging.manager"
and set it to "org.jboss.logmanager.LogManager"
I added the following to the plugins section in my pom.xml:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<systemProperties>
<property>
<name>java.util.logging.manager</name>
<value>org.jboss.logmanager.LogManager</value>
</property>
</systemProperties>
</configuration>
</plugin>
Made the complaints go away. I'm not sure if it is a bug or not. I think it would be better if the embedded container just worked without any extra configuration.
add this it will work i had he same problem (in pom.xml) with right version :
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.3.0.Final</version>
</dependency>
Related
I only added this dependency and i am not able to start my application.
Can you explain why it is happening?
Without this dependency the spring-boot application is working. I tried to use 2.5.4 and 2.4.2 versions of spring-boot.
It is causing the following error:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
<version>1.4.7.RELEASE</version>
</dependency>
Caused by: java.io.FileNotFoundException: class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class] cannot be opened because it does not exist
I was facing same issue and I resolved it . in your pom , remove version from all spring-cloud dependency and then add below thing in your pom :
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>2021.0.1</spring-cloud.version>
</properties>
and
<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>
Note : please pick version as per your requirements. thanks.
Created an application using micronaut bom 1.2.10 version, along with software.amazon.awssdk:lambda:2.10.56 & software.amazon.awssdk:s3:2.10.56 dependencies which had functionality to retrieve data from s3 storage and used graal 19.2.1 to create a native image.
The native image is successfully created but when i try to access the endpoint it fails for below exception:
failed: org.apache.commons.logging.LogFactoryjava.lang.NoClassDefFoundError: org.apache.commons.logging.LogFactory
and series of exceptions with specifically while creating S3 client.
The exception also had failure at below point:
failed: Could not initialize class software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactoryjava.lang.NoClassDefFoundError: Could not initialize class software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory
Code for S3Client :
S3Client s3Client = S3Client.builder().region(getRegion()).build();
build-native-image.sh
${GRAALVM_HOME}/bin/native-image --no-server -cp example-function-*-all.jar
-H:IncludeResources="git.properties"
-H:IncludeResources="logback.xml"
-H:IncludeResources="application.properties" \
So this issue was resolved by adding below configuration in build.gradle:
allprojects {
configurations {
all {
exclude(group = "commons-logging")
}
}
}
and in the dependencies added:
compile group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.30'
I hope this helps.
I faced the same issue, when running tests, with the exact same NoClassDefFoundError but when using AWS sts and secretsmanager libraries. I could actually get it to work by just including the jcl-over-slf4j dependency, while the error happened when using the slf4j-api dependency. I did not need to exclude commons-logging. Snippet of dependency in maven pom.xml that worked:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.17.89</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>secretsmanager</artifactId>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>sts</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
</dependencies>
I am working in a Maven project and trying to add latest version of mysql-connector-java/5.1.38 dependencies im pom.xml. But I got ArtifactDescriptorException: Failed to read artifact descriptor for for mysql:mysql-connector-java and there is no mysql-connector jar inside maven dependecies folder. I also added older version of mysql-connector-java/5.1.10 and mysql-connector-java/5.1.36 version and it's working fine without any exceptions.
The pom.xml has the following problems with latest version of mysql-connector-java/5.1.38
ArtifactDescriptorException: Failed to read artifact descriptor for mysql:mysql-connector-java:jar:5.1.38: ArtifactResolutionException: Failure to transfer mysql:mysql-connector-java:pom:5.1.38 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact mysql:mysql-connector-java:pom:5.1.38 from/to central (http://repo.maven.apache.org/maven2): null to http://repo.maven.apache.org/maven2/mysql/mysql-connector-java/5.1.38/mysql-connector-java-5.1.38.pom
And my pom.xml looks like
<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.java.spring</groupId>
<artifactId>practice</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>practice</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.2.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.2.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.4.RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<versionRange>
[2.3.2,)
</versionRange>
<goals>
<goal>compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
I also cleaned my project one time and update it but after adding dependencies same error occurred.
So How can I solve this?
I have added the coordinates to a pom.xml in a project in my computer. It worked.
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
I write here, possible solutions.
1.If you simply copy and paste maven coordinates to you pom.xml, sometimes, in the whitespace, there are some invisible characters, that make everything broken. Try to remove this white spaces.
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
2.Remove your local maven repository, try it again. The local repository is generally, C:\Users\username\.m2\repository
3.Control your proxy settings.
I hope this helps.
Go to your maven repository directory:
C:\Users\{user}\.m2\repository
Look for mysql folder and navigate to:
C:\Users\{user}\.m2\repository\mysql\mysql-connector-java\5.1.6
In here you will find a file called mysql-connector-java-5.1.6.pom.lastUpdated. Open it and check what the problem might be.
In my case it says
Failed to authenticate with proxy
This means i have to disconnect from my proxy and connect with my wi-fi or modem and it works. I hope this helps cheers
I use Arquillian to test an EJB that has an explicit local and remote interface. But in the test Arquillian does not "inject" anything in a field that has the type of the local interface, or the remote interface.
I use the Glassfish embedded as server for test and I use junit4.
I used :
#EJB ,
#Inject ,
#EJB(lookup="java:global/costa-services-depa/GreeterImpl!es.costa.GreeterLocal") ,
#EJB(lookup="java:global/costa-services-depa/GreeterImpl!es.costa.GreeterRemote")
With (2) even for GreeterImpl, or GreeterLocal or GreeterRemote it gives me the error Could not inject members.
With (1,3,4) I get a java.lang.NullPointerException which means that the EJB is not injected.
This is a part of my code:
#RunWith(Arquillian.class)
public class greeterTest {
#Deployment
public static Archive<?> createDeployment() {
JavaArchive jar = ShrinkWrap.create(JavaArchive.class,"costa-services-depa")
.addClasses(
GreeterRemote.class,
GreeterLocal.class,
Greeter.class)
.addAsManifestResource("test-persistence.xml", "persistence.xml")
.addAsManifestResource("jbossas-ds.xml")
.addAsManifestResource("META-INF/beans.xml",
ArchivePaths.create("beans.xml"));
return jar;
}
#Inject
GreeterImpl greeter;
#Test
public void testTestServiceLocal(){
System.out.println(greeter.getMessage());
}
}
Here is the glassfish-resources.xml:
...
<resources>
<jdbc-resource pool-name="ArquillianEmbeddedH2Pool"
jndi-name="jdbc/arquillian"/>
<jdbc-connection-pool name="ArquillianEmbeddedH2Pool"
res-type="javax.sql.DataSource"
datasource-classname="org.h2.jdbcx.JdbcDataSource">
<property name="user" value="sa"/>
<property name="password" value=""/>
<property name="url" value="jdbc:h2:file:target/databases/h2/db"/>
</jdbc-connection-pool>
</resources>
Here is the test-persistence.xml:
...
<persistence-unit name="test">
<jta-data-source>jdbc/arquillian</jta-data-source>
<properties>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
<property name="eclipselink.logging.level.sql" value="FINE"/>
<property name="eclipselink.logging.parameters" value="true"/>
</properties>
</persistence-unit>
This is the arquillian.xml:
...
<container qualifier="glassfish-embedded" default="true">
<configuration>
<property name="resourcesXml">
ejbModule/src/test/resources-glassfish-embedded/glassfish-resources.xml
</property>
</configuration>
</container>
...
This is jbossas-ds.xml:
<datasources xmlns="http://www.jboss.org/ironjacamar/schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.jboss.org/ironjacamar/schema
http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">
<datasource enabled="true"
jndi-name="jdbc/arquillian"
pool-name="ArquillianEmbeddedH2Pool">
<connection-url>jdbc:h2:mem:arquillian;DB_CLOSE_DELAY=-1</connection-url>
<driver>h2</driver>
</datasource>
</datasources>
About dependencies for Glassfish embedded and Arquillian and Junit:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.0.3.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<profiles>
<profile>
<id>arquillian-glassfish-embedded</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-glassfish-embedded-3.1</artifactId>
<version>1.0.0.CR3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.main.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>3.1.2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.3.166</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<testResources>
<testResource>
<directory>ejbModule/src/test/resources</directory>
</testResource>
<testResource>
<directory>ejbModule/src/test/resources-glassfish-embedded</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<systemPropertyVariables>
<arquillian.launch>glassfish-embedded</arquillian.launch>
<java.util.logging.config.file>
${project.build.testOutputDirectory}/logging.properties
</java.util.logging.config.file>
<derby.stream.error.file>
${project.build.directory}/derby.log
</derby.stream.error.file>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
In the console I noticed:
Infos: Network listener https-listener on port 0 disabled per domain.xml
Infos: Grizzly Framework 1.9.50 started in: 32ms - bound to [0.0.0.0:8181]
Infos: GlassFish Server Open Source Edition 3.1.2.2 (java_re) startup time :
Embedded (525ms), startup services(384ms), total(909ms)
Infos: command add-resources result:
PlainTextActionReporterSUCCESSDescription: add-resources AdminCommandnull
JDBC connection pool ArquillianEmbeddedH2Pool created successfully.
JDBC resource jdbc/arquillian created successfully.
Infos: SEC1002: Security Manager is OFF.
Infos: SEC1010: Entering Security Startup Service
Infos: SEC1143: Loading policy provider
com.sun.enterprise.security.jacc.provider.SimplePolicyProvider.
Infos: SEC1115: Realm [admin-realm] of classtype
[com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
[com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
Infos: SEC1115: Realm [file] of classtype
[com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
Infos: SEC1115: Realm [certificate] of classtype
[com.sun.enterprise.security.auth.realm.certificate.CertificateRealm] successfully created.
Infos: SEC1011: Security Service(s) Started Successfully
Infos: WEB0169: Created HTTP listener [http-listener] on host/port [0.0.0.0:8181]
Infos: WEB0171: Created virtual server [server]
Infos: WEB0172: Virtual server [server] loaded default web module []
Infos: WELD-000900 SNAPSHOT
Infos: WEB0671: Loading application [**test**] at [**/test**]
Infos: test was successfully deployed in 1 822 milliseconds.
PlainTextActionReporterSUCCESSNo monitoring data to report.
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.308 sec
Infos: Shutdown procedure finished
Infos: [Thread[GlassFish Kernel Main Thread,5,main]] exiting
NB : By default that deploys as test application or not as what I made "costa-services-depa"?
To know that in the path of call of EJB I put test instead of costa-service-depa but always it gives me the same problem (NullPointerException).
I'm having the same problem trying to somehow inject a context bean in an Arquillian test against GlassFish 4.1.
This issue seems related to a GlassFish (major and open) bug:
https://java.net/jira/browse/GLASSFISH-21167
They say injections in GlassFish won't work deploying a war with certain conditions:
The application uses an empty <absoluteOrdering> tag in web.xml
The classes of the application are all packed as jar archives in the [war]\WEB-INF\lib\ directory, instead of included them unpacked in the [war]\WEB-INF\classes\ directory
What happens to me is that my #Singleton bean is created and injected but for every #EJB reference in the app, not just created once.
I checked my Arquillian deployment on GF (glassfish-4.1\glassfish\domains\domain1\applications\test) and I can see the test.jar deployed in [war]\WEB-INF\lib\. I don't have a web.xml in my app and I don't see it in my GlassFish deployment. I guess the web.xml is provided somehow automatically.
Deploying the same app with Arquillian on Wildfly works fine and my #Singleton bean is injected correctly as expected.
i am trying to use a container managed datasource (via context.xml) in tomcat. The corresponding jar file needs to go in $catalina_home/lib, otherwise tomcat can't find it. (not in webapp/WEB-INF/lib, because it is managed by the webserver, not by the application itself)
the problem is: I am using maven with the maven-tomcat-plugin, so I don't have a $catalina_home (everything is distributed in my .m2 -repository).
So the question is: how can I add the mysql driver jar to the classpath of the tomcat server (mvn tomcat:run)?
thanks a lot,
gerolf.
Did you try to add the JDBC driver as a dependency of the maven-tomcat-plugin:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
...
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.0.5</version>
</dependency>
</dependencies>
</plugin>