This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ejbproject reference to Webproject in enterprose project

 
Mark Henryson
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using MyEclipse with JBoss server.
I have created an enterprise project with web project and ejb project.
Web project will have all the struts related classes and jsp files.
EJB project will have the session and entity beans.
I have written a business delegate with service locator in the web project.
I want to use the business delegate with service locator in ejb project also without duplicating it.
For example:
Service Locator.java is in MIWebProject (package: com.example.web.locator)
ProductManagerBean.java is in MIEjbProject.
In ProductManagerBean.java, I couldn't able to import com.example.web.locator package and use the service locator to get the JNDI lookup.
In MIEjbProject, I have tried to referenced the MIWebProject but it's not working.
I have tried to include the MIWebProject in MIEjbProject classpath. But getting the following error:



I don't want to duplicate the service locator class in ejbproject also. How to achieve this?

Also I have nother query on logging.
How to implement the logging for both web and ejb project?


 
Reza Rahman
author
Ranch Hand
Posts: 580
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark,

You will need to tell MyEclipse that the web module depends on the EJB module. Should be fairly self-explanatory if you right click on the web project.

As to logging, I highly recommend a shared log4j configuration.

Hope it helps,
Reza
 
Mark Henryson
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, EJB project is depend on the Web project's Service Locator class.
In EJB project, I have right clicked and in Project Reference, I have included the Web Project. But it's not working and still it's showing the error message as ServiceLocator cannot be resolved. Usually pressing CTRL+SHIT+O will automatically import the missing/required packages in eclispe. Even after I have hardcoded the package detail, it's showing ServiceLocator cannot resolved error.

Whether ServiceLocator should be at EJBProject and WebProject should reference it? Which is the best place for the ServiceLocator to reside at.. in EJBProject or WebProject? Since both are using it.

 
Reza Rahman
author
Ranch Hand
Posts: 580
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark,

You have it slightly backward. The service locator can be a web project. However, since the service locator depends on EJB instances, the web project should depend on the EJB project instead of the other way round.

Hope it helps,
Reza
 
Mark Henryson
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reza Rahman,

Thanks for your reply.I have moved the service locator from Web Project to EJB Project and it's working properly.
I have another query for regarding the logging. I want to log both the web and ejb related classes. As adviced by you, I have planned to create a separate project for logging and provide the project reference to both web project and ejb project. If this is right way of doing, whether the loggin project can be an ordinary java project or it should be a web project. I am using JBoss 4.2.2.GA Application server with MyEclispe. Whether I need to disable the default logging provided by the JBoss. I have planned to use log4j for logging. Can you please help to throw some light on it and any useful links or tutorial will useful. I have searched in google, but if I have any material/tutorial for explaining the best practices/how to implement the logging for the enterprise application will be useful. Meanwhile, I am also keep on searching in google to get some good resources on it.
 
Reza Rahman
author
Ranch Hand
Posts: 580
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark,

Yes, it is best to make this a shared Java project/library. log4j is the best choice (although it has a few problems you need to watch out for). I have enterprise logging best practices that I use for consulting engagements. I can consider publishing them if there is enough demand.

Best regards,
Reza
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic