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 8177935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:38:41+00:00 2026-06-06T23:38:41+00:00

My Java EE app uses crawler4j which starts the crawl using the following code:

  • 0

My Java EE app uses crawler4j which starts the crawl using the following code:

CrawlConfig config = new CrawlConfig();
config.setCrawlStorageFolder("C:/crawler4j_storage");
PageFetcher pageFetcher = new PageFetcher(config);
RobotstxtConfig robotstxtConfig = new RobotstxtConfig();
RobotstxtServer robotstxtServer = new RobotstxtServer(robotstxtConfig, pageFetcher);
CrawlController controller = new CrawlController(config, pageFetcher, robotstxtServer);

controller.start(Crawler.class, 1);

The EJB is injected in Crawler.class:

@Stateless
@LocalBean
public class Crawler extends WebCrawler {

    @Inject private SeedFacadeLocal seedEJB;

    public void doSomething () {
        seedEJB.findAll(); // gives the NullPointerException
    }

My guess is that it has something to do with the way Crawler.class is passed as a argument. SeedFacadeLocal is a @Local bean interface which has a @Stateless bean implementation. I inject this bean at numerous other places and it works fine.

I think that by starting the crawl with “controller.start(Crawler.class, 1)” results in Crawler.class being a POJO instead of a EJB. Therefor annotations in Crawler.class are ignored.

  • 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-06-06T23:38:44+00:00Added an answer on June 6, 2026 at 11:38 pm

    CrawlController creates instances of crawlers with a simple newInstance call:

    http://code.google.com/p/crawler4j/source/browse/src/main/java/edu/uci/ics/crawler4j/crawler/CrawlController.java#149

    That won’t do any sort of injection, so your crawler’s injected fields will be null.

    If you want to use an injected crawler, then you will need to take control of the way that the CrawlController creates crawlers. However, there is no obvious way to do that; it is rather badly designed from that point of view.

    What you will probably have to do is to separate out your domain logic (the stuff you write in your EJB) from the crawler class, and write a simple, newInstance-able, crawler class which calls the EJB when appropriate. The EJB would not itself be a crawler. You can get hold of a reference to an EJB using JNDI.

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

Sidebar

Related Questions

I have a java app that uses log4j. Config: log4j.rootLogger=info, file log4j.appender.file=org.apache.log4j.DailyRollingFileAppender log4j.appender.file.File=${user.home}/logs/app.log log4j.appender.file.layout=org.apache.log4j.PatternLayout
I generate XML using JAXB2 for an standalone java app that uses maven 3,
Let's say I have a Java app which uses a (static) int constant from
I’m working on a Java server app which uses Spring 3 and C3P0 to
i'm new in java/android app and i'm creating an app that uses user-location. I
I am working on a java web app which uses Smart GWT for the
I'm trying to deploy a java web app which uses FreeTTS to generate mp3s.
I have a large Java app that uses massive amounts of memory at times
I am working on a Java app that uses Spring IoC and JDBC Template
I'm trying to create a simple Java app that uses JNI to call some

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.