0

Originally, I was trying to tie together Oracle Database (21c) with RabbitMQ, to enable more efficient microservice communication between the database and a Docker environment (Swarm mode). I found this Java application. It works, but it doesn't work every time as I get an "Uncaught Java-exception". I couldn't figure out why, and the project seems to be abandoned(?), at least no commit has been made in almost 10 years. There are also unanswered issues. Anyway, I decided to try to learn some Java, and write my own program. I did, and running the app from the command line it behaves as expected (publishes "Hello World!" to a RabbitMQ queue). Great, then I load the app into the database like so:

loadjava -v -synonym -u user/pass@hostpdb -resolve -resolver "((* schema) (* PUBLIC) (* -))" target\AMQPforOracle-0.0.1.jar

It loads without errors. I find the class:


my/org/app/Publish  JAVA CLASS  VALID

I then create the function:

create or replace function amqp_test_send 
return number
as language java
name 'my.org.app.Publish() return java.lang.Int';

With:

select object_name,object_type,status from user_objects where object_type LIKE 'JAVA%' and object_name like '%Publish';

I get this error:

ORA-29540: klassen my/org/app finnes ikke (Norwegian, translates to: class ... not found)

I have made sure the schema and user is correct.

Mind you, the original app i found on github does not produce this error, so I am doing something wrong, I am just not sure what. Why does it refer to my/org/app, when my/org/app/Publish should be the class? Is it something in my POM?:

<project>
    <modelVersion>4.0.0</modelVersion>
   
    <groupId>my.org.app</groupId>
    <artifactId>oradb-amqp</artifactId>
    <version>0.1</version>
  
    <dependencies>
      <dependency>
        <groupId>com.rabbitmq</groupId>
        <artifactId>amqp-client</artifactId>
        <version>5.14.2</version>
      </dependency>

      <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
      </dependency>
    </dependencies>
  
    <properties>
      <maven.compiler.source>1.8</maven.compiler.source>
      <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <build>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-shade-plugin</artifactId>
          <version>3.2.4</version>
          <executions>
            <execution>
              <phase>package</phase>
              <goals>
                <goal>shade</goal>
              </goals>
              <configuration>
                 <transformers>
                  <transformer
                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                    <mainClass>my.org.app.Publish</mainClass>
                  </transformer>
                </transformers>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>

  
  </project>

Any hints would be greatly appreciated!

Dan
  • 3,647
  • 5
  • 20
  • 26
rbl9069
  • 23
  • 1
  • 5
  • 2
    I don't know if this will fix your issue, but your Java call specification `'my.org.app.Publish() return java.lang.Int'` is referring to a non-existent Java class. It should be [`java.lang.Integer`](https://cr.openjdk.java.net/~iris/se/17/latestSpec/api/java.base/java/lang/Integer.html). You may be mixing up the Java primitive data type `int` with the class `Integer`. I assume Oracle needs a class here, not a primitive. See also [What is the difference between Integer and int in Java?](https://stackoverflow.com/questions/8660691/what-is-the-difference-between-integer-and-int-in-java) – andrewJames May 28 '22 at 13:59
  • 1
    Secondly, (and possibly just a naming convention issue, not actually an error): Java class names typically start with an upper-case letter, while method names start with a lowercase letter - so if I have understood it correctly, I would expect to see `my.org.App.publish()` - and this also assumes your class is in a package called `my.org`. – andrewJames May 28 '22 at 14:10
  • Thanks for your suggestions! The 'Int' to 'Integer' didn't change anything, but I suspect there is something about the naming of classes and methods that are causing confusion here. I will look into that. – rbl9069 May 28 '22 at 14:29

0 Answers0