Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6147545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:07:17+00:00 2026-05-23T19:07:17+00:00

I have a web app that is using Bayeux to handle Comet connections. I

  • 0

I have a web app that is using Bayeux to handle Comet connections. I initialize a BayeuxServer and tie it into Spring annotations and it all works fine, listening on selected channels and responding.

I have a Jersey annotated class and an annotated Bayeux service as shown below. The idea is I wanted to be able to control resources via Rest from an individual web app, and then right after the resource is changed, do a server push via Comet to all other applicable clients to tell them to update their information.

Here is the problem: A Bayeux Service is created when the webapp is deployed, setting up proper channels to listen on and monitoring clients. There should only be one instance of this. When Jersey attempts to use the Bayeux service it creates a whole new service, when it should be using the original one. This new service doesn’t have the BayeuxServer properly injected so I can’t access client information through it.

It makes since that this should be doable, but I don’t seem to understand how to inject these things properly via annotations. Can anyone point me in the right direction?

Jersey Annotated Class:

@Path("JsonTest")
public class JsonTest {

@Context
Request request;
@Context
UriInfo uriInfo;

@Context
ResourceContext resourceContext;

protected final Logger log = Logger.getLogger(getClass());

public JsonTest() {

}

@DELETE
@Path("{id}")
public void deleteJson(@PathParam("id") String id) {
    JsonTestDao.instance.getModel().remove(id);
    log.info("Deleted Json..." + id);
    log.info("New json: " + JsonTestDao.instance.getModel().toString());


    JsonTestService jsonTestService = resourceContext.getResource(JsonTestService.class);
    jsonTestService.sendUpdate();
}
}

BayeuxService:

@Named
// Singleton here didn't seem to make a difference
@Service
public class JsonTestService {

protected final Logger log = Logger.getLogger(getClass());

@Inject
private BayeuxServer bayeux;
@Session
private ServerSession serverSession;

@PostConstruct
public void init() {
    log.info("Initializing JsonTest Bayeux HelloService...");
    log.info("Current sessions are: " + bayeux.getSessions().toString());
}

@Listener("/cometd/JsonTest")
public void jsonTestHandler(ServerSession remote, ServerMessage.Mutable message) {

}

public void sendUpdate() {
    //bayeux.newMessage(); // Need a method that the Jersey class can call to notify changes
    log.info("Bayeux server should be sending an update now...");
}

@PreDestroy
public void destroy() {
    log.info("Destroying JsonTest Bayeux HelloService...");
}

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:07:18+00:00Added an answer on May 23, 2026 at 7:07 pm

    See Jersey and spring integration – bean Injections are null at runtime.

    Another question I asked. Both of these stem from the same problem involving properly setting the Jersey dependency and integrating it with spring.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have configured in following way that spring MVC app using Spring 3.1.1.RELEASE web.xml
I have a web app that uses Spring's Log4jConfigurer class to initialize my Log4J
I have an ASP.NET 4 Web Forms app that is using URL Routing. I
I have a Java web app running on Tomcat 7 that is using JDBC
I have a web app that is using the 3.5 framework. I wanted to
I have a web app that I am deploying to Tomcat 7.0 using Eclipse
Using Visual Studio 2008 and VB.Net: I have a working web app that uses
I have a web app that is using ActiveResource to talk to another server
I have a web app that allows people to register directly or by using
I currently have a web app that is built using Play framework (1.2.4) with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.