I used to have the following maven dependencies to use arquillian glassfish container:
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-junit</artifactId>
<scope>test</scope>
<version>1.0.0.Alpha5</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-glassfish-embedded-3.1</artifactId>
<version>1.0.0.Alpha5</version>
</dependency>
I was able to run my tests successfully until I wanted to inject specific resources, that could not be looked up through JNDI.
I improved my domain.xml to have the relevant resources I wanted. But for now, I am not sure arquillian load successfully all the domain.xml (look up failed on "jca/Neo4j/resource").
My arquillian.xml (in src/test/resources):
<?xml version="1.0" encoding="UTF-8"?>
<arquillian xmlns="http://jboss.com/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:glassfish="urn:arq:org.jboss.arquillian.container.glassfish.embedded_3">
<glassfish:container>
<glassfish:instanceRoot>src/test/resources/glassfish</glassfish:instanceRoot>
<glassfish:bindPort>9090</glassfish:bindPort>
<glassfish:autoDelete>false</glassfish:autoDelete>
</glassfish:container>
My domain.xml (in src/test/resources/glassfish/config/):
<domain log-root="${com.sun.aas.instanceRoot}/logs" applicationroot="${com.sun.aas.instanceRoot}/applications" version="10.0">
<resources>
<connector-connection-pool name="jca/Neo4j/pool" resource-adapter-name="neo4j-connector-0.1-SNAPSHOT" connection-definition-name="com.netoprise.neo4j.connection.Neo4JConnectionFactory">
<property name="dir" value="${com.sun.aas.instanceRoot}/lib/databases/neo4j"></property>
<property name="xa" value="true"></property>
</connector-connection-pool>
<connector-resource pool-name="jca/Neo4j/pool" jndi-name="jca/Neo4j/resource"></connector-resource>
</resources>
<servers>
<server name="server" config-ref="server-config">
<application-ref ref="neo4j-connector-0.1-SNAPSHOT" virtual-servers="server"></application-ref>
<resource-ref ref="jca/Neo4j/resource"></resource-ref>
</server>
</servers>
...
</domain>
Thanks,
Alex
The Alpha5 was a bit hard to handle :)
Stuff changed a bit and if you like to give the latest 1.0.0.Final-SNAPSHOT a try, you could have a more detailed look at a configuration here:
http://blog.eisele.net/2012/01/arquillian-with-netbeans-glassfish.html
Thanks,
M
Related
I have a project on Wildfly-Swarm. I need to use query cache, so I put Infinispan dependency on my POM.
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>infinispan</artifactId>
</dependency>
I setup Infinispan on my persistence.xml
<persistence-unit name="Condominio" transaction-type="JTA">
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
<properties>
<property name="hibernate.cache.use_query_cache" value="true"/>
<property name="hibernate.cache.infinispan.entity.expiration.max_idle" value="300000"/>
...
<properties>
</persistence-unit>
It's work well, the cache works. But I read the documentation of Infinispan Wildfly-Swarm fraction (https://reference.wildfly-swarm.io/fractions/infinispan.html) and I was in doubt if should setup it on project-defaults.yml using those configurations.
I don't know which configurations of Infinispan Wildfly-Swarm fraction are equivalents to persistence.xml configurations.
I have created a suite of functional UI tests for my web based application using Arquillian Done which I would like to run on a Selenium Grid as opposed to running them locally.
The problem I've got that despite setting the host/port details for the Selenium hub server in the arquillian.xml file, the UI tests are executed locally rather than on one of the Selenium nodes. I've even tried entering the details for a host that doesn't exist but the tests are still run locally and there are no error messages generated. It appears as though Drone is ignoring the configuration in the arquillian.xml file.
Is there something wrong with my configuration in the arquillian.xml file, or is there something else I'm doing wrong? Unfortunately there seems to be very little documentation on using Arquillian Drone with Selenium Grid.
The content of the arquillian.xml file is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<arquillian xmlns="http://jboss.org/schema/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<extension qualifier="webdriver">
<property name="browser">${arquillian.browser}</property>
<property name="remoteAddress">http://selenium-hub:4444</property>
</extension>
<extension qualifier="selenium-server">
<property name="host">selenium-hub</property>
<property name="port">4444</property>
<property name="skip">true</property>
</extension>
<container qualifier="arquillian-glassfish-remote">
<configuration>
...
</configuration>
</container>
</arquillian>
My Maven pom.xml file contains the following dependency and dependencyManagement sections:
<dependencies>
<!-- Various Java EE and Internal Dependencies -->
<!-- Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.graphene</groupId>
<artifactId>graphene-webdriver</artifactId>
<version>2.0.3.Final</version>
<type>pom</type>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.1.8.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.selenium</groupId>
<artifactId>selenium-bom</artifactId>
<version>2.46.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-drone-bom</artifactId>
<version>1.3.1.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
It appears there were two issues preventing the Arquillian Drone tests being executed against a Selenium Grid.
The first issue is that the webdriver section of the arquillian.xml file needs to include either <property name="remote">true</property> or <property name="remoteReusable">true</property> in addition to the remoteAddress property. Without either the remote or remoteReusable then the tests will be run locally.
The second issue was that the remoteAddress did not contain the full URL for the Selenium Grid hub server. The property should be set to <property name="remoteAddress">http://selenium-hub:4444/wd/hub</property>. Obviously selenium-hub needs to be set to the hostname of your Selenium hub server. What through me was accessing this URL via a browser returned a NullPointerException however this appears to be normal behaviour as there are other parameters set when the URL is accessed correctly.
In addition the selenium-server section of the arquillian.xml file appears to be unnecessary.
I'm trying to configure a Postgres datasource in standalone.xml. I've put the driver jar in the right place "jboss-as-7.2.0.Final\modules\org\postgresql\main" and this is my "standalone.xml":
<datasource jta="true" jndi-name="java:jboss/datasources/ProcessEngine" pool-name="ProcessEngine" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:postgresql://localhost:5432/camunda_process_engine</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<driver>postgresql</driver>
<security>
<user-name>postgres</user-name>
<password>postgres</password>
</security>
</datasource>
<drivers>
</driver>
<driver name="postgresql" module="org.postgresql">
<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
</driver>
</drivers>
...
"jboss-as-7.2.0.Final\modules\org\postgresql\main\module.xml"
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="org.postgresql">
<resources>
<resource-root path="postgresql-9.3-1102.jdbc41.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
I'm trying to start server but it shows errors.
JBAS014775: New missing/unsatisfied dependencies:
service jboss.jdbc-driver.org_postgresql_Driver (missing) dependents: [service jboss.driver-demander.java:jboss/datasources/ProcessEngine, service jboss.data-source.java:jboss/datasources/ProcessEngine]
You also have to add a dependency on your new module to your application. The easiest way to do this is to add a jboss-deployment-structure.xml to the META-INF of your Ear, or if you just have a war, put it in WEB-INF.
<?xml version="1.0"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<deployment>
<dependencies>
<module name="org.postgresql" />
</dependencies>
</deployment>
</jboss-deployment-structure>
When you redeploy, JBoss will know to put your new custom module in the classpath. Decent guide to classloading in AS7 here.
I am having a curious problem. I had this Java application which was previously deployed in tomcat and happily used logback classic as an slf4j implementation. Now when we tried to deploy the same app in a jboss 7.1.final server it doesn't even deploy the application maoning about
java.lang.ClassCastException: org.slf4j.impl.Slf4jLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext
This is the offending line of code
final LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
The class that has his is spring injected and that is failing - hence the whole application cannot be deployed. Anyone got a solution to this? Thanks in advance
After looking in this site plus other forums I realised that Jboss 7 comes bundled with it's own slf4j implementation and implement the same ILoggerFactory interface that LoggerContext in logback does. Our application tried to get an instance of the same but the app server imposes it's own slf4j implementation.
I tried to modify the module.xml in jboss\modules\org\slf4j\impl\main and pointed it to logback jars.
<resources>
<resource-root path="logback-classic-0.9.28.jar"/>
<resource-root path="logback-core-0.9.28.jar"/>
</resources>
Now when I start the application I am getting a serious error
Exception starting filter WicketFilter: java.lang.ClassCastException: ch.qos.logback.classic.LoggerContext cannot be cast to ch.qos.logback.classic.LoggerContext
I am at my wits end. Any jboss and logback experts can help?
Thanks in advance
You need to exclude the servers version of slf4j from your deployment. Create a jboss-deployment-structure.xml file and place it in either your WARS META-INF or WEB-INF directory.
The contents of the file should look like this:
<jboss-deployment-structure>
<deployment>
<!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
<exclusions>
<module name="org.slf4j" />
<module name="org.slf4j.impl" />
</exclusions>
</deployment>
</jboss-deployment-structure>
If you are using the bridges for jul or jcl in your app, you should exclude them too:
<module name="org.slf4j" />
<module name="org.slf4j.jcl-over-slf4j" />
<module name="org.slf4j.impl" />
<module name="org.jboss.logging.jul-to-slf4j-stub" />
There is alternative approach:
you got logging configured in your war
you got all dependencies in your war
you don't configure anything in JBoss server directory, not even additional JBoss modules
Just disable JBoss logging completely and rely on the dependencies in your war. Edit your jboss-deployment-structure.xml as follows:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<deployment>
<exclusions>
<module name="org.apache.commons.logging" />
<module name="org.apache.log4j" />
<module name="org.jboss.logging" />
<module name="org.jboss.logging.jul-to-slf4j-stub" />
<module name="org.jboss.logmanager" />
<module name="org.jboss.logmanager.log4j" />
<module name="org.slf4j" />
<module name="org.slf4j.impl" />
<module name="org.slf4j.jcl-over-slf4j" />
</exclusions>
</deployment>
</jboss-deployment-structure>
Once you deploy your app, bootstrap logging (boot.log) keeps working also server.log will show deployment logging. But all your application is logged through your (in this example) slf4j+logback in your war.
Note that you should not need to run JBoss with -Dorg.jboss.logging.provider=slf4j, if you specify this, you will need to provide JBoss modules (typically slf4j-api, logback-classic and logback-core), but it is not worth the effort, as JBoss logging is now used only for bootstrap (boot.log) and for deployment info (server.log).
References:
http://tinyapps.blogspot.com/2013/01/getting-logback-and-slf4j-to-work-in.html
https://stackoverflow.com/a/19695680/2587343
To make independent logging with Logback + Json in JBoss EAP 7.0 I need to exclude outdated Jackson implementation too:
jboss-deployment-structure.xml
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<deployment>
<!-- https://docs.jboss.org/author/display/AS7/Class%20Loading%20in%20AS7.html -->
<!-- https://docs.wildfly.org/16/Developer_Guide.html -->
<exclusions>
<!-- Rely on WAR's SLF4j + Logback instead of JBoss logmananger. -->
<module name="org.apache.commons.logging" />
<module name="org.apache.log4j" />
<module name="org.jboss.as.logging" />
<module name="org.jboss.logging" />
<module name="org.jboss.logging.jul-to-slf4j-stub" />
<module name="org.jboss.logmanager" />
<module name="org.jboss.log4j.logmanager" />
<module name="org.slf4j" />
<module name="org.slf4j.ext" />
<module name="org.slf4j.impl" />
<module name="org.slf4j.jcl-over-slf4j" />
<!-- Built-in Jackson is without the field: Feature.USE_THREAD_LOCAL_FOR_BUFFER_RECYCLING, need to bundle own version. -->
<!-- https://docs.jboss.org/resteasy/docs/3.0.2.Final/userguide/html/json.html -->
<module name="org.jboss.resteasy.resteasy-jackson-provider"/>
<module name="org.jboss.resteasy.resteasy-jackson2-provider"/>
</exclusions>
</deployment>
</jboss-deployment-structure>
pom.xml
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.9</version>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>7.0.1</version>
</dependency>
logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true">
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<charset>UTF-8</charset>
<pattern>%d{HH:mm:ss.SSS} %5p [%15.15t] %logger %m%ex</pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<charset>UTF-8</charset>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %5p [%t] %-40.40logger{39} %m%n%ex</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${my.log.dir}/test-servlet-logging-%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>30</maxHistory>
<totalSizeCap>500MB</totalSizeCap>
</rollingPolicy>
</appender>
<appender name="JSON-FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${my.log.dir}/test-servlet-logging-%d{yyyy-MM-dd}.ndjson</fileNamePattern>
<maxHistory>30</maxHistory>
<totalSizeCap>500MB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<includeContext>false</includeContext>
<includeMdc>true</includeMdc>
<timestampPattern>uuuu-MM-dd'T'HH:mm:ss.SSSxxx</timestampPattern>
<fieldNames>
<timestamp>#timestamp</timestamp>
<message>message</message>
<thread>thread</thread>
<logger>logger</logger>
<level>level</level>
<levelValue>[ignore]</levelValue>
<version>[ignore]</version>
<stackTrace>ex</stackTrace>
</fieldNames>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
<appender-ref ref="JSON-FILE" />
</root>
</configuration>
i am learning tomcat basics and while i tried to deploy my web-application on tomcat i am getting the following error
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project struts2-demoapp: Cannot invoke Tomcat manager: Server returned HTTP response code: 401 for URL: http://localhost:8080/manager/html/deploy?path=%2FmkyWebApp&war= -> [Help 1]
[ERROR]
as per this it seems war file location is not being passed to the tomcat manager.i have the following entries in my tomcat-user.xml
tomcat-users>
<user name="admin" password="admin" roles="admin,manager" /><!--
NOTE: The sample user and role entries below are wrapped in a comment
and thus are ignored when reading this file. Do not forget to remove
<!.. ..> that surrounds them.
-->
<role rolename="manager"/>
<role rolename="admin"/>
<user username="admin" password="admin" roles="admin,manager"/>
</tomcat-users>
here are the details of the pom.xml
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<packagingExcludes>WEB-INF/web.xml</packagingExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<warFile>${project.build.directory}/${project.build.finalName}.war</warFile>
<url>http://localhost:8080/manager/html</url>
<server>myserver</server>
<path>/mkyWebApp</path>
</configuration>
</plugin>
</plugins>
</build>
in my setting.xml there are the entries
<server>
<id>Tomcat6.x</id>
<username>admin</username>
<password>admin</password>
</server>
i am not sure what exactly is going wrong here.any help in this regard will be helpful.
Change
<server>
<id>Tomcat6.x</id>
<username>admin</username>
<password>admin</password>
</server>
to
<server>
<id>myserver</id>
<username>admin</username>
<password>admin</password>
</server>
If you are using tomcat 7 use
<url>http://localhost:8080/manager/html</url>
If tomcat 6
<url>http://localhost:8080/manager</url>
start tomcat run tomcat7:deploy or tomcat6:deploy
You need to map the credentials from your settings.xml to the server configuration at your pom.xml.
In your case, this is done but setting the <id> element of your server, to match the server's host name from the pom.xml.
Since you are pointing localhost, the id must be also localhost.
When you change the hostname, you must also update settings.xml.
It's in the plugin configuration docs: the server/id tag in Maven settings must match the configuration/server value in your POM file, i.e. put <server>Tomcat6.x</server> in POM file.
There are some other minor issues with your tomcat-maven-plugin entry in the POM file:
you are missing the <version>1.1</version> tag,
the /html suffix in the Tomcat manager URL is unnecessary (cf. the default value for <url> tag).
When I was also running into this problem. My issue was using the older
<groupId>org.codehaus.mojo</groupId>
instead of using
<groupId>org.apache.tomcat.maven</groupId>
My setup is as follows
~/.m2/settings.xml
<settings>
<servers>
<server>
<id>localhost</id>
<username>tomcat</username>
<password>tomcat</password>
</server>
</servers>
</settings>
pom.xml
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<configuration>
<url>http://localhost:8080/manager</url>
<server>localhost</server>
<path>/myapppath</path>
</configuration>
</plugin>
tomcat/conf/tomcat-users.xml
<tomcat-users>
<role rolename="manager"/>
<user username="tomcat" password="tomcat" roles="admin-gui,manager-gui,manager-script,tomcat,manager"/>
</tomcat-users>
I Advise you to use this plugin :
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.1.2</version>
It's very helpful with Tomcat7. I Have the same issue with mojo <groupId>org.codehaus.mojo</groupId>
but now, using Cargo plugin, the deploy run smooth as silk.