synyx / springboot-reactjs-demo

A simple demo app to demonstrate server side rendering with nashorn
Apache License 2.0
18 stars 11 forks source link

Problem with java method invocation. #2

Open serpentcross opened 7 years ago

serpentcross commented 7 years ago

Hello!

Sorry for bothering you again, but I think this is the last issue I'm disturbing you =)))

I'm unable to invoke any Java method from JavaScript, using your isomorphic application.

In general it must be like this:

var MyJavaClass = Java.type('my.package.MyJavaClass');
var greetingResult = MyJavaClass.sayHello('John Doe');
print(greetingResult);

But when I'm implementing something like this, I'm getting an error:

Uncaught ReferenceError: Java is not defined at Object.<anonymous> (bundle.js:10401) at __webpack_require__ (bundle.js:20) at Object.<anonymous> (bundle.js:10596) at Object.module.exports.bPageLine (bundle.js:10616) at __webpack_require__ (bundle.js:20) at module.exports (bundle.js:66) at bundle.js:69

What should I do? =((

p.s.

I mentioned one interesting thing. If you purposely provide a wrong java class name, like this: var MyJavaClass = Java.type('my.package.MyJava**Calss**');

compiler will throw an error like: java error: Class my.package.MyJavaCalss' not found!

Many thanks you in advance!!!

serpentcross commented 7 years ago

UPD:

Looks like I found one possible solution =) I'll try to implement it, and if it works, I'll close the issue soon.

Sorry for disturbance =)))

serpentcross commented 7 years ago

No. Still doesn't work =( Please help if it's possible!

Thank you!