Scheduled Task executing bean with Execute works but Activating gives No such bean named '...'

I have a JMX managed bean I created and installed into the Scheduled Task screen. It works fine when I press the Execute button on Scheduled Task (halts in the debugger, executes, etc.).

However, when I click the Activate button, I get an error:

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named ‘merges_GmailSync’ available

How can it work when I manually execute with Execute button but not work with Activate?

This is weird. Try to debug the com.haulmont.cuba.core.app.scheduling.RunnerBean#runTask(ScheduledTask, long, boolean, UserSession) method, it should be invoked in both cases.

I think I’ve found the problem. I am debugging on my local machine but I deploy on another computer. My core URL is set to the OTHER machine, which does not have an implementation yet. So, the URL for the bean is incorrect and can’t be accessed.

Duh.

So, something still isn’t correct. I am now executing on the correct server and debugging remotely. I can still do a single execute remotely, although I don’t know why, as the URL listed on the screen is WRONG!

image

The bottom line, where I executed manually, did work - but it has the wrong port. I am running a single-war UberJar on port 8090:

image

How am I reaching it with merges:8080/merges-core???

Worse yet, WHERE is it getting merges:8080/rentals-core for the scheduled execution?? (rentals is another UberJar app running on my server – it is on port 8080).

image

I have an Nginx server running on port 80 that is redirecting traffic:

location /merges {
  proxy_pass http://localhost:8090;
}
location /rentals {
  proxy_pass http://localhost:8080;
}

Everything else works perfectly, as far as I know. I did notice that the serverInfo JMX bean was returning “merge03:8080/merges-core”, so I added cuba.webPort = 8090 to my Uberjar configuration. The JMX Bean now returns the correct value, but it did not fix the issue.

I have also tried debugging by setting the breakpoint in your RunnerBean, but IT DOES NOT HALT. Seems to me that it is somehow communicating with the wrong core? That is what the URL indicates, but how does that happen?

First of all, please check that you have set up the app properties used to identify servers properly: Server ID.

Also, do you have cuba.cluster.enabled = true?

Server ID is now set properly.

Everything else works perfectly, as far as I know. I did notice that the serverInfo JMX bean was returning “merge03:8080/merges-core”, so I added cuba.webPort = 8090 to my Uberjar configuration. The JMX Bean now returns the correct value, but it did not fix the issue.

Am I running a cluster? I have two different Cuba apps, each with one core in an UberJar, running on the same server. I do not want any communication between them, so I did not set cuba.cluster.enabled=true. Is that wrong?

Also, I wonder if it’s an issue in SYS_SERVER table? Here are my entries:

image

When I debug on my local PC, the localhost servers are active. Even though I don’t have any running right now, IS_RUNNING = ‘1’.

Plus, there are what appear to be garbage entries. Does this table get cleaned up when an UberJar is killed? Should I be removing entries manually?

Would I be better off if they all said “localhost”, (removing my deployment settings) since it is only communicating on the one server it runs on?

image

Originally, my apps were deployed on a Tomcat server. I needed these settings on that server in order to make the app run. Could these be confusing my UberJar deployments?

This is correct, you don’t need cluster. I asked to make sure you didn’t turn it on accidentally.

This is normal, because your server could stop abnormally. In fact, the SYS_SERVER table data is not used in any platform mechanisms and is updated only for reference. I.e. it doesn’t affect anything.

Ok. I had tried turning it on but it did not help. I will turn it back off.

Another thing to note is that the two apps share the same login, so they are sharing their system tables. This is because they share app tables (orders, customers, etc.).

Could this be the issue? If not, where else can I look?

If several apps work with the same database, they obviously share the schedulers. So you create a scheduler in one app, and the other app can immediately try to execute it.
You can try to separate schedulers using the Permitted servers attribute, see the docs.

Another piece of the puzzle that I missed. Set:

cuba.schedulingActive = true

in the app.properties of the core module. Even with that turned on, my bean is not running.

JMX shows that Scheduling is now active.

image

ServerId is:

image

Task is:

image

Task is Activated:

image

Execution history is still empty:

image

Deactivate and run manually:

image

image

Now it has executed.

What else am I missing?

Hi,

I can guess from my past experience: you may have problems with time synchronization.

If ScheduledTask#lastStartTime attribute is in the future (because of bad time on one of servers that was connected to the database) - then scheduled task won’t start by schedule.

You can view all attributes of ScheduledTask in the entity inspector screen.

You can also set logging level to TRACE for this category:
com.haulmont.cuba.core.app.scheduling.Scheduling
and change level for one of appenders to TRACE to view super-detailed messages and avoid debugging code on remote server.

Thanks but not sure how that can be. ServerID is localhost. In any event, I am going to try turning on tracing and see what I can find.