Archive for the ‘en-US’ Category
GWT to GXT migration
These days, I am discovering GWT, and more accurately ExtGWT, aka GXT.
Case
I have to write a “Hello World” application based on GXT.
Steps
- Firstly, follow Lars Vogel’s tutorial to have a “Hello World” in GWT.
- In Eclipse, add a dependancy from your project to
extjs-gxt-lib-2.1.1.jar(version compatible with your GWT version: 1.7 or 2.0), available at this link. - In your
*.gwt.xmlfile, remove:
[xml]<inherits name=’com.google.gwt.user.theme.standard.Standard’/>[/xml]and add:
[xml]<inherits name=’com.extjs.gxt.ui.GXT’/>[/xml]
- Get the gxt-all.css file, copy it into
war/css/folder - In your
*.htmlfile, add the lines:
[xml]<link rel="stylesheet" type="text/css" href="css/gxt-all.css" />[/xml] - Now, adapt your Java entry point source class, replacing GWT widgets with GXT ones.
- Restart your server and refresh the page in your browser. You have your “Hello World” in GXT!
This RJVM has already been shutdown
Error
Could not connect to remote service [ejb.services.myEjb]; nested exception is java.rmi.ConnectException: This RJVM has already been shutdown 4967659282374941940S:myServer:[7404,7404,-1,-1,-1,-1,-1]:myDomain:myEjbInstance
Explanation
Your EJB instance tries to lookup for a remote instance which seems to be shutdown. There may be many causes: IP / hostname resolution failed, remote servers are actually unreachables (such in the case of network issues), etc. Another potential issue may come from a bug in cluster management by WebLogic. Such a bug was identified and fixed by BEA with version 8 release ; yet, the bug may have kept on occuring on later version (9.2 in my case).
In my current case, the issue was that webservices, theorically deployed in the same WebLogic, were not started. Once the web services started, the issue vanished.
Maven: resume build from a module
Case
Your have a multi-module project. For any reason, the build fails on your 32nd project (out of 70).
You indentify the issue, fix it, and need rebuild your project. Yet, you don’t want to rebuild the 31 first projects. Rather, you prefer to start on the 32nd one.
On older version of Maven, you had to edit your pom.xml, comment the 31 projects, launch the build and uncomment the projects.
Fix
From Maven 2.1, a new option is available: -rf or —resume-from. Thanks to this option, you can hint to Maven to restart the build at any point you like.
ServletAuthentication.AUTHENTICATED
Case
You have this code
[java]ServletAuthentication servletAuthentication = new ServletAuthentication(LOGIN_USERNAME_LABEL, LOGIN_PASSWORD_LABEL);
Integer answer = servletAuthentication.weak(request, response);[/java]
But you always get FAILED_AUTHENTICATION as answer, while you expect to receive AUTHENTICATED.
Fix
In WebLogic configuration, set the control flag for Custom Authentication Provider and Default Weblogic Authentication Provider at SUFFICIENT.
Mule: File transport reads many times the same file
Case
With Mule ESB 2.2.1, I use a classic <file:inbound-endpoint>:
[xml]<file:inbound-endpoint path="${fromPath}"
pollingFrequency="3000" fileAge="5000"
moveToDirectory="${moveToDirectory}"
synchronous="true"
>
<transformers>
<transformer ref="mySimpleCSVParser">
</transformers>
</file:inbound-endpoint>
[/xml]
When I launch the Mule with no component (entreprise layer), everything is OK: the file is loaded, parsed and moved. But when I introduce a minimal component, which does nothing, then the file is read many times. Mule ESB seems to loop indefinitely, reading the file many times, without deleting it from the directory.
[java]INFO 2010-03-04 15:47:18,291 [connector.file.0.receiver.6] org.mule.transport.file.FileMessageReceiver: Lock obtained on file: C:\temp\myFile.txt[/java]
Fix
Firstly I tried to increase the pollingFrequency attribute, assuming that the file had not yet been completely parsed when another cycle of “load-parse-move”. But it did not fix the issue.
Indeed, the problem was not related to the component layer, but to the parser itself. To fix the issue, you have to ensure the InputStream is properly closed in your Transformer layer:
[java]try
{
inputStream.close();
return answer;
} catch (IOException e)
{
throw new TransformerException((Message)null, e);
}[/java]
Get a field of a bean in Spring
Case
I have to instanciate an object of type FooDao. The only constructor available is FooDao(Connection connection).
On another hand, I have a bean of type BasicDataSource. From this BasicDataSource, I can get a Connection, through the call of BasicDataSource.getConnection().
Question: how to instanciate a bean of type FooDao in Spring?
Solution
The idea, to retrieve a field member of a bean, is to use the attributes factory-bean and factory-method, from which we will get a new bean.
Use the following Spring context file:
[xml]
<bean id="myBasicDataSource" class="org.apache.commons.dbcp.BasicDataSource">
<!– complete … –>
</bean>
<bean id="connection" factory-bean="myBasicDataSource" factory-method="getConnection"
scope="singleton"/>
<bean id="myFooDao" class="com.my.company.FooDao">
<constructor-arg ref="connection"/>
</bean>
[/xml]
Many thanks to David Chau from SFEIR for his help in this issue!
EhCache integration within Spring
Case
You have to use a EhCache in a couple of beans, instancied via Spring.
Fix
In your main Spring configuration file, declare the following block:
[xml]
<bean id="customCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
<property name="shared" value="false" />
<property name="cacheManager">
<bean class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath*:ehcache.xml" />
</bean>
</property>
<property name="cacheName" value="SampleConfigOne" />
</bean>
[/xml]
Then, in any of your beans, declare the following property:
[xml]<property name="cache" value="customCache"/>[/xml]
Unit Test output redirection onto the console, with Maven 2
Case
You have to build your project. All tests are OK when you run them in your IDE, but one or more unit tests fail when you launch the build with Maven 2. When this happens, you have to open the SureFire tests reports to read the failures details.
But you’d rather read the failure in the standard output. In other terms, you would like the output to be redirected onto the console, and not in log files.
Fix
When you launch the build, specify the following option:
-Dsurefire.useFile=false
Change settings.xml location
Case
You have to use a custom-set settings.xml file, rather the default one.
By default, settings.xml is assumed to be in one the two following folders:
$M2_HOME/conf/settings.xml
$HOME/.m2/settings.xml
Fix
Use the -s option, for instance:
mvn install -s /path/to/file/otherSettings.xml
WebLogic 10.x new features
Recent history
BEA WebLogic 9.0, 9.1 and 9.2 were released from 2007: the main features were: a new console, WLST (WebLogic ScriptingTool), deployment plans, WebLogic Diagnostic Framework (WLDF), new security providers (RDBMS, SAML 1.1, etc.), JMS performance improvements, support of Java EE 4, JDK 5, Spring, OpenJPA, Kodo, etc.
Since this date, some events happened:
- Oracle bought Sun (2009)
- Oracle released WebLogic 10.3 (2008)
- Oracle bought BEA (2008)
WebLogic Server 10 General Features
- Developer productivity ehancements
- JDK 6, Java EE 5
- Support of
EJB3 andJPA - BEA enhancements
- Web Services: more annotations, less XML
JAX-RPCWeb Services EnhancementsJAX-WS2.0 Web Services Implementation
- Misc:
- Better administration console
- Auto-Record of Admin Console actions as WLST scripts
- Automatic JTA Transaction Recovery Service (TRS) migration
- SNMP 3.0
- Production Application Redeployment enhancements
- Clustering – Unicast messaging (in addition to Multicast)
Programmer Perspective
- New persistence engine: TopLink
- OEPE (Oracle Entreprise Pack for Eclipse): sequence of tools and plugins for Eclipse: remote deployment, debugging, editors for
weblogic.xmlandweblogic-application.xml, wizards, facets, Weblogic ClientGen,WSDLCandJAXBwizards - Optimizations for
Springintegration and certication - Web 2.0:
- Ajax / Dojo client support
- Http publish / submit engine for collaborative applications:
- Bayeux protocol
- data exchange within applications over persistent connections
- scalability for Dojo clients
- Ad-hoc tools for:
- Oracle Database
Spring- JAX-WS webservices
Lightweight WebLogic Server
WebLogic 10 offers a light weight server:
- Install only “core” WebLogic server
- Optionally, startup other services (
,JDBCEJB,JMS, etc.) - FastSwap: modify classes without requiring redeployment.
Architect Perspective
Architects have to consider WebLogic as a complete suite, and not only WebLogic Server:
- Oracle RAC integration: Connectivity to RAC with load balancing, failover, transactions
- Enterprise Messaging with
JMS: High performance and reliableJMSmessaging engine “built-in” - ActiveCache with Coherence*Web and
EJB/JPA: Coherence Data Grid caching included and integrated - Operations Automation: Tools for automating management of applications and servers
- Operations Insight: Tools for diagnosing problems in development and production
- Other features
- Development tools: Choice of tools for developer productivity
- Web Services: Enterprise Web Services for SOA
- TopLink: Persist application data to stores with performance and productivity. It works in a way similar to Hibernate L2 cache.
Spring: Enable flexible choice of dev frameworks with same WebLogic QOS
Production and Support Perspective
WebLogic 10 provides a tool: JRockit Mission Control
- monitors more than 150 parameters:
- CPU
- memory
- leaks
- latency spikes
- threads
- object references
connectionsJDBCJMS- pools
- clusters
- configuration files
- etc.
- allows to compare WebLogic domains
- Runtime Analyzer: runtime capture for offline analysis, Garbage Collector analysis, etc.
Coherence – ActiveCache
Coherence is the Data Grid offered by Oracle. It allows to store Java objects in memory, and share them between all instances. From a certain viewpoint, Coherence looks like the GigaSpaces.
Roadmap for Future WebLogic Releases
- Support of Java EE 6 (ratified by the community in last December)
OSGideployment- More native integration for WebLogic Server – Coherence – Oracle Database
- JRockit Flight Recorder for constant record
- Virtualization
- More integration with Maven, Hudson and Cruise Control
- Shared Library: use the same
JARfor many applications, rather than packing the sameJARin differentEARs. - On long term:
- IDE
- NetBeans to be oriented onto J2ME development
- JDevelopper to remain Oracle strategic IDE
- Contributions to Eclipse to go on
- JRockit and Sun HotSpot JVMs to be merged.
- IDE