Debugging remote container jboss7.1.1 fails with arquillian. I set the debugging conf in the standalone.conf.bat as described here https://community.jboss.org/wiki/WhyDontBreakPointsWorkWhenDebugging. But that doesn't starts the jboss in debugging mode.
Consoleoutput:
INFO: Starting container with: [D:\java\jdk1.6.0_22\bin\java, -Xmx512m,
-XX:MaxPermSize=128m, -ea, -Djboss.home.dir=target/jboss-as-7.1.1.Final,
...
Using arquillian 1.0.3.Final.
If you use a managed container and arquillian is starting JBoss AS for you, you need to add the option to arquillian.xml. Something like:
<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">
<engine>
<property name="deploymentExportPath">target/</property>
</engine>
<container qualifier="jboss" default="true">
<protocol type="jmx-as7">
<property name="executionType">REMOTE</property>
</protocol>
<configuration>
<property name="jbossHome">${basedir}/target/jboss-as-${jbossas.version}</property>
<property name="javaVmArguments">-Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y -Xmx512m -XX:MaxPermSize=128m</property>
</configuration>
</container>
</arquillian>
Related
I'm using an Red Hat JBoss Enterprise Application Platform - Version 7.1.0.GA and trying to use picketlink 2.7.1.Final causes org.jboss.modules.ModuleLoadError.
So, I added in standalone.xml
<extension module="org.wildfly.extension.picketlink"/>
Then ran the picketlink-installer-2.7.1.Final with the ant that gave me: BUILD SUCCESSFUL, and when I try to launch my app with jboss, I get an:
WARN [org.jboss.modules] (ServerService Thread Pool -- 31) Failed to define class org.picketlink.identity.federation.web.handlers.saml2.SAML2IssuerTrustHandler in Module "org.picketlink.federation" from local module loader #58134517 (finder: local module finder #4450d156 (roots: D:\Jboss\bin\..\modules,D:\Jboss\bin\..\modules\system\layers\base)): org.jboss.modules.ModuleLoadError: org.jboss.common-core
I added the picketlink.xml file with the Handlers:
<Handlers xmlns="urn:picketlink:identity-federation:handler:config:2.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:picketlink:identity-federation:handler:config:2.1 ">
<Handler class="org.picketlink.identity.federation.web.handlers.saml2.SAML2IssuerTrustHandler" />
<Handler class="org.picketlink.identity.federation.web.handlers.saml2.SAML2LogOutHandler"/>
<Handler class="org.picketlink.identity.federation.web.handlers.saml2.SAML2AuthenticationHandler"/>
<Handler class="org.picketlink.identity.federation.web.handlers.saml2.RolesGenerationHandler"/>
</Handlers>
I added in \Jboss\modules\system\layers\base\org\jboss\common-core\main\jboss-common-4.2.2.GA.jar and an module.xml with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.5" name="org.jboss.common-core">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<dependencies>
<module name="javax.api"/>
</dependencies>
<resources>
<resource-root path="jboss-common-4.2.2.GA.jar"/>
</resources>
</module>
And that error is gone, I have other errors now...
I would like to change some properties from the log4j2.xml file depending on the my application.properties, for example define some properties and then substitute in the log4j2 those properties that are parameters.
I ran different approaches but I still did not get the right thing. I would like to have different configs depending on the environment (DEV, QA or PROD). How to accomplish this?
I'm trying to have this in my properties
#Place holders for log4j2.xml file
log.file.path=/opt/tomcat/logs
log.file.name=dummydummy
log.file.size=100 MB
log.level=DEBUG
My log4j2 below.
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" monitorInterval="30">
<Properties>
<Property name="PID">????</Property>
<property name="name">my-log</property>
</Properties>
<Appenders>
<RollingFile name="file" fileName="${log.file.path}${log.file}.log"
filePattern="${log.file.path}${log.file}-%d{yyyy-MM-dd}-%i.log.gz">
<PatternLayout
pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${sys:PID} --- [%t] %c{1}(%M:%L) : %m%n%wEx" />
<Policies>
<TimeBasedTriggeringPolicy /><!-- Rotated everyday -->
<SizeBasedTriggeringPolicy size="${log.file.size}" /> <!-- Or every 100 MB -->
</Policies>
</RollingFile>
<Console name="Console" target="SYSTEM_OUT" follow="true">
<PatternLayout
pattern="%clr{%d{yyyy-MM-dd HH:mm:ss.SSS}}{faint} %clr{%5p} %clr{${sys:PID}}{magenta} %clr{---}{faint} %clr{[%t]}{faint} %clr{%c{1}(%M:%L)}{cyan} %clr{:}{faint} %m%n%wEx" />
</Console>
</Appenders>
<Loggers>
<Logger name="org.hibernate.validator.internal.util.Version"
level="warn" />
<Logger name="org.apache.coyote.http11.Http11NioProtocol" level="warn" />
<Logger name="org.apache.tomcat.util.net.NioSelectorPool" level="warn" />
<Logger name="org.apache.catalina.startup.DigesterFactory" level="error" />
<Logger name="org.springframework.web" level="error" />
<Root level="${log.level}">
<AppenderRef ref="Console" />
<AppenderRef ref="file" />
</Root>
</Loggers>
</Configuration>
The properties lookup element allows to refer properties from an external properties file in the log4j configuration.
For your example it should be something like this:
A file env.properties contains the following properties:
log.file.path=/opt/tomcat/logs
log.file.name=dummydummy
log.file.size=100 MB
log.level=DEBUG
The properties lookup should be defined as properties of the log4j2.xml:
<Configuration>
<Properties>
<property name="log.file.path">${bundle:env:log.file.path}</property>
<property name="log.file.name">${bundle:env:log.file.name}</property>
<property name="log.file.size">${bundle:env:log.file.size}</property>
<property name="log.level">${bundle:env:log.level}</property>
</Properties>
Now the properties may be referred in appenders with ${property_name} notation. Each property reference will be interpolated with the real value from the env.properties.
You can find another example of properties lookup here.
As of Log4j 2.13.0 Log4j 2 now provides a Spring Lookup as part of its Spring Cloud Config support. It will allow you to reference properties defined in your application.properties or application.yml file of your Spring Boot application in the log4j2.xml.
Since log4j 2.14.0, you can now use Spring Boot environment variables without Spring Cloud and without doing direct reference to the properties file. You'll need at least Spring Boot 2.0.3
<property name="applicationName">${spring:spring.application.name}</property>
Documentation: https://logging.apache.org/log4j/2.x/log4j-spring-boot/index.html
Maven repository: https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-spring-boot
Ensure that log4j2 starter is added in the classpath and then remove logging related properties in application.properties then spring will load your log4j2.xml from resources folder.
This way you can have full control over logging. If you want to substitute values then refer this link
Note:: If you have actuator in your project then remove spring boot logger starter
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
Workaround in case you need just different property values in log4j2.xml config for different spring profiles (dev, test, prod, etc.).
You could access spring profile files like: ${bundle:application-${sys:spring.profiles.active}:log.file.name}
application-dev.properties file:
log.file.name=dev_log
application-prod.properties file:
log.file.name=app_name
log4j2.xml config:
<Configuration>
<Properties>
<Property name="file_name">${bundle:application-${sys:spring.profiles.active}:log.file.name}</Property>
</Properties>
<Appenders>
<RollingFile name="RollingFile"
fileName="/logs/${file_name}.log"
...
NOTE: You have to add log.file.name property to each spring profile, log4j2 sees it just as separate text files and will not resolve default values from application.properties file and etc.
Its possible to add some jvm options to embedded glassfish using arquillian ?
I need to add that jvm options:
-Djavax.net.ssl.keyStorePassword=changeit
-Djavax.net.ssl.trustStorePassword=changeit
Java properties on Glassfish are configured in domain.xml. Since you are running an embedded Glassfish, you don't really have a domain.xml file you could modify. You can try to do this in arquillian.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<arquillian xmlns="http://www.jboss.org/arquillian-1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.org/arquillian-1.0 http://jboss.org/schema/arquillian/arquillian-1.0.xsd">
<engine>
<property name="deploymentExportPath">target/</property>
</engine>
<container qualifier="glassfish" default="true">
<configuration>
<property name="configurationXml">file:src/test/resources/domain.xml</property>
...
</configuration>
</container>
</arquillian>
The configurationXml property is used to pass the configuration file to use for the embedded insance. See also https://docs.jboss.org/author/display/ARQ/GlassFish+3.1+-+Embedded. domain.xml itself has a section for JVM arguments.
I created a project using Netbeans and selected Glassfish 3.1 as a server, it also uses Derby database. Now I want to migrate to Apache Tomcat 7, I just did the following:
Stopped Glassfish
Changed the Netbeans project's properties to use Apache 7 instead of Glassfish
Added Apache to Netbeans and started it
When I try to build the project, several error messages appear like:
error: cannot find symbol
import javax.persistence.Basic;
although I ensured that /bin path of Java is set correctly in Apache server properties in Netbeans and that src.zip path is also set.
I think there are some steps that must be followed to have a successful migration, can any one guide me?
Thanks
Apache Tomcat does not come with the JPA specification. It is a Servlet container only.
You must add JPA specification plus Hibernate (implementation) to your project and make sure it will be deployed on your WEB-INF/lib.
Then, make sure your Persistence Unit is of transaction-type="RESOURCE_LOCAL", and configure all necessary properties to create a connection.
Example:
<persistence-unit name="bookmark-ds" transaction-type="RESOURCE_LOCAL">
<class>com.sample.domain.YourEntity</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver" />
<property name="javax.persistence.jdbc.user" value="sa" />
<property name="javax.persistence.jdbc.password" value="" />
<property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:mem:." />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
</properties>
</persistence-unit>
Obs: this is an HSQLDB example. Adjust for Derby. ;-)
UPDATE: there's a great tutorial for Tomcat+JPA+EclipseLink here.
I'm working on an integration test suite and I've got a question for you.
My parent pom defines the use of the jetty plugin with the goal: run-war. I need to make the port that jetty listens on changeable via the command-line. This can be achieved by passing -Djetty.port=8099 for example.
In the child project, I need to use this port number to configure the endpoint for some SOAP tests that I'll need to run on the service hosted by jetty.
If I use ${jetty.port} in my child pom in the end-point configuration this works fine IF and only IF I explicitly pass -Djetty.port when invoking maven.
In my child pom:
<endpoint>http://127.0.0.1:${jetty.port}/{artifactId}<endpoint>
I need jetty.port to be filled in with 8080 which is what jetty defaults to if -Djetty.port is not explicitly passed, and still catch any other port values if the command line argument is specified.
Use the properties section, and add a jetty.port property with a default value:
<properties>
<jetty.port>8080</jetty.port>
</properties>
config maven jetty plugin:
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1H.14.1</version>
<configuration>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8085</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
</configuration>
</plugin>
</plugins>
If you want to use a newer version of jetty plugin, use the following configuration:
From http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html:
You could instead configure the connectors in a standard jetty xml config file and put its location into the jettyXml parameter. Note that since jetty-9.0 it is no longer possible to configure a https connector directly in the pom.xml: you need to use jetty xml config files to do it.
Something like:
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.0.5.v20130815</version>
<configuration>
<jettyXml>src/main/resources/jetty.xml</jettyXml>
<webApp>
<contextPath>/yourCtxPath</contextPath>
</webApp>
</configuration>
</plugin>
would do the trick, with
jetty.xml file content:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call id="httpsConnector" name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.ServerConnector">
<Arg name="server"><Ref refid="Server" /></Arg>
<Set name="host"><Property name="jetty.host" /></Set>
<Set name="port"><Property name="jetty.port" default="8085" /></Set>
<Set name="idleTimeout">30000</Set>
</New>
</Arg>
</Call>
</Configure>
See the log after 'mvn jetty:run', at the end should show something like:
2013-09-05 09:49:05.047:INFO:oejs.ServerConnector:main: Started ServerConnector#a6e9cb4{HTTP/1.1}{0.0.0.0:8085}
You will need to use maven 3 and java 7 for this version of plugin.