lunedì, gennaio 19, 2015
mercoledì, dicembre 17, 2014
martedì, novembre 25, 2014
Create a simple maven project
$ mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart
It works in interactive mode, so you will be asked to type groupId, atifactId and so on.
Here how to create a webapp template from the maven archetype plugin in not interactive mode.
$ mvn archetype:generate -DgroupId=org.enricogiurin.poc -DartifactId=maven-usage -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
https://maven.apache.org/archetype/maven-archetype-bundles/maven-archetype-quickstart/
http://www.mkyong.com/maven/how-to-create-a-web-application-project-with-maven/
http://maven.apache.org/guides/mini/guide-building-for-different-environments.html
http://maven.apache.org/plugins/maven-resources-plugin/examples/copy-resources.html
To make compatible with java 8, add this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
martedì, giugno 17, 2014
lunedì, novembre 25, 2013
Soup with vegetables
Here a simple recipe to prepare a tasty soup with vegetables.
Before starting make sure you have the following ingredients: 2 potatoes without peel, 3 carrots, 10 green beans with the ends cut, 1 pepper, 300ml tomato sauce, salt, oil of olive, 1 onion without peel.
So, let's start!
I learned how to prepare it today in the soup session with my friend Cristian, I hope to have not forgotten some steps so I won't consider myself responsible of the success of the soup ;-)
So, let's start!
- Cut the potatoes, carrots, green beans, pepper, onion in small pieces, not so small though.
- Put these ingredients in a pot and fill it with the water.
- Light the fire and wait till the water in the pot start to boil.
- Once it's boiling reduce the level of firing to minimum and let it boil for other 60 minutes; really this is important, the level of firing should be very low, you should observe the level of water just boiling a bit.
- Add the potatoes in the pot.
- Add two spoons of oil of olive and a bit of salt.
- Let it boil, always with low fire, for about 25 minutes.
- Add the tomato sauce and half of dado knorr
- Let it boil for the last 5 minutes.
I learned how to prepare it today in the soup session with my friend Cristian, I hope to have not forgotten some steps so I won't consider myself responsible of the success of the soup ;-)
giovedì, novembre 21, 2013
Building Reactive Apps @ Jug Lausanne
Yesterday I've participated at the meeting @ JUG Lausanne, where there was a presentation with the title "Building Reactive Apps" kept by James Ward.
In the room there were about 40 persons and the speech was kept in English.
After having talked about the reactive manifesto , the speaker shortly introduced the principles of reactive programming
Has followed a demo of how to build a reactive application with the play framework, where he showed the usage of Future classes. Other topics were related websocket, actors in AKKA, scala and so on.
I think I'll give a try to these new technologies.
In the room there were about 40 persons and the speech was kept in English.
After having talked about the reactive manifesto , the speaker shortly introduced the principles of reactive programming
Has followed a demo of how to build a reactive application with the play framework, where he showed the usage of Future classes. Other topics were related websocket, actors in AKKA, scala and so on.
I think I'll give a try to these new technologies.
venerdì, settembre 13, 2013
NoClassDefFoundError in Jboss with maven EJB plugin when using SNAPSHOT dependencies
Context: Jboss 5.1.0, maven 2.x, snapshot dependencies.
Problem: I got this exception after deployed my ear in jboss 5.1.
EAR name: myEAR.ear
ejb component: services.jar
Jboss classloader cannot find the myPackage/MyInterface.class when this is a SNAPSHOT dependency of my services.jar.
Solution: Correct configuration of the maven ejb plugin.
You need to set to false the useUniqueVersion attribute.
Problem: I got this exception after deployed my ear in jboss 5.1.
EAR name: myEAR.ear
ejb component: services.jar
Jboss classloader cannot find the myPackage/MyInterface.class when this is a SNAPSHOT dependency of my services.jar.
Solution: Correct configuration of the maven ejb plugin.
You need to set to false the useUniqueVersion attribute.
org.apache.maven.plugins
maven-ejb-plugin
3.0
true
false
Exception stack-trace:
er.MBeanServerImpl@52f97d27[ defaultDomain='jboss' ]
2013-09-13 14:22:03,699 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (main) Error installing to PostClassLoader: name=vfszip:/usr/local/jboss-5.1.0.GA-jdk/server/standard/deploy/myEAR.ear/ state=ClassLoader mode=Manual requiredState=PostClassLoader
org.jboss.deployers.spi.DeploymentException: Error during deploy: vfszip:/usr/local/jboss-5.1.0.GA-jdk/server/standard/deploy/myEAR.ear/services.jar/
at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49)
at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:177)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1210)
at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)
at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)
at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
at org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306)
at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271)
at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)
at org.jboss.Main.boot(Main.java:221)
at org.jboss.Main$1.run(Main.java:556)
at java.lang.Thread.run(Thread.java:679)
Caused by: java.lang.NoClassDefFoundError: myPackage/MyInterface
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at org.jboss.classloader.spi.base.BaseClassLoader.access$200(BaseClassLoader.java:63)
at org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.java:572)
at org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.java:532)
at java.security.AccessController.doPrivileged(Native Method)
at org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseClassLoader.java:530)
at org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseClassLoader.java:507)
at org.jboss.classloader.spi.base.BaseDelegateLoader.loadClass(BaseDelegateLoader.java:134)
at org.jboss.classloader.spi.filter.FilteredDelegateLoader.loadClass(FilteredDelegateLoader.java:131)
2013-09-13 14:22:03,699 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (main) Error installing to PostClassLoader: name=vfszip:/usr/local/jboss-5.1.0.GA-jdk/server/standard/deploy/myEAR.ear/ state=ClassLoader mode=Manual requiredState=PostClassLoader
org.jboss.deployers.spi.DeploymentException: Error during deploy: vfszip:/usr/local/jboss-5.1.0.GA-jdk/server/standard/deploy/myEAR.ear/services.jar/
at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49)
at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:177)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1210)
at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)
at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)
at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
at org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306)
at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271)
at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)
at org.jboss.Main.boot(Main.java:221)
at org.jboss.Main$1.run(Main.java:556)
at java.lang.Thread.run(Thread.java:679)
Caused by: java.lang.NoClassDefFoundError: myPackage/MyInterface
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at org.jboss.classloader.spi.base.BaseClassLoader.access$200(BaseClassLoader.java:63)
at org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.java:572)
at org.jboss.classloader.spi.base.BaseClassLoader$2.run(BaseClassLoader.java:532)
at java.security.AccessController.doPrivileged(Native Method)
at org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseClassLoader.java:530)
at org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseClassLoader.java:507)
at org.jboss.classloader.spi.base.BaseDelegateLoader.loadClass(BaseDelegateLoader.java:134)
at org.jboss.classloader.spi.filter.FilteredDelegateLoader.loadClass(FilteredDelegateLoader.java:131)
lunedì, maggio 20, 2013
Spring - Unable to process claimed identity 'https://www.google.com/accounts/o8/id'
Issue - The openId gmail authentication, built on top of springsecurity, stopped to work on my website and I got this error:
org.springframework.security.authentication.AuthenticationServiceException: Unable to process claimed identity 'https://www.google.com/accounts/o8/id'
Reason - in the class OpenID4JavaConsumer
error: org.openid4java.discovery.DiscoveryException: 0x70d: Error parsing XML document
Solution
I fixed the issue by updating the version of xmlParserAPIs and xercesImpl from 2.5 to 2.6.x.
The wrong version for xmlParserAPIs and xmlParserAPIs was brought by jcaptcha so I had to exclude those two.
See this link on jugevents.
org.springframework.security.authentication.AuthenticationServiceException: Unable to process claimed identity 'https://www.google.com/accounts/o8/id'
Reason - in the class OpenID4JavaConsumer
error: org.openid4java.discovery.DiscoveryException: 0x70d: Error parsing XML document
Solution
I fixed the issue by updating the version of xmlParserAPIs and xercesImpl from 2.5 to 2.6.x.
The wrong version for xmlParserAPIs and xmlParserAPIs was brought by jcaptcha so I had to exclude those two.
See this link on jugevents.
giovedì, ottobre 11, 2012
mercurial and mercurialEclipse plugin in ubuntu
Install the latest version of mercurial
- $ sudo add-apt-repository ppa:mercurial-ppa/releases
- $ sudo apt-get update
- $ sudo apt-get install mercurial
- check version of mercurial: $ hg --version
Mercurial eclipse plugin
- Help/Eclipse marketplace
- Find: Mercurial
- Install MercurialEclipse (requires at least mercurial 2.0)
Resources
mercoledì, ottobre 10, 2012
Creating a shortcut to eclipse on the ubuntu desktop
Proceed in this way:
- right click on desktop: Create Launcher
- set the proper icon eclipse_home/icon.xpm
- Set the command: eclipse_home/eclipse
Troubleshooting
Issue: "A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No Java virtual machine was found after searching the following locations "
Solution
- $ cd eclipse_home
- $ mkdir jre
- $ cd jre
- $ ln -s /opt/jdk1.6.0_35/jre/bin/ bin
Resources:
http://ubuntuforums.org/showpost.php?p=11081349&postcount=4
http://www.linuxquestions.org/questions/linux-newbie-8/how-to-create-desktop-shortcut-with-eclipse-ide-icom-876136/#post4331155
http://www.linuxquestions.org/questions/linux-newbie-8/how-to-create-desktop-shortcut-with-eclipse-ide-icom-876136/#post4331155
martedì, maggio 08, 2012
filesync eclipse plugin
Nice eclipse plugin to synchronize resources.
http://andrei.gmxhome.de/filesync/index.html
Adopting it will speed up your development process without need to rebuild each time you edit a resource in the src folder, for instances a jsp.
http://andrei.gmxhome.de/filesync/index.html
Adopting it will speed up your development process without need to rebuild each time you edit a resource in the src folder, for instances a jsp.
venerdì, gennaio 27, 2012
Remotely debug tomcat on linux
Create this simple shell script: debugtomcat.sh
resource
#leave this command for future reference
#export currentdir=`pwd`
export JAVA_OPTS='-Xmx1024m -XX:MaxPermSize=512m
-Xdebug -Xrunjdwp:transport=dt_socket,
address=8000,server=y,suspend=n'
echo JAVA_OPTS: $JAVA_OPTS
/$HOME/MyPrograms/apache-tomcat-6.0.35/bin/catalina.sh run
resource
mercoledì, dicembre 07, 2011
svn ignore list commands
- % set SVN_EDITOR=notepad
- % svn propedit svn:ignore .
- % svn propget svn:ignore .
Decrease the double click speed for Java Applications on Ubuntu Linux
I couldn't properly use double click on idea so I found a great solution in this post.
To resume:
It's amazing that intellij doesn't take in account this issue.
To resume:
In your home directory create a file called .Xresources and add the following line
*multiClickTime: 400
Then from the commandline execute
xrdb ~/.Xresources
It's amazing that intellij doesn't take in account this issue.
venerdì, luglio 22, 2011
Serving jboss logs as static content
This configuration has been tested using red hat linux and jboss 5.1.x
Links
Enable symlinks
Enable directory browsing
- Edit the
<jboss_home>/server/default/deployers/jbossweb.deployer/web.xml
and change the servlet attribute listings from false to true. - Edit the
<jboss_home>/server/default/deploy/jbossweb.sar/servlet.xml
and add the attribute allowLinking="true" to the Context element. - Create a log folder in the path
<jboss_home>/server/default/deploy/ROOT.war - In the log folder create a symbolic link to the log folder of jboss
$ ln -s ../../../log listAll - Restart the jboss instance
- The logs will be available at this url http://myHost:8080/log/listAll
Links
Enable symlinks
Enable directory browsing
venerdì, maggio 27, 2011
sabato, maggio 14, 2011
martedì, febbraio 22, 2011
Jboss - Port already in use: 1098
I got this exception after started jboss 5.1 on windows XP.
I tried to understand which process was using that port by running this command:
But the result didn't show any port associated to 1098.
Finally I edited the file at <jboss_51_home>\server\default\conf\bindingservice.beans\META-INF\bindings-jboss-beans.xml
and changed the value of the port 1098 to 10980 and the error has disappeared.
Windows and Jboss ...such a nightmare.
Here the link where I found the solution.
ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (main)
Error installing to Start: name=jboss:service=Naming
state=Create mode=Manual requiredState=Installed
java.rmi.server.ExportException: Port already in use: 1098;
nested exception is:
java.net.BindException: Address already in use: JVM_Bind
I tried to understand which process was using that port by running this command:
$> netstat -a -o -n
But the result didn't show any port associated to 1098.
Finally I edited the file at <jboss_51_home>\server\default\conf\bindingservice.beans\META-INF\bindings-jboss-beans.xml
and changed the value of the port 1098 to 10980 and the error has disappeared.
Windows and Jboss ...such a nightmare.
Here the link where I found the solution.
Nice java client to execute remote ssh
http://www.journaldev.com/246/java-program-to-run-shell-commands-on-ssh-enabled-system
Just add this dependency at your pom.xml
Just add this dependency at your pom.xml
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.42</version>
</dependency>
lunedì, febbraio 21, 2011
Stop jboss in the case it's running
If you need to stop jboss inside a shell script this block of code could be useful.
if ps -ef | grep "<jboss_home>/bin/run.jar" | grep -v grep
then
echo [deploy] Stopping Jboss...
<jboss_home>/bin/shutdown.sh -S --server=localhost:1199
sleep 12s
else
echo [deploy] Jboss was already stopped
sleep 2s
fi
Iscriviti a:
Post (Atom)
