Previously, in "Call CORBA service from Spring (Java)", how to call CORBA service using Spring function on Java 8 I introduced it, but this time I would like to introduce how to call the CORBA service using an alternative library in Java 11+ (Why CORBA in this era !?) Please don't ask w).
JDK
NOTE:
In this entry, the CORBA service is also created in Java ... In order to be able to acquire CORBA objects via the naming service, the function equivalent to orbd included in JDK 8 is also required. (If you want to get a CORBA object using an IOR string without using a naming service, you don't need a function equivalent to orbd). Since JDK 11 and later does not include the orbd command ... This entry uses JDK 8 only to use the orbd command ... (Completely compromised, but this entry focuses on the client side only. Please note that
Spring Boot
Roughly speaking, it seems that the ORB implementation used in GlassFish is being developed as an independent subproject of Eclipse EE 4J. From this library, not only the ORB implementation but also tools such as idlj and rmic are provided. This library is introduced as an alternative library in "JEP 320: Remove the Java EE and CORBA Modules". It has been.
It looks like JBoss is redistributing the OpenJDK 8 ORB implementation. Since the 1st release is 2015 ... Deprecated in JDK 9, it's unclear if it's related to the disappearance of modules in JDK 11.
Did JBoss disappear in OpenJDK 9? It seems to be a library that redistributes ORB related classes. Here, "[Call the CORBA service from Spring (Java)](https://qiita.com/kazuki43zoo/items/5eb4d57d785e0b3505fb#spring%E3%81%AE%E6%A9%9F%E8%83" % BD% E3% 82% 92% E4% BD% BF% E3% 81% A3% E3% 81% A6corba% E3% 82% B5% E3% 83% BC% E3% 83% 93% E3% 82% B9 % E3% 82% 92% E5% 91% BC% E3% 81% B3% E5% 87% BA% E3% 81% 97% E3% 81% A6% E3% 81% BF% E3% 82% 8B) " The " com.sun.jndi.cosnaming.CNCtxFactory
"used in is included.
"[Here](https://qiita.com/kazuki43zoo/items/5eb4d57d785e0b3505fb#java%E3%81%A7corba%E3%82%B5%E3%83%BC%E3%83%93%E3%82%B9" % E3% 82% 92% E4% BD% 9C% E3% 81% A3% E3% 81% A6% E3% 81% BF% E3% 82% 8B) ". Regarding the part that generates Java code from the IDL file, there is no idlj command in JDK 11+, so idlj provided by Eclipse ORB You can generate an equivalent class by using /corba/idlj/4.2.1/idlj-4.2.1.jar) (executable jar).
$ java -jar idlj-4.2.1.jar -fall -td src/main/java src/main/resources/Greeting.idl
Since there is no ORB implementation in JDK 11+, if you do nothing, you will not be able to find the required class and compile, so first of all ... you need to be able to use an alternative library.
pom.xml
<dependency>
<groupId>org.glassfish.corba</groupId>
<artifactId>glassfish-corba-orb</artifactId>
<version>4.2.1</version>
</dependency>
<dependency> <!--"Com" in Spring Boot.sun.jndi.cosnaming.To use "CNCTxFactory"-->
<groupId>org.jboss.openjdk-orb</groupId>
<artifactId>openjdk-orb-jdk9-supplement</artifactId>
<version>1.0.3.Final</version>
<exclusions>
<exclusion> <!--Excluded because the ORB implementation overlaps with the Eclipse ORB-->
<groupId>org.jboss.openjdk-orb</groupId>
<artifactId>openjdk-orb</artifactId>
</exclusion>
</exclusions>
</dependency>
pom.xml
<dependency>
<groupId>org.jboss.openjdk-orb</groupId>
<artifactId>openjdk-orb</artifactId>
<version>8.1.4.Final</version>
</dependency>
Publish the CORBA service when the ORB is available. For more information, see "[here](https://qiita.com/kazuki43zoo/items/5eb4d57d785e0b3505fb#java%E3%81%A7corba%E3%82%B5%E3%83%BC%E3%83%93%E3%82" % B9% E3% 82% 92% E5% 85% AC% E9% 96% 8B% E3% 81% 97% E3% 81% A6% E3% 81% BF% E3% 82% 8B) ". If the environment is such that the orbd command of JDK 8 is in the path, there is no need to modify the source code, but if the path is not in the path ... The following modifications are required.
List<String> orbdStartupCommands = new ArrayList<>();
// orbdStartupCommands.add("orbd");
orbdStartupCommands.add("/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/orbd"); //Specify the command with the full path
orbdStartupCommands.addAll(Arrays.asList(ORB_OPTIONS));
"[Here](https://qiita.com/kazuki43zoo/items/5eb4d57d785e0b3505fb#java%E3%81%8B%E3%82%89corba%E3%82%B5%E3%83%BC%E3%83%93" % E3% 82% B9% E3% 82% 92% E5% 91% BC% E3% 81% B3% E5% 87% BA% E3% 81% 97% E3% 81% A6% E3% 81% BF% E3 % 82% 8B) ”. There is nothing that needs to be fixed.
"[Here](https://qiita.com/kazuki43zoo/items/5eb4d57d785e0b3505fb#spring%E3%81%AE%E6%A9%9F%E8%83%BD%E3%82%92%E4%BD%BF % E3% 81% A3% E3% 81% A6corba% E3% 82% B5% E3% 83% BC% E3% 83% 93% E3% 82% B9% E3% 82% 92% E5% 91% BC% E3 % 81% B3% E5% 87% BA% E3% 81% 97% E3% 81% A6% E3% 81% BF% E3% 82% 8B) ". There is nothing that needs to be fixed.
Although it is not exactly the same as the content introduced in this entry, a demo application with the same content is published on GitHub.
CORBA's module disappeared in JDK 11, but I found that it can be used in the environment of JDK 11+ by using an alternative library. But ... can alternative libraries be used in commercial applications? When I checked the license, I was worried about the part
Eclipse ORB is ...
Homepage excerpt
Eclipse Distribution License 1.0 (BSD)
Eclipse Public License 2.0
one(Secondary) GNU General Public License, version 2 with the GNU Classpath Exception
JBoss repackaging of the OpenJDK ORB
From the license file
GNU General Public License, version 2 with the GNU Classpath Exception
So, as long as you add the jar file on the classpath and use it, it seems that you can use it even in non-OSS commercial applications that can not publish the source code.
Recommended Posts