Recent Posts
Archives

Posts Tagged ‘Java’

PostHeaderIcon org.springframework.beans.factory.xml.XmlBeanDefinitionReader: Ignored XML validation warning org.xml.sax.SAXParseException: SchemaLocation: schemaLocation value = … must have even number of URI’s

Context

Mule 2.2.1 ESB config file with a TibcoRV connector, under Windows XP SP2 and Java 5.
The error happened in this context, yet I assume it would occur in any occurence related to XSD / XML schemas.

Error

org.springframework.beans.factory.xml.XmlBeanDefinitionReader: Ignored XML validation warning
org.xml.sax.SAXParseException: SchemaLocation: schemaLocation value = 'http://www.mulesource.org/schema/mule/management/2.2                http://www.mulesource.org/schema/mule/management/2.2/mule-management.xsd                http://www.mulesource.org/schema/mule/core/2.2                http://www.mulesource.org/schema/mule/core/2.2/mule.xsd                http://www.springframework.org/schema/beans                http://www.springframework.org/schema/beans/spring-beans-2.5.xsd                http://www.mulesource.org/schema/mule/core/2.2/mule.xsd                http://www.mulesource.org/schema/mule/vm/2.2                http://www.mulesource.org/schema/mule/vm/2.2/mule-vm.xsd
http://www.mulesource.org/schema/mule/tibcorv/2.2                http://www.mulesource.org/schema/mule/tibcorv/2.2/mule-tibcorv.xsd' must have even number of URI's.

Headers of XML config file:

[xml]<mule xmlns=&amp;quot;http://www.mulesource.org/schema/mule/core/2.2&amp;quot;
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:management="http://www.mulesource.org/schema/mule/management/2.2"
xmlns:tibcorv="http://www.mulesource.org/schema/mule/tibcorv/2.2
xsi:schemaLocation="http://www.mulesource.org/schema/mule/management/2.2
http://www.mulesource.org/schema/mule/management/2.2/mule-management.xsd
http://www.mulesource.org/schema/mule/core/2.2
http://www.mulesource.org/schema/mule/core/2.2/mule.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.mulesource.org/schema/mule/core/2.2/mule.xsd
http://www.mulesource.org/schema/mule/vm/2.2
http://www.mulesource.org/schema/mule/vm/2.2/mule-vm.xsd
http://www.mulesource.org/schema/mule/tibcorv/2.2
http://www.mulesource.org/schema/mule/tibcorv/2.2/mule-tibcorv.xsd">[/xml]

Explanation – Fix

Each time, the attribute xsi:schemaLocation must have an even number of lines: a “public” XSD address and a “non-public” one. For non English-fluent speakers, I remind that a number is even if, and only if, it is a multiple of 2 ; otherwise it is odd.

In our case, one line is redundant. To fix this issue, you have to remove the redundant line, and ensure each line belongs to a consistent pair of lines: for instance:

http://www.mulesource.org/schema/mule/tibcorv/2.2
and
http://www.mulesource.org/schema/mule/tibcorv/2.2/mule-tibcorv.xsd

PostHeaderIcon Tibco RendezVous quick-start tutorial

When I was introduced to TIBCO Rendezvous (also spelled “Tibco Rendez-Vous” or, shorterly, “TiboRV”), I faced a embarrassing issue: the lack of documentation and tutorials on the web.

The purpose of this -short- tutorial is to guide you until you can send and read a “HelloWorld” message passing through Tibco RendezVous

Installation

  • Set the variable JAVA_HOME
    Eg, in my case:

    set JAVA_HOME=C:\exe\java\jdk150_10
  • Get the file to be installed:
    TIB_rv_8.1.2_win_x86_vc8.zip
  • Unzip the content in your local drive
  • Launch the installer (.exe)
    • select Custom installation
    • choose the installation folder, eg: C:\exe\tibco
    • keep default options for other requests
  • Set the variable TIBRV_HOME
    Eg, in my case:

    set TIBRV_HOME=C:\exe\tibco\tibrv\8.1

Main Runnables

RVD: Daemon

  • Launching the daemon on local host on port 8181 (default port: 7580):
    rvd -http 8181

    You should see the following trace:

    C:\exe\tibco\tibrv\8.1\bin>rvd -http 8181
    
    TIB/Rendezvous daemon
    Copyright 1994-2008 by TIBCO Software Inc.
    All rights reserved.
    
    Version 8.1.2 V8 9/26/2008
    2010-01-19 16:37:02 rvd: Command line: rvd -http 8181
    2010-01-19 16:37:02 rvd: Hostname: MYLOCALMACHINE
    2010-01-19 16:37:02 rvd: Hostname IP address: 123.123.123.123
    2010-01-19 16:37:02 rvd: Detected IP interface: 123.123.123.123 (IP00)
    2010-01-19 16:37:02 rvd: Detected IP interface: 127.0.0.1 (loopback)
    2010-01-19 16:37:02 rvd: Unable to find ticket file tibrv.tkt in PATH
    2010-01-19 16:37:02 rvd: Http interface - http://myLocalMachine.myDomain:8181/

tibrvsend: send a message

To send a message on myLocalMachine:7580:

.\tibrvsend.exe -service 7580 -network MYLOCALMACHINE mySubject myMessage

Expected output:

C:\exe\tibco\tibrv\8.1\bin>.\tibrvsend.exe -service 7580 -network MYLOCALMACHINE mySubject myMessage
Publishing: subject=mySubject "myMessage"
2010-01-19 16:52:11 RV: TIB/Rendezvous Error Not Handled by Process:
{ADV_CLASS="WARN" ADV_SOURCE="SYSTEM" ADV_NAME="LICENSE.EXPIRE" ADV_DESC="The license will expire" expiretime=2010-01-19 16:02:11Z host="10.30.226.147"}

tibrvlisten: listen to messages

Abstract

To listed to messages published on MYLOCALMACHINE:7580, related to subject mySubject:

tibrvlisten -service 7580 -network MYLOCALMACHINE mySubject

Use case: HelloWorld

For instance, let’s assume that you launch this command from one frame:

C:\exe\tibco\tibrv\8.1\bin>.\tibrvsend.exe -service 7580 -network localhost mySubject HelloWorld
Publishing: subject=mySubject "HelloWorld"

Here is what appears in the “listening” frame:

2010-01-19 17:01:32 (2010-01-19 16:01:32.990000000Z): subject=mySubject, message={DATA="HelloWorld"}

Notice you can have many instances listening to the same messages.

Other runnables

Launch the daemon manager

  • Launch:
    cd %TIBRV_HOME%/RVDM
    ./RVDM.bat -http 8282 .
  • You should see following messages, that you can ignore:
    2010-01-19 13:01:48 rvdm: RVDM has activated.
    2010-01-19 13:02:03 RV: TIB/Rendezvous Error Not Handled by Process:
    {ADV_CLASS="WARN" ADV_SOURCE="SYSTEM" ADV_NAME="LICENSE.EXPIRE" ADV_DESC="The license will expire" e
    xpiretime=2010-01-19 12:11:48Z host="123.123.123.123"}
  • To check the daemon is on, you can open the address http://localhost:8282 on your favorite browser.

Example sources

Example sources are available in folder %TIBRV_HOME%/src/examples/java

Misc

TIBRV_HOME\bin folder fosters a couple of binaries:

  • rvntscfg.exe: Services Configuration Program

PostHeaderIcon Servlet of class org.apache.catalina.servlets.CGIServlet is privileged and cannot be loaded by this web application

Case:

Under Windows / Tomcat 6:

[java]java.lang.SecurityException: Servlet of class org.apache.catalina.servlets.CGIServlet is privileged and cannot be loaded by this web application[/java]

Fix:

In the web.xml file, add the following block:

[xml]
<context-param>
<param-name>privileged</param-name>
<param-value>true</param-value>
</context-param>[/xml]

PostHeaderIcon JAXB2 in WebLogic 9.2

Case:

We need use JAXB2 packaged version, rather than the version which is provided within WebLogic 9.2.

Fix:

In the weblogic-application.xml, add the following block:

[xml]
<prefer-application-packages>
<package-name>javax.xml.bind.*</package-name>
</prefer-application-packages>
[/xml]

PostHeaderIcon Create a new project from Maven2 under Eclipse

Yeah, I know this must be widely known, yet I needed a short while before successing ;-).
Case: I must mount a Java projet from a Maven2 file, under Eclipse (I am back to my prefered IDE).

Fix:

  • Checkout the sources from version control tool
  • Open a console window
  • Go to the project home
  • (possibly: mvn install)
  • mvn eclipse:eclipse
  • Open Eclipse
  • File > New Project > add the name > check "create project from existing tool" > Finish

And it’s over!

PostHeaderIcon “Select for update” in Hibernate

Case:

You have to use an equivalent to “select for update” in Hibernate, for instance when you migrate en EJB entity to Hibernate.

Fix:

In your query, use the option LockMode.UPGRADE. For instance, you will have:

[java]sessionFactory.getCurrentSession().load(MyMappedClass.class, myPk, LockMode.UPGRADE);[/java]

PostHeaderIcon java.io.StreamCorruptedException: invalid type code: 31

Context:

Client-server communication over JMS.

Stacktrace:

[java]Caused by: java.rmi.UnmarshalException: failed to unmarshal class weblogic.security.acl.internal.AuthenticatedUser; nested exception is:
java.io.StreamCorruptedException: invalid type code: 31
at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:203)
at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:224)
at weblogic.common.internal.RMIBootServiceImpl_921_WLStub.authenticate(Unknown Source)
at weblogic.security.acl.internal.Security$1.run(Security.java:185)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
at weblogic.security.acl.internal.Security.authenticate(Security.java:181)
at weblogic.jndi.WLInitialContextFactoryDelegate.authenticateRemotely(WLInitialContextFactoryDelegate.java:726)
at weblogic.jndi.WLInitialContextFactoryDelegate.pushSubject(WLInitialContextFactoryDelegate.java:659)[/java]

Explanation – Fix

The client JVM was in version 1.6, the server was in 1.5.
To fix the issue, the client must be run with Java 1.5.
Possibly, the client may laucnh the JVM with the option -Dsun.lang.ClassLoader.allowArraySyntax=true.

PostHeaderIcon Spring using multi instances of JndiTemplate

Case

Spring application context file:

[xml]
&lt;bean id=&quot;jmsQueueConnectionFactory&quot;
class=&quot;org.springframework.jndi.JndiObjectFactoryBean&quot;&gt;
&lt;property name=&quot;jndiName&quot; value=&quot;jonathan.jms-connection-factory.external&quot;/&gt;
&lt;property name=&quot;jndiEnvironment&quot;&gt;
&lt;props&gt;
&lt;prop key=&quot;java.naming.factory.initial&quot;&gt;weblogic.jndi.WLInitialContextFactory&lt;/prop&gt;
&lt;prop key=&quot;java.naming.provider.url&quot;&gt;
t3://anOtherServer:8521
&lt;/prop&gt;
&lt;prop key=&quot;java.naming.security.principal&quot;&gt;jonathan&lt;/prop&gt;
&lt;prop key=&quot;java.naming.security.credentials&quot;&gt;jonathan&lt;/prop&gt;
&lt;prop key=&quot;weblogic.jndi.enableDefaultUser&quot;&gt;true&lt;/prop&gt;
&lt;/props&gt;
&lt;/property&gt;
&lt;/bean&gt;
&lt;bean id=&quot;mainJndiTemplate&quot; class=&quot;org.springframework.jndi.JndiTemplate&quot;&gt;
&lt;property name=&quot;environment&quot;&gt;
&lt;props&gt;
&lt;prop key=&quot;java.naming.factory.initial&quot;&gt;weblogic.jndi.WLInitialContextFactory&lt;/prop&gt;
&lt;prop key=&quot;java.naming.provider.url&quot;&gt;t3://mainServer:1234&lt;/prop&gt;
&lt;prop key=&quot;java.naming.security.principal&quot;&gt;myPrincipal&lt;/prop&gt;
&lt;prop key=&quot;java.naming.security.credentials&quot;&gt;myPassword&lt;/prop&gt;
&lt;prop key=&quot;weblogic.jndi.enableDefaultUser&quot;&gt;false&lt;/prop&gt;
&lt;/props&gt;
&lt;/property&gt;
&lt;/bean&gt;
[/xml]

Description

I use two instances of JndiTemplate to send JMS messages on two different queues, on two different Weblogic domains, using two different Ldap directories. When I try to send messages on the second server, it does not work: I get an error because the second server receives credentials that should be sent to the first server.

[Security:090398]Invalid Subject: principals=[...]

Quick fix

Remove the properties weblogic.jndi.enableDefaultUser from within the XML.

PostHeaderIcon Short Tutorial: Migration from EJB Entity to Hibernate

Case

  • let’s consider an EJB Bean AnimalBean, linked to a table JL_Animal
  • let’s have a human understandable name for the Pojo, let’s say: Animal
  • let an EJB entity have following finders:

[java]
* @ejb.finder
* signature = "Collection findByBirthDate(java.lang.Integer birthDate)"
* query = "SELECT OBJECT(o) FROM AnimalBean AS o WHERE o.birthDate = ?1"
*
* @ejb.finder
* signature = "Collection findByCountryAndBirthDate(java.lang.String from,java.lang.Integer birthDate)"
* query = "SELECT OBJECT(o) FROM AnimalBean AS o WHERE o.country = ?1 AND o.birthDate = ?2"[/java]

Read the rest of this entry »

PostHeaderIcon Default method on interface implementing

Abstract:

Developpers happen to forget to implement concrete classes on creating new implementations. Indeed, IDEs fill methods content with canonical return values, (null for object, 0 for numerics, etc.). Consequently, errors appear only on deployment stage, when it is not on running.

To avoid this, here is the tip I use: raising a default exception. If unit tests are generated, then the exception is raised on development stage, which is better than after one hour compiling / deployment / execution ;-).

Process:

On IntelliJ IDEA, open:

  • Project Settings
    • File Templates
      • Code
        • Implemented Method Body
        • write: throw new UnsupportedOperationException("Class Name : ${CLASS_NAME} - Method Name : ${METHOD_NAME}");