... [0m11:20:28,608 INFO [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http) [0m[0m11:20:28,625 INFO [org.xnio] (MSC service thread 1-9) XNIO version 3.3.0.Final [0m[0m11:20:28,631 INFO [org.xnio.nio] (MSC service thread 1-9) XNIO NIO Implementation Version 3.3.0.Final ...
Entries tagged [intellij]
Disabling color escape sequences in WildFly's console logging for IDE
TweetPosted on Wednesday Mar 18, 2015 at 11:31AM in WildFly
I’m using IntelliJ IDEA for developing Java EE applications on WildFly. its built-in WildFly console appears as follows:
You can see strange characters in the head of every lines. they are color escape sequences that works fine with terminal emulators but not for IntelliJ IDEA’s console output. to disable color escape sequences, issue following command in jboss-cli
:
/subsystem=logging/console-handler=CONSOLE:write-attribute(name=named-formatter, value=PATTERN)
Now strange characters disappeared from IntelliJ IDEA’s console as follows:
... 2015-03-18 11:26:11,800 INFO [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http) 2015-03-18 11:26:11,812 INFO [org.xnio] (MSC service thread 1-4) XNIO version 3.3.0.Final 2015-03-18 11:26:11,817 INFO [org.xnio.nio] (MSC service thread 1-4) XNIO NIO Implementation Version 3.3.0.Final ...
An example of Maven EAR project consists of an EJB interface, an EJB implementation and a WAR
TweetPosted on Friday Mar 06, 2015 at 10:43PM in Maven
The project consists of following principal modules:
-
eartest-ejb-api: holds an EJB local interface named
Hello
. packaging=jar. no dependency. -
eartest-ejb-impl: holds an EJB implementation named
HelloImpl
which implementsHello
. packaging=ejb. depends on eartest-ejb-api. -
eartest-war: holds an Servlet which has an injection point of
Hello
interface. depends on eartest-ejb-api. -
eartest-ear: holds above 3 modules in the EAR.
Whole project is can be obtained from https://github.com/lbtc-xxx/eartest .
Structure of eartest-ear module
$ tree eartest-ear/target/eartest-ear eartest-ear/target/eartest-ear |-- META-INF | `-- application.xml |-- eartest-ejb-impl-1.0-SNAPSHOT.jar |-- eartest-war-1.0-SNAPSHOT.war `-- lib `-- eartest-ejb-api-1.0-SNAPSHOT.jar 2 directories, 4 files
Structure of eartest-war module
$ tree eartest-war/target/eartest-war eartest-war/target/eartest-war |-- META-INF `-- WEB-INF `-- classes `-- eartest `-- war `-- MyServlet.class 5 directories, 1 file
MyServlet can reference eartest-ejb-api-1.0-SNAPSHOT.jar
because it’s placed under lib
directory in the parent EAR. this packaging style is called as Skinny WAR.
Structure of eartest-ejb-api
$ tree eartest-ejb-api/target/classes eartest-ejb-api/target/classes `-- eartest `-- ejb `-- api `-- Hello.class 3 directories, 1 file
Structure of eartest-ejb-impl
$ tree eartest-ejb-impl/target/classes eartest-ejb-impl/target/classes |-- META-INF | `-- ejb-jar.xml `-- eartest `-- ejb `-- impl `-- HelloImpl.class 4 directories, 2 files
A problem with IntelliJ IDEA
IntelliJ has an annoying issue: Maven support cannot handle skinny wars for EAR deployments : IDEA-97324. this brings unnecessary eartest-ejb-api into WEB-INF/lib
inside the WAR and brings following exception. to avoid this, I need to put <scope>provided</scope>
in dependency declaration for eartest-ejb-api
in pom.xml
of eartest-war
.
Caused by: java.lang.IllegalStateException: JBAS011048: Failed to construct component instance at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:162) at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:133) at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:89) at org.jboss.as.ee.component.ComponentRegistry$ComponentManagedReferenceFactory.getReference(ComponentRegistry.java:149) at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$5.createInstance(UndertowDeploymentInfoService.java:1233) at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:215) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final] ... 27 more Caused by: java.lang.IllegalArgumentException: Can not set eartest.ejb.api.Hello field eartest.war.MyServlet.hello to eartest.ejb.api.Hello$$$view17 at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167) [rt.jar:1.8.0_20] at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171) [rt.jar:1.8.0_20] at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81) [rt.jar:1.8.0_20] at java.lang.reflect.Field.set(Field.java:758) [rt.jar:1.8.0_20] at org.jboss.as.ee.component.ManagedReferenceFieldInjectionInterceptorFactory$ManagedReferenceFieldInjectionInterceptor.processInvocation(ManagedReferenceFieldInjectionInterceptorFactory.java:108) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) at org.jboss.as.ee.component.AroundConstructInterceptorFactory$1.processInvocation(AroundConstructInterceptorFactory.java:28) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45) [wildfly-ee-8.2.0.Final.jar:8.2.0.Final] at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:326) at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:160) ... 32 more
Remote debugging of standalone application with IntelliJ IDEA
TweetPosted on Friday Feb 06, 2015 at 11:08AM in Technology
Environment
-
IntelliJ IDEA 14.0.3
-
Oracle JDK 8u20
-
OS X 10.9
Procedure
-
Open/create/import a project of the target application in IntelliJ IDEA
-
Attach additional sources such as dependencies if you need it. it can be attached from
Project Structure ⇒ Libraries
. -
Set breakpoints as you desired
-
Open
Edit Configurations…
-
Click
+
button -
Click
Remote
-
Look
Configuration
tab and copy the fragment inCommand line arguments for running remote JVM
as follows:-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
-
Click
OK
-
Launch target application with preceding argument which copied
-
Click insect icon on upper-right
Evaluating JRebel for WildFly and IntelliJ IDEA
TweetPosted on Wednesday Jan 21, 2015 at 10:41PM in Technology
I’m evaluating myJRebel which is free, for personal, non-commercial use only version of JRebel. it enables hot-deployment of classes. its quick start guide for IntelliJ IDEA is nice and easy to understand.
I used an example project which used in my past posting Exploded deployment for WildFly on development and Conditional inclusion of whole element for deployment descriptor with Maven for evaluate JRebel.
Installation is very easy. we can just follow the quick start guide. my recipe is as follows:
-
Just find and install JRebel plugin from plugin installation window of IntelliJ IDEA
-
After restart, enter your activation key (get yours from https://my.jrebel.com/) in Help ⇒ JRebel Activation window
-
Add a definition of JRebel Maven Plugin. I prefer to put definition to a profile because sometimes I make my project public on GitHub or somewhere and not everyone can use JRebel
<profile> <id>jrebel</id> <build> <plugins> <plugin> <groupId>org.zeroturnaround</groupId> <artifactId>jrebel-maven-plugin</artifactId> <version>1.1.5</version> <executions> <execution> <id>generate-rebel-xml</id> <phase>process-resources</phase> <goals> <goal>generate</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile>
-
Enable a profile named
jrebel
in Maven Projects window (make sure to check if/WEB-INF/classes/rebel.xml
exists in the target directory after build) -
Launch your application server with a newly added Run with JRebel icon on upper-right. you would see some logging messages from JRebel in your console
After installation, I did some experiment that modifying a method of CDI managed bean which returns a constant string. it works fine, and pressing Command+F9 (Make Project) after modification is good so that JRebel can reflects changes immediately. also Update classes and resources On frame deactivation works fine but I felt some delay to reflect for about 1 or 2 seconds.
It works fine during the evaluation and it was very nice. it properly enabled server side Java development without deployment. I would apply it to my project.
Also I found a book named "Instant JRebel" (published on 2013). I haven’t read it but it might be good for beginners.
Exploded deployment for WildFly on development
TweetPosted on Tuesday Jan 20, 2015 at 07:25PM in Technology
I used archive deployment for long time on development because of this problem: http://stackoverflow.com/questions/24725644/intellij-idea-artifact-xxxxwar-exploded-has-invalid-extension
Archive deployment needs redeploy for reflect updates of every resource even if I updated only static content such as html, css, xhtml and jsp. it’s very annoying but finally I found a solution to use exploded deployment with WildFly and IntelliJ IDEA for WAR application so I leave some notes about it. my environment is WildFly 8.2.0.Final and IntelliJ IDEA 14.0.2.
First, specify webappDirectory which ended with .war to pom.xml in your project so that make WildFly to stop complaining that there’s no suffix to application directory.
<plugin> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <webappDirectory>${project.build.directory}/exploded/${project.build.finalName}.war</webappDirectory> </configuration> </plugin>
According to https://youtrack.jetbrains.com/issue/IDEA-86484, this should be worked for EAR deployments:
<workDirectory>${project.build.directory}/myapp.ear</workDirectory>
Set following attributes to WildFly with jboss-cli for JSP hot-deployment:
/subsystem=undertow/servlet-container=default/setting=jsp:write-attribute(name=development, value=true) /subsystem=undertow/servlet-container=default/setting=jsp:write-attribute(name=check-interval, value=1) /subsystem=undertow/servlet-container=default/setting=jsp:write-attribute(name=modification-test-interval, value=1) /subsystem=undertow/servlet-container=default/setting=jsp:write-attribute(name=recompile-on-fail, value=true) :reload
Set following parameters to web.xml for JSF(XHTML) hot-deployment:
<context-param> <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name> <param-value>0</param-value> </context-param> <context-param> <param-name>javax.faces.PROJECT_STAGE</param-name> <param-value>Development</param-value> </context-param>
REFRESH_PERIOD should be 2 (default) or something for production environment (filtering with maven might help). also it’s better to specify PROJECT_STAGE in JNDI.
Then configure your IDE.
for IntelliJ IDEA
-
Click the empty drop down list on upper right then select Edit Configurations…
-
Click "+" button on upper left then select JBoss Server ⇒ Local
-
Click "Fix" on the lower right then select an artifact which ended with "exploded"
-
Back to server tab and select desirable actions. I prefer "Update resources" for On frame deactivation because it enables that I can check modified JSP/XHTMLs with just press Command+Tab to switch to browser and reload immediately. I can trigger redeploy by hand with Command+F10 shortcut when I update some classes.
-
Now you can launch WildFly with the button on the upper right.
Refer http://jrebel.com for hot deployment of classes. it also offers free https://my.jrebel.com for personal, non-commercial use.