Oracle Service Bus Java - oracle

I have an EJB which has as input argument and return value a JAXB mapped complex structure (with subclasses etc).
Now I want to deploy this on the Oracle Service Bus 11g. I can create a business proxy invoking the EJB, but only with basic types (int, ...).
How do i tunnel the XML between EJB and OSB? Any advanced OSB information is appreciated, as I don't know much about it.

After playing around, it turns out the OSB supports (afaik only) Apache XMLBeans. Thus if you declare parameters and return values of type org.apache.xmlbeans.XmlObject it works. I did get some errors concerning DOM v3 not being implemented and some crashes in the oracle DOM implementation, so I just use the XmlObject to create an XML string, and the reparse it.
#Euclides: I have XMLObject and XmlObject in my classpath. I need the second (lower case). Thanks for the hint, anyway.

Related

Spring boot jpa entity table name from property file

We are working on a spring boot library to generate and validate OTP. It uses database to store the OTP.
We are using Spring Data JPA for Database operations, as it will be easy to handle multiple database systems according to the project.
Now we have ran in to a problem, most of our projects uses Oracle with a single database.
When using the the same lib in multiple projects there is a name conflict.
So we want the name of the OTP table to be configurable using a property file.
We tried #Table(name = "${otp-table-name}") But its not working.
We did a lots of research and found out the hibernate naming strategy configuration can help.
But we dont want to use lots of configuration in our library as we need the library to be easily usable in the projects.
Can someone help us on this aspect.
Thanks in advance.
You can dynamically determine the actual DataSource based on the current context, use Spring's AbstractRoutingDataSource class. You could write your own version of this class and configure it to use a different data source based on the property file.
This allows you to switch between databases or schema without having to change the code in your library.
See: https://www.baeldung.com/spring-abstract-routing-data-source
Using a NamingStrategy is good approach.
You could let it delegate to an existing NamingStrategy and add a prefix.
Use a library specific default for the prefix, but also allow users of your library specify an alternative prefix.
This way your library can be used without extra configuration, but can also handle the case of multiple applications using it in the same database schema.
Of course this might involve the risk of someone using the default prefix without realizing that, that is already used.
It is not clear what the consequences of that scenario are.
If the consequences are really bad you should drop the default value and require that a project specific prefix is used.
When no prefix is specified throw an exception with an instructional error message telling the user, i.e. the developer how to pick a prefix and where to put it.

Is Spring Data Jdbc recommended for Oracle 18c?

Is Spring Data JDBC v1.1.5 recommended for Oracle Database and Enterprise Applications? Lot of samples around the net based on Open Source RDBMS (H2 or PostgreSQL). We are using Spring Data JDBC in a Spring Boot Microservice Application, facing following problems.
Force to write custom converters for oracle.sql.TIMESTAMP, oracle.sql.TIMESTAMPTZ and oracle.sql.DATE and oracle.sql.ROWID etc..
Can't type cast oracle.sql.ROWID to java.lang.Number
Identity must not be null after save.
Spring Data JDBC is absolutely recommended for Enterprise Applications.
Not so much for use with Oracle.
Since the necessary resources (database & JDBC driver) weren't available in a form that could be easily used in integration tests on public platforms, Oracle isn't included in regular builds.
Therefore it is likely that one encounters issues when working with Oracle.
Some are already known, for others issues in Jira or even PRs are highly appreciated.

Easiest Way to Access Neo4J from Java

I want to access a Neo4j DB with Java and wanted to know what the preferred way to do this is. I just want to write a quite simple data structure to the DB.
http://neo4j.com/developer/java/ gives following options:
JDBC
Hibernate OGM
Spring Data
Rest API via Unmanaged Extensions
I looked into accessing Neo4J with JDBC and Hibernate OGM. It seems that its not worth it to use for me. JDBC gives me some trouble. So should i go with the REST way or try to fix my JDBC problems?
The JDBC driver is really a wrapper around the REST interface (as of neo4j 2.3). There is a example application how to use it. Should suffice for very simple use.
Then there is neo4j-ogm (different from Hibernate OGM) - this is an object graph mapping library, similar to hibernate in ORM world. This has minimal external dependencies and is very easy to use - ideal for cases where you want to map couple of objects into graph.
Then there is the Spring Data Neo4j project, which since version 4 uses neo4j-ogm for mapping, but adds other Spring data features, like repositories, derived finder queries, transactions ...

What is the role of JavaEE jar in Oracle java stored procedure in 11g when using MQ

I need to write an Oracle Java Stored Procedure to write messages to MQ using the stored procedure. I followed the directions from this link and it worked. According to the link, it requires JavaEE api jar to be loaded into the database.
But now I have questions about the role of JavaEE Jar in an Oracle Java Stored procedure. From what I have read, these jars contain only interfaces, no implementations
What role does JavaEE jar play in an Oracle Java Stored Procedure?
If it doesn't have implementaion details, where does it get it from at runtime?
I have been able to write simple Java Stored Procedures without use of these jars, so what are the situations that require use of this jar?
It contains the interfaces for services like EJB, JMS, Resource managers, JDBC (javax.sql), transactions etc. This is to ensure that applications using theses interfaces can be installed in different application servers. It's up to the application server provider to write implementations, but these are not directly needed in a client application.
To get a connection for example, you need to lookup a factory using a naming service. The result from the lookup must be cast to an interface (as the naming service returns Objects). As a result you deal with the interface, but of course there is a vendor specific class in the background which implements it.
If you call Java stored procedures from your JDBC client, the database could be considered to be an application server as well. So in theory anything you do in a Java application server could be done in a stored procedure as well: It's JMS, and possibly transactions services, or calls to other EJB servers. But that's not common practice, and I am not aware of any limitations.

Reading from xml file and populating H2 DB table through Apache ServiceMix 4.2.2

I am trying to integrate a simple Enterprise App to a data source(xml file for now) using Apache Service Mix(ASM) ESB. Basically I need to have the ESB pick up content from the xml file and populate corresponding tables in a H2 database(which my app is linked to). I am not sure as to which features of ASM I should be using for the same. If someone could give me a high level idea as to how I should be going about the same I would be very grateful. I have looked at documentation from Fuse ESB and also the ASM documentation but at this point I am totally confused.
Thanks in advance.
Since ServiceMix uses Camel for such work, my first suggestion is to take a look at Apache Camel for it.
For you're example a simple route would look like this:
from("file:location_of_file").unmarshal(registered-jaxB-structure)
.split(simple("probably_your_entities")).to("jdbc:dataSource?sql_insert");
You read your incoming file from the *location_of_file* unmarshall it since it's a XML file to your object-structure with jaxb. After that you probably need to iterate over the entities inside your xml file which is best be done with a split. Now your structure is most likely in a way you can use either for storing with jpa, sql or jdbc.

Resources