Last Friday, after “illegally” struggling in Australia for more than one year, I was granted permanent residency visa. With a lot of congratulations coming from different people, a common question they ask is ‘what is Australian Permanent Residency’? This question even comes from many Aussies which I thought the answer should be crystal clear for them. Now I realized the one who knows it well can only be those people who had/have experience to deal with the evil DIAC ( Department of Immigration and Citizenship).
Anyway, in this post, I will shortly introduce what is Australian Permanent Residency and how does it work for migrating people like me.
As everyone knows, generally there are only a few countries in the world publicly welcome immigration, Australia, Canada, New Zealand to name a few. Most of these countries share the same features like highly developed but low population density. In order to keep these contries’ development, more on economical perspective, they need immigrates to fill the holes for skills shortage. The occupations varied from country to country depending on what kind of main industry the country runs. Let’s go back to Australia again, the immigration policy has changed dramatically in the last ten years. Start from 2000, as the strong need from Australia government, it was extremely easy for an overseas student to get a permanent residency after studying in Australia for a tertiary degree. Under that policy, many many students came to Australia and settled since then. Meanwhile, they acted as an advertisement or agent, and attracted more crowds keeping coming. Consequently, a lot of changes of the migration policy had been put on. From 2007, a two-year minimum study period and IETLS 4*7 was started to be effective. Though pretty hard, comparing to the huge base numbers of students, still too many are eligible to stay in Australia after graduation. Started from 2008, more and more changes put on migration law made most of the graduates lost the opportunity to apply for PR, and had to return to their own country after spending thousands of thousands dollars here.
Currently, migration law is still under discussion, and another dramatic overhaul is being in progress and is due to release on Jul 1, 2011. Australia is no longer a country that can be easily migrated.
So, after you got PR, what benefits you can get out of it?
You are eligible to staying in Australia indefinitely You can work, study, or nearly do whatever you want in Australia You are free to leave Australia and back to Australia as many times as you want You have the right to apply Medicare You can also apply for centrelink after two years You can freely go to New Zealand Comparing the citizenship, the only a few disadvantages areYou have to renew your PR visa every five years, and within this period time, you have to stay at least 2 years to show you are genuinely would like to be a resident in Australia You have no political right in Australia, and cannot vote (which I guess most people would not care) You cannot apply for Australian passport, and if you have to use your original passport to apply any third-country visa (Except New Zealand) I would say, the most benefit to apply for a citizenship is you get an Australian passport which allows you to enter most of the countries in the world without worring about visa. However, if your original country doesn’t allow dual citizenship (e.g. China), then the moment you join Australia, you lost your original country’s citizenship. This may be a big problem, if you wish to go back to your original country after 20 years or would like to work there, and will also be a problem for your property or deposits back in your own country. That’s why, there are many people working in Australia holding a PR visa not applying for the citizenship.
This is the second time I ran into the JTA exceptions. Basically, you will get this message every one minute when running your EJB on any version of WebLogic server:
<Warning> <JTA> <BEA-110486> <Transaction BEA1-05576B5644FBD4F5B49F cannot complete commit processing because resource [weblogic.jdbc.wrapper.JTSXAResourceImpl] is unavailable. The transaction will be abandoned after 67,910 seconds unless all resources acknowledge the commit decision.>
Last I did google it, get rid of it, and eventually forget about it at all. Now it’s a good chance for me to pick it up and record it down. Hopefully next time I can handle it in no time without spending half an hour wondering around. I tried different ways like restart server, uninstall/reinstall application, etc. No luck at all.
This warning message is because something is wrong in your code, specifically of transaction. There must be some of the transaction still keep opening after some exception happens or similar alike. As a result, the server complain that there is a transaction still running which no one seems to be using it at all.
In order to get rid of this ugly message, just go to your domain: <your-domain>/servers/AdminServer/data/store/default, there should be a file like “_WLS_ADMINSERVER000000.DAT” there. The number will random. If you delete this file, and restart the server, problem solved!
I was aware of the release of Firefox since Day 1, and kept trying to use numerous beta or trial version or even the minefield (sounds scary as the name or the real experience?) before the official release. However every time I just switched back to my lovely and sleek Chrome. Don’t blame my patience, it just never worked out.
But this time, I have to say, the FF4 release is a huge success in terms of every aspect I can consider so far. The speed improvement is the topic that people keeping discussing all these two days. It’s dramatically speed up everything even ten tabs are opening at the same time. The memory is another point I reckon, which used to consume nearly 700-800 MB on my poor machine, now can stably up and down around 300-400 MB. Actually this is one of the killing point for my working machine since this old PC always needs to Intellij Idea, WebLogic, SQLDeveloper and all sorts of dev tools all at once, you know how hard time I am having.
Another thing I like FF better than Chrome is it can temporarily record down the input you have put in before. Next time, you don’t need to repeat those lengthy characters but just double click the text field. For me it’s really helpful since I have do those boring task everyday to make sure programs never being screwed up.
Because it’s only Day 2, I don’t mind the add-ons are not ready for use. But please, guys, at least make some of the most common tools available ASAP. I have spent nearly half an hour this morning trying to find a good add-on for twitter. You will know the result if you do the same search now, not two days later, I reckon things may change less than 48 hours because weekend is coming
Anyway, now I have both Chrome and FF running at the same time finally (which also thanks for the latest upgrade of the memory), each sitting in a monitor. Before I make any final decision to stick on which browser, I will hang over, or later I may get used to the dual browser environment. Should I?
P.S. It would be nice if we can have a cross-browser bookmark application. Any recommendations?
I know this is one of the most basic topic that even second year university should be familiar with, however, this afternoon I have spent nearly a whole afternoon to debug some issues with Java Multi-threading, and only at that point I realized I am far far away from fully understanding the seemingly easy problem.
As I have reading through all kinds of tutorials, discussions available, I believe the best way would be to sommarize what I have found and record it as my own writing.
So here is the beginning, Java always running with a single thread if there is no request for a new thread to be spawned. However, in some circumstances, a separate thread is needed to perform some other tasks either to be parallel with the main thread or as a background job. There are two ways to achieve multi-thread in Java, as everyone should be familiar with: implements Runnable and extends Thread.
Basically, most of the time, implements Runnable should be the preference over extends Thread, unless you need to specifically override the life cycle method of the thread (which is rare). These two ways do nearly the same thing except when you subclass Thread, you are trapped in the spot that no other class can inherit as Java only allows single inheritance. While if you implements the interface, you still have the ability to extend any class you wish.
Next, let’s go into the main method in the body — run(). Actually, you have the choice to call run() and start() to execute the body. However, there is some slight differences between these two methods. run() will execute the method immediately in the current thread, and start() will spawn a new thread and the execution will be invoked undeterministicallly. As a rule of thumb, we should avoid to use run() but use start() all the time. The reason we have a multi-thread class is to run it in a separate thread. If we just call the run(), everything will run sequentially as there is no thread existed. run() should always invoked by JVM not the application.
Another point we should pay some attention is Executor which comes from JDK 5. Instead of explicitly calling new MyThread().start() to invoke the new thread, Executor can decouple the task submission from the real method perform -> executor.execute(new MyThread()).
com.ctc.wstx.exc.WstxIOException:
Tried all: ‘1′ addresses, but could not connect over HTTP to server: ‘java.sun.com’, port: ‘80′
at com.ctc.wstx.sr.StreamScanner.throwFromIOE(StreamScanner.java:683)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1086)
at weblogic.servlet.internal.TldCacheHelper$TldIOHelper.parseXML(TldCacheHelper.java:134)
at weblogic.descriptor.DescriptorCache.parseXML(DescriptorCache.java:380)
at weblogic.servlet.internal.TldCacheHelper.parseTagLibraries(TldCacheHelper.java:65)
Truncated. see log file for complete stacktrace
java.net.ConnectException:
Tried all: ‘1′ addresses, but could not connect over HTTP to server: ‘java.sun.com’, port: ‘80′
at weblogic.net.http.HttpClient.openServer(HttpClient.java:312)
at weblogic.net.http.HttpClient.openServer(HttpClient.java:388)
at weblogic.net.http.HttpClient.New(HttpClient.java:238)
at weblogic.net.http.HttpURLConnection.connect(HttpURLConnection.java:172)
at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:356)
Truncated. see log file for complete stacktrace
Sometimes, you may encounter problems like this which slows the deployment process.
One option to workaround this issue is add
“-Djavax.xml.stream.XMLInputFactory=weblogic.xml.stax.XMLStreamInputFactory”
to your WebLogic start script. It will prevents WebLogic to fetch any remote xml definition files.
1. System.out.println is expensive. These calls are synchronized for the duration of disk I/O, which
significantly slows throughput.
2. By default, stack traces are logged to the console. But browsing the console for an exception trace isn’t feasible in
a production system.
3. In addition, they aren’t guaranteed to show up in the production system, because system administrators can map
System.out and System.errs to ‘ ‘ [>nul] on NT and dev/nul on UNIX. Moreover, if you’re running the
J2EE app server as an NT service, you won’t even have a console.
4. Even if you redirect the console log to an output file, chances are that the file will be overwritten when the
production J2EE app servers are restarted.
5. Using System.out.println during testing and then removing them before production isn’t an elegant solution
either, because doing so means your production code will not function the same as your test code.
While this is a really old topic, the process to develop a maven plugin still need some time to sort our especially for people who are not familiar with Maven, like me. So here is a very short introduction on how to develop a maven plugin and how to integrate it with your existing application.
Prerequisite: of course, you need Maven, and all other things will totally depend on your wish. For me, I use Eclipse with m2eclipse plugin which saves me some time to create the archetype of Maven plugin project. However, this is a rather simple process and everyone can do it in command line with only a few typing.
1. Create a new Maven plugin project in Eclipse. Here, we name the project groupid: Featheast, artifactid: maven-test-plugin. Please pay attention to the naming convention of artifactid which we will use a little bit later.
2. Under the src directory, create a new Class naming MyMojo which extends AbstractMojo. AbstractMojo is the class you must inherit for plugin to work, and the only method you have to implement is execute(), where the real business will happens.
3. In order for other project to recognize your plugin function, you have to specify what the Mojo does. In Maven, this is accomplished by add an annotation @goal for the class in the comment of class. This goal name will be used later for other projects to reference this function.
4. You can create any number of variables in the class which acts like a parameter for later process. Consider the whole class as a function, then this variables will be the arguments you passed in. For each variable, another annotation @parameter will be used to specify how to like the variable to external usage.
5. Set the real business logic in the execute() function. You can use the Maven log to print out or debug for your convenience. An internal method getLog() is always there for you to do so and the usage of it is quite similar to the log4j.
/**
*
* @author yudong
*
* @goal realmojo
*/
public class MyRealMojo extends AbstractMojo{
/**
* @parameter expression=”${mymojo.username}”
*/
private String username;
/**
* @parameter expression=”${mymojo.password}”
*/
private String password;
public void execute() throws MojoExecutionException, MojoFailureException {
if(password.length()<10){
getLog().info(”Hey” + username +”, your password is too short!”);
}else{
getLog().info(”Congratulations ” + username + “, your password is all right!”);
}
Set set = getPluginContext().keySet();
getLog().info(”The context include ” + set.size() + ” entries”);
Iterator iterator = set.iterator();
while(iterator.hasNext()){
Object key = iterator.next();
getLog().info(key.toString() + ” : ” + getPluginContext().get(key));
}
}
}
6. In the pom.xml, add any dependency you need, then add the maven-plugin-plugin to build the plugin. Specify any goals that you want to be included in the build output.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<goalPrefix>Plugin.Test</goalPrefix>
<username>Featheast</username>
</configuration>
<goals>
<goal>
realmojo
</goal>
</goals>
</plugin>
</plugins>
</build>
7. Now your Maven plugin is created, build it with standard command: mvn install.
8. Create another project to use this plugin. Add the plugin configuration in the pom.xml, and specify the goal.
<build>
<plugins>
<plugin>
<groupId>Featheast</groupId>
<artifactId>maven-test-plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>realmojo</goal>
</goals>
<configuration>
<username>This is the usernmae</username>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
9. You could specify the parameters in the configuration tag, or you can add -Dusername = XXX in the command line to pass in the parameters.
10. Finally what you did will be print on the console, once you build the new project.
An enterprise bean is a server-side software component that can be deployed in a distributed multi-tiered environment, and it will remain that way going forward. Anyone who has worked with Enterprise JavaBeans technology before knows that there are three types of beans - session beans, entity beans, and message-driven beans. Historically an EJB component implementation has neven been contained in a single source file; a number of files work together to make up an implementation of an enterprise bean. Let us briefly go through these EJB implementation artifacts:
1) Enterprise bean class
The primary part of the bean used to be the implementation itself - which contained the guts of your logic - called the enterprise bean class. This was simply a Java class that conformed to a well-defined interface and obeyed certain rules. For instance, the EJB specification defined a few standard interfaces forced your bean class had to implement. Implementing these interfaces forced your bean class to expose certain methods that all bean must provide, as defined by the EJB component model. The EJB container called these required methods to manage your bean and alert your bean to significant events. The most basic interface that all of the session, entity and message-driven bean classes implemented is the javax.ejb.EnterpriseBean interface. This interface served as a marker interface, meaning that implementing this interface indicated that your class was indeed an enterprise bean class. Session beans, entity beans, and message-driven beans each had more specific interfaces that extended the component interface javax.ejb.EnterpriseBean, viz. javax.ejb.SessionBean, javax.ejb.EntityBean, and javax.ejb.MessageDrivenBean.
2) EJB Object
When a client wants to use an instance of an enterprise bean class, the client never invokes the method directly on an actual bean instance. Rather, the invocation is intercepted by the EJB container and then delegated to the bean instance. By intercepting requests, the EJB container can provide middleware services implicitly. Thus, the EJB container acted as a layer of indirection between the client code and the bean. This layer of indirection manifested itself as a single network-aware object called the EJB object. The container would generate the implementation of javax.ejb.EJBObject or javax.ejb.EJBLocalObject, depending on whether the bean was local or remote, that is whether it supported local or remote clients, at deployment time.
3) Remote interface
A remote interface, written by the bean provider, consisted of all the methods that were made available to the remote client of the bean.These methods usually would be business methods that the bean provider wants the remote clients of the bean to use. Remote interfaces had to comply with special rules that EJB specification defined. For example, all remote interfaces must be derived from the javax.ejb.EJBObject interface. The EJB object interface consisted of a number of methods, and the container would implement them for you.
4) Local interface
The local interface, written by the bean provider, consisted of all the methods that were made available to the local clients of the bean. Akin to the remote interface, the local interface provided business methods that the local bean clients could call. The local interface provided an efficient mechanism to enable use of EJB objects within the Java Virtual MAchine, without incurring the overhead of RMI-IIOP. An enterprise bean that expected to be used by remote as well as local clients had to support both local and remote interfaces.
5) Home interface
Home interfaces defined methods for creating, destroying, and finding local or remote EJB objects. They acted as life cycle interfaces for the EJB objects. Each bean was supposed to have a corresponding home interface. All home interfaces had to extend standard interface javax.ejb.EJBHome or javax.ejb.EJBLocalHome, depending on whether the enterprise bean was local or remote. The container generated home objects implementing the methods of this interface at the time of deployment. Clients acquired references to the EJB objects via these home objects. Even though the container implemented home interfaces as home objects, an EJB developer was still required to follow certain rules pertaining to the life-cycle methods of a home interface. For instance, for each createXXX() method in the home interface, the enterprise bean class was required to have a corresponding ejbCreateXXX() method.
6) Deployment descriptor
To inform the container about your middleware needs, you as a bean provider were required to declare your component’ middleware needs - such as life-cycle management, transaction control, security services, and so on - in an XML-based deployment descriptor file. The container inspected the deployment descriptor and fulfilled the requirements laid out by you. The deployment descriptor thus played the key role in enabling implicit middleware services in the EJB framework.
7) Vendor-specific files
Since all EJB server vendors are different, they each have some proprietary value-added features. The EJB specification did not touch these features, such as how to configure load balancing, clustering, monitoring, and so on. Therefore, each EJB server vendor required you to include additional files specific to that vendor, such as a vendor specific XML or text-based deployment descriptor that the container would inspect to provide vendor-specific middleware services.
The Ejb-jar file
The Ejb-jar file, the packaging artifact, consisted of all the other implementation artifacts of your bean. Once you generated your bean classes, your home interfaces, your remote interfaces, and your deployment descriptor, you’d package them into an Ejb-jar file. It is this Ejb-jar file that you, as a bean provider, would pass around for deployment purpose to application assembles.
1) Try to ensure there is no duplicates or different versions of dependencies in a project, which will lead errors or conflicts later on.
2) If only want dependencies to exist during the compile phase and then be removed, the scope of such dependency should be set to PROVIDED. PROVIDED scope is not transitive, and the dependencies is supposed to be provided by JDK or container.
3) Use mvn dependency:tree to display the dependencies structure of the whole project, and try to pipeline the output to a file will be more easily to be observed.
4) If you are sitting behind a firewall, set proxy configurations in settings.xml under your .m2 directory.
More to be continued.
it’s common knowledge to use Runtime.getRuntime().exec(command) to execute any Unix command or Windows command in a Java application. However, when you try to include the pipe ‘|’ or redirect ‘>’ in the command to alter any output pattern, most of the time the Java will not interpret your command as expected which will turn out to be an error finally. For example, when I tried to run ffmpeg command to encode any video and would like to capture those outputs into a log file, an error of “Unable to find a suitable output format for ‘>’” will appear.
In order to make Java “understand” out purpose, you cannot directly insert the usual command into the exec() parameter. There is a workaround which will solve the issue.
Construct an array:
String[] commands = {
“/bin/sh”,
“-c”,
YOUR REAL COMMAND HERE
}
and pass the commands as argument to the Runtime.getRuntime().exec(commands). In this way, the Java environment will make a sh (YOU COULD USE BASH) environment to execute your command, which will take the pipe and redirect into consideration.



