Win a copy of Getting started with Java programming language this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem deploying EAR due to referencing classes in a second EJB Project  RSS feed

 
Michelle Streeter
Ranch Hand
Posts: 120
Eclipse IDE Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a EJB project called accounts in Eclipse which is a webservice which manages accounts and transactions.

I have a second EJB project called ranch in Eclipse which is a webservice which manages locations and inventory.

I want to make a transaction entry when an inventory maintenance is performed.

So, I have my ranch project loaded in eclipse which contains the EJB and Client and EAR.
I imported the accounts project into my workspace.
In the ranch properties java build path, I added the accounts project in the projects tab.

This allowed me to reference the entities and eao and the ranch compiles.

But when I go to deploy the ranch ear, it fails because it says it cant find the referenced entities class files.
I tried adding the second project to the EAR but when I tried to deploy, it failed because the second EJB is already reference in the app server which I am using weblogic 12c

I have done alot of trying and missing. 

Have I done this completely wrong, or is there just one thing I need to do to get this to work.

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 36171
439
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michelle,
Have you put the second EJB in the Manifest of the first project? That's used as a runtime classpath for EJBs.
 
Michelle Streeter
Ranch Hand
Posts: 120
Eclipse IDE Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do I want to include the entire jar file rather than just the classes needed?

I am using eclipse.  How do I do this?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 36171
439
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wait. SO the second EJB isn't part of the ear? If it is in another ear, you are going to need to create a client jar to call it and included that in your ear.
 
Michelle Streeter
Ranch Hand
Posts: 120
Eclipse IDE Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is how I ended up getting it to work.  Though not tested yet.  But deployed.

First, I removed the second project out of my Workspace so that the ranch EJB, Client, and EAR is all thats there.
Then, I created packages for the eao and the entities for the accounts classes I needed.
I then right clicked the package and selected New then other then in general I selected File. 
Then clicked advanced and selected Link to file in the file system.
Then browsed to the files I needed in this project
Then clicked Finish. 
I repeated this for my eao classes and my entities needed. 
Once I had everything added to my project, it compiled.  Do note that I had already referenced the persistent unit in the eao and I already had the second persistent unit in the persistent.xml file.
Now that it compiled, I deployed.  And it deployed.  But it only deployed what I needed rather than the entire accounts projects Jar file.

The one benefit to this is that the files I added are linked and so any changes I make to accounts is reflected in ranch and visa versa.  I just have to make sure I deploy both if I make a change.

Now, with this said.  Is there any issues with doing it this way?  Again, I have not yet tested it .
 
Michelle Streeter
Ranch Hand
Posts: 120
Eclipse IDE Flex Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So far, I have tested individual gets such as getaccounts and it is working. 

Now I need to create the logic for getting maintenance which has embedded transaction info and setting which sets not only in ranch but also in accounts.  But surely if the getaccounts worked, the embedded part should work too.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 36171
439
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michelle,
I'm not sure. It sounds a bit hacky becuase it relies on incremental deployment.
 
Michelle Streeter
Ranch Hand
Posts: 120
Eclipse IDE Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, So, here is another idea.  Well maybe.  Depending on if its allowed. 

So, my first EJB for accounts does have the typical Client Remote interface.  Which normally, my front end consumes.  Though I have been using Flashbuilder and so it builds the connection for me and does all the soap stuff for me.

Is there a way I can call the accounts webservice from my ranch webservice to get and set the dto I need?

Or is there a more appropriate way?
 
Michelle Streeter
Ranch Hand
Posts: 120
Eclipse IDE Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let me add why I want to do this in my EJB for my ranch app.  There would be an accounts transaction for every Maintenance record.  So when I am loading the maintenance records, thats when I want to attach the transaction record.  Otherwise, I would have to iterate through the entire list a second time to add it on the front end.  And I would have to do a call the the accounts web service for every record in the maintenance list.  Talk about slowing down your app.  
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!