- Create a DataSource in Intellij, let's name it datasource_1
- Go to the Project->View:J2EE structure->right click the module your pojos are located in, edit the JPA facet properties to set datasource_1 maps to the desired Persistent Unit, and set the default JPA provider to: Hibernate.
- Project->View:J2EE structure->right click the Persistent Unit, you should be able to start HQL Console.
- You can paste your HQL or JPAQL in the HQL Console and try it out, or you can generate SQL for it and run the SQL in your DB.
Monday, March 29, 2010
Using HQL Console for JPA facet in Intellij
You got a complicated HQL or JPAQL in your code that has some problems, you need to verify what exactly the query is doing, how should you go ahead to test run it in your database? One option is that you can read the HQL or JPAQL and manually translate it to SQL statement and run the sql statement in your Database, however, this method is error prone and tedious. Another option is use the HQL Console came with Intellij, I found this method is easy and more accurate comparing to the previous options. Here is how I did it:
Wednesday, December 09, 2009
Unable to access jarfile on Cygwin
Today I ran into a strange problem on Cygwin: I give the full path to the jar file for the java command, but strangely, the java runtime shows me the error message: Unable to access jarfile /cygdrive/c/pathtojar/.yuicompressor.jar. What is going on? did I have a typo? No. Then Why? After scratch my head enough, I figure out that the java in Cygwin does not like Unix format path to specify the jar file. You can use cygpath to do the trick to convert the Unix format path to mixed(-m) or windows format(-w) path, the java command will happily take it and use the jar file. Here are the two commands that works for me:
- java -jar `cygpath -m /cygdrive/c/pathtojar/.yuicompressor.jar`
- java -jar `cygpath -w /cygdrive/c/pathtojar/.yuicompressor.jar`
pip install python packages makes it easy
pip is easy_install replacement, and it is easy to use. Here are some features I recently used:
- To install something from Python Package Index, for example, Django 1.1, you just issue: pip install django, it will download it and install it.
- To see what Python Packages were installed by pip, you can use command: pip freeze, of course, you can redirect the output to a file and pass around.
- To uninstall a Python Package, for example, Django 1.1 installed in step 1, the command is: pip uninstall django.
- To install some Python Package you may run into error: No distributions at all found for xxxxx, you can supply the package file url to the pip install command, for example, if you want to install Django 0.96.5, here is the command: pip install http://www.djangoproject.com/download/0.96.5/tarball/, this one is pretty cool, if you can find the package gz file, then you can install it by using pip.
Friday, June 05, 2009
Install MySQL-python on Cygwin
After pulling my hairs and scavenging the Google, finally I succeeded installed the MySQL-python on Cygwin.
- Build MySQL on Cygwin
- Download MySQL source package from here. I was using mysql-5.0.76.tar.gz
- configure && make && make install
- Install MySQL-python on Cygwin
- Download MySQL-python . I was using 1.2.2. Unzip it.
- ./setup.py install, if you run into any problem, please have look on the readme file of the MySQL-python package. You may need to update threadSafe=False in the site.cfg file.
Wednesday, June 03, 2009
PIL error: IOError: decoder jpeg not available
After installing PIL on Cygwin, I ran into the following error while I am trying to load data from a JPEG file.
To solve this problem I did the following steps:
Remove the installed PIL from Cygwin:
rm -rf /usr/lib/python2.5/site-packages/PIL
rm /usr/lib/python2.5/site-packages/PIL.pth
Install libjpeg by using Cygwin setup.exe
Rerun PIL setup.py install.
IOError: decoder jpeg not availableTo solve this problem I did the following steps:
Remove the installed PIL from Cygwin:
rm -rf /usr/lib/python2.5/site-packages/PIL
rm /usr/lib/python2.5/site-packages/PIL.pth
Install libjpeg by using Cygwin setup.exe
Rerun PIL setup.py install.
unable to remap C:\cygwin\bin\tk84.dll
While installing PIL(Python Imaging Libary) on Cygwin, I ran into the following error:
5 [main] python 4388 C:\cygwin\bin\python.exe: *** fatal error - unable to remap C:\cygwin\bin\tk84.dll to same address as parent(0x410000) != 0
x700000
22 [main] python 4636 fork: child 4388 - died waiting for dll loading, errno 11
error: Resource temporarily unavailable
Fortunately, with the help of Google, it is easy to find an existing solution from Datahammer's blog:
c:\cygwin\bin\ash
cd /bin
./rebase -b 0x100000000 tk84.dll
Rerun the PIL setup.py install in Cygwin shell.
Update: If you run into remap error on Cygwin, you could try rebaseall
c:\cygwin\bin\ash
cd /bin
./rebaseall
5 [main] python 4388 C:\cygwin\bin\python.exe: *** fatal error - unable to remap C:\cygwin\bin\tk84.dll to same address as parent(0x410000) != 0
x700000
22 [main] python 4636 fork: child 4388 - died waiting for dll loading, errno 11
error: Resource temporarily unavailable
Fortunately, with the help of Google, it is easy to find an existing solution from Datahammer's blog:
c:\cygwin\bin\ash
cd /bin
./rebase -b 0x100000000 tk84.dll
Rerun the PIL setup.py install in Cygwin shell.
Update: If you run into remap error on Cygwin, you could try rebaseall
c:\cygwin\bin\ash
cd /bin
./rebaseall
Thursday, April 16, 2009
Unix commands help on diagnosing Weblogic problems
While working on diagnosing the Weblogic problems, I found the unix commands help me a lot, here they are:
- Apache error_log files BackEnd errors: grep -r -h --include=error_log Backend . | awk '{print $2 " " $3}'| sort | uniq -c
- Oracle connections: while true; do netstat -an|grep 1521; netstat -an|grep 1521|wc -l; echo "+++++++++++++++++++"; sleep 4; done;
Thursday, April 09, 2009
Google App Engine for Java Rocks!!!
I signed up GAE yesterday, and the account was activated today. It is time to play with it:
* Create Application ID
* Download and install Eclipse plugin
* Create new Web application
* Deploy application to GAE
Done!!!
It is just so easy.
More will come on this topic.
* Create Application ID
* Download and install Eclipse plugin
* Create new Web application
* Deploy application to GAE
Done!!!
It is just so easy.
More will come on this topic.
Friday, March 13, 2009
How to remote debug JMeter?
Want to remote Debug JMeter? Here I show you how I did it?
- Download JMeter binary package and source package, unzip them into the same directory.
- Rename the eclipse.classpath file to .classpath and open the project with IDEA.
- Open a shell, set JVM_ARGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
- Start JMeter in the previous shell.
- Setup remote debug in IDEA and start debug.
Setup JMeter JMS Publisher Sampler
Even though there are documentations on how to setup and use JMeter JMS publisher sampler, it seems all of them are either inaccurate or out of date. After pulling my hair for almost two hours, I finally made it work. To avoid headache for anybody who want to set up JMeter JMS publisher sampler, I recorded the procedure as following.
We choose ActiveMQ as our JMS provider.
java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
java.naming.provider.url=tcp://hostname:61616
topic.MyTopic=topic
There are a few catches during the setting up process:
* The ActiveMQInitialContextFactory package name must have the apache.
* ConnectionFactory can not contain any trailing space.
* The Topic JNDI name must be prefixed with topic in the jndi file.
* You must put in the Number Of messages to aggregate, otherwise there will be no messages published.
We choose ActiveMQ as our JMS provider.
- Copy activemq-core-5.2.0.jar, jms-1.1.jar, and geronimo-j2ee-management_1.0_spec-1.0.jar into JMeter's lib directory.
- Create a jndi.properties file and jar it into a jar file, put the jar file into JMeter's lib directory.
- Confiture the JMS publisher sampler with the following settings in the JMeter GUI.
- Check use jndi.properties
- Connection Factory: ConnectionFactory
- Topic: MyTopic
- Number of messages to aggregate: 1
java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
java.naming.provider.url=tcp://hostname:61616
topic.MyTopic=topic
There are a few catches during the setting up process:
* The ActiveMQInitialContextFactory package name must have the apache.
* ConnectionFactory can not contain any trailing space.
* The Topic JNDI name must be prefixed with topic in the jndi file.
* You must put in the Number Of messages to aggregate, otherwise there will be no messages published.
Monday, December 08, 2008
TeamCity checkout rules
In team city Version Control Settings you can include/exclude the path for checkout.
Here are a few examples:
+:project1/testing/watirtests
+:project1/ant
-:project1/testing/watirtests
-:project1/ant
Here are a few examples:
- I want to checkout only the directories:/project1/testing/watirtests, and /project1/ant, but not anything else under project1:
+:project1/testing/watirtests
+:project1/ant
- I want to checkout everything but derectories:/project1/testing/watirtests, and /project1/ant:
-:project1/testing/watirtests
-:project1/ant
Monday, December 01, 2008
Python recursive generator to find all the files in a directory
Just for exercise, I programed the following transverse_directory function in python to find out all the files in a directory tree in python, while trying the google treasure hunt - zip:
def transverse_directory(path):
if os.path.isdir(path):
for item in os.listdir(path):
item_path = os.path.abspath(path) + os.sep + item
for file in tranverse_directory(item_path):
yield file
else:
yield path
Wednesday, November 26, 2008
Recursive lambda implementation factorial function in Python
It is easy to implement factorial function use recursive in Python, but how do you implement it by using recursive lambda in Python? Here is my try:
fact = lambda n: (n and n-1) and n*fact(n-1) or 1
Tuesday, November 25, 2008
What are the Secrets of the Furious Five?
Did you get the secrets of the Furious Five?
Patience(耐心), Courage(勇气), Confidence(信心), Control your strength(自制力) , Compassion(同情心)
Patience(耐心), Courage(勇气), Confidence(信心), Control your strength(自制力) , Compassion(同情心)
Thursday, October 23, 2008
W3C XML Schema design
Recently, I am involved in a project to design some XML Schema for our partners. While working on it, I referred to some resources on the internet, most of them are listed in this Google search result page. I list a few that caught my eyes and I felt helpful:
Thursday, October 09, 2008
Oracle BEA Weblogic Server 10 "invalid pad byte" error
First of first, BEA has the worst error message ever, it just does not make any sense, maybe just for me!
When switch to a new weblogic domain, we like to copy the configuration files to the new domain in order to reserve some configurations works, such as JMS, JDBC settings.
However, you may get weblogic.management.ManagementRuntimeException: com.rsa.jsafe.JSAFE_PaddingException: Could not perform unpadding: invalid pad byte.
Does this give you any hint that your password-encrypt is incorrect?
You may need to re-encrypt your password in the new domain by using the BEA supplied weblogic.security.Encrypt tool to archive this goal.
java -cp ./weblogic/server/lib/weblogic.jar -Dweblogic.RootDirectory={your domain} weblogic.security.Encrypt {your plain text password}
When switch to a new weblogic domain, we like to copy the configuration files to the new domain in order to reserve some configurations works, such as JMS, JDBC settings.
However, you may get weblogic.management.ManagementRuntimeException: com.rsa.jsafe.JSAFE_PaddingException: Could not perform unpadding: invalid pad byte.
Does this give you any hint that your password-encrypt is incorrect?
You may need to re-encrypt your password in the new domain by using the BEA supplied weblogic.security.Encrypt tool to archive this goal.
java -cp ./weblogic/server/lib/weblogic.jar -Dweblogic.RootDirectory={your domain} weblogic.security.Encrypt {your plain text password}
Monday, August 11, 2008
Seam getting start with JBoss Tools Plugin for Eclipse
Tuesday, July 08, 2008
Saturday, March 08, 2008
Better Web App
Watch the following video, get a feeling on what is better to be used to develop web application.
better-web-app.mov (video/quicktime Object)
better-web-app.mov (video/quicktime Object)
Thursday, February 28, 2008
Oracle Lite dmagent managing olite.key
While dmagent running, it may hold a copy of the olite.key in the memory. So if you change the olite.key in the file system level, it may not be picked up during next action.
Also, the dmagent has the ability to download the new olite.key as it needs, but you may see the username/password challenge window, if you are sure the username/password is correct, just simply click OK, let it try with the new olite.key downloaded by the dmagent. Surprise, it succeeded!
Also, the dmagent has the ability to download the new olite.key as it needs, but you may see the username/password challenge window, if you are sure the username/password is correct, just simply click OK, let it try with the new olite.key downloaded by the dmagent. Surprise, it succeeded!
Subscribe to:
Posts (Atom)
Full Guide for using Bitnami Prometheus Operator Helm Chart with Additional Scrape Configuration
"The Prometheus Operator for Kubernetes provides easy monitoring definitions for Kubernetes services and deployment and management of...
-
After some digging, finally I got android market working on Android emulator 2.2 running on Windows Vista. Here is the steps,: Start SDK Set...
-
Thingsboard is a fantastic open source IoT data gathering and visualization platform. I was trying to setup the local development mode for ...
-
"The Prometheus Operator for Kubernetes provides easy monitoring definitions for Kubernetes services and deployment and management of...









