aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Ejbproject reference to Webproject in enterprose project Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Ejbproject reference to Webproject in enterprose project" Watch "Ejbproject reference to Webproject in enterprose project" New topic
Author

Ejbproject reference to Webproject in enterprose project

Mark Henryson
Ranch Hand

Joined: Jul 11, 2005
Posts: 200
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

Joined: Feb 01, 2005
Posts: 580
    
    5
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


Independent Consultant — Author, EJB 3 in Action — Expert Group Member, Java EE 6 and EJB 3.1
Mark Henryson
Ranch Hand

Joined: Jul 11, 2005
Posts: 200
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

Joined: Feb 01, 2005
Posts: 580
    
    5
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

Joined: Jul 11, 2005
Posts: 200
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

Joined: Feb 01, 2005
Posts: 580
    
    5
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
 
 
subject: Ejbproject reference to Webproject in enterprose project