- This topic has 5 replies, 2 voices, and was last updated 13 years, 6 months ago by support-tony.
-
AuthorPosts
-
trantParticipantI created a new Java Enterprise Project in MyEclipse, and within its wizard i created a new web module. So now I have two projects, the EAR project and the WEB project
Then I went to the WEB module project, right clicked and added maven capabilities. Then I ran the maven install. I left everything default so at to just test deployment alone.
Then I go back to the EAR project and also add maven capabilities, and then add dependency to my web module project. I also specifiy to maven that it is to build an ear archive.
Now I can run Maven package from Run As… and it builds an ear file – though there is one problem – it does not have the application.xml file MyEclipse produced, instead it is using some blank application.xml that it created – no idea why!
And then now how do I easily have maven or myeclipse deploy this packaged ear file to weblogic 11g?
Would really love to get some help on those 2 questions – thanks!
support-tonyKeymastertrant,
This may be a bug. I will need to investigate further. When adding maven capabilities to the EAR project, the pom generated should probably be more detailed to cope with a different project structure than the default maven structure, though this may not be sufficient.
In the meantime, I think this will help:
Create a new src folder under the project, a main folder under src and an application folder under main. Move the META-INF folder under the new application folder. The maven package build should now work.
support-tonyKeymastertrant,
We’re still considering this but I’ve discovered that a maven build of an EAR project will generate the application.xml file, so there is no need to retain the file that was generated during project creation. However, maven, by default, does expect to find sources and other files in certain places. So, after adding maven support, you may need to do some manual tweaking of directory structures and/or the POM file.
Can you say exactly how you added maven support to those projects, as there is no direct way to do it in MyEclipse (for the way you created your projects), though if you already have maven enabled projects in the workspace there might be a context menu item that indirectly adds maven support?
trantParticipantHello,
I think the problem is in MyEclipse. When you create a EAR project with an attached Web or EJB modiule MyEclipse automatically creates an applciaiton.xml for you. Then you can add Maven support through the context menu however MyEclipse does nothing to tie the application.xml it created with the maven support you add, it is disconnected.
I believe MyEclipse should handle the configuration for you so that if you add Maven support to a project then it should configure your default pom.xml to use your project resources.
That way, you really do get good benefits from having maven support integrated.
It is quite easy to reproduce this problem:
1. New -> Enterprise Application Project
2. Put in any name, then check either Web or EJB modules. Hit Finish
3. MyEclipse creates the projects, and it also generates a default application XML under the META-INF folder for you.
4. Right click project, under MyEclipse Maven choose Enable Maven
5. On the dialog, leave everything except the packaging dropdown, change that to “ear”, hit Finish
(MyEclipse now creates the pom.xml and the target folder for you)
Here is where the problems start to happen:
A) It generates a completely new applciation.xml, it does not connect to your existing one (compare the two files to confirm)
B) The generated application xml is not even valid, it immediately throws an error because it is missing required tags inside of it.
And if you do a maven package it will use the invalid maven generated application.xml, not the one MyEclipse made for you originally.
My wish would be that MyEclipse when adding maven capabilities would automatically configure your pom.xml so that it points to the original application.xml instead of creating a new one and ignoring any existing ones. Only create a new application.xml if you do not have one already.
I believe it could accomplish this by either altering the folder structure for you automatically to conform with maven’s structure, or including a secton in your pom.xml which explicitly points to your existing applciation.xml.
I think the same idea should apply to web projects, which in my experience also falls short on maven support as I had to do manual tweaking to get my web application working after I added maven support because maven was not automatically configured to use the web.xml MyEclipse generated for me and because the directory structure was not altered to make it ‘maven friendly’
This way, adding maaven support would be a pwoerful tool.
trantParticipantHello,
I think the problem is in MyEclipse. When you create a EAR project with an attached Web or EJB modiule MyEclipse automatically creates an applciaiton.xml for you. Then you can add Maven support through the context menu however MyEclipse does nothing to tie the application.xml it created with the maven support you add, it is disconnected.
I believe MyEclipse should handle the configuration for you so that if you add Maven support to a project then it should configure your default pom.xml to use your project resources.
That way, you really do get good benefits from having maven support integrated.
It is quite easy to reproduce this problem:
1. New -> Enterprise Application Project
2. Put in any name, then check either Web or EJB modules. Hit Finish
3. MyEclipse creates the projects, and it also generates a default application XML under the META-INF folder for you.
4. Right click project, under MyEclipse Maven choose Enable Maven
5. On the dialog, leave everything except the packaging dropdown, change that to “ear”, hit Finish
(MyEclipse now creates the pom.xml and the target folder for you)
Here is where the problems start to happen:
A) It generates a completely new applciation.xml, it does not connect to your existing one (compare the two files to confirm)
B) The generated application xml is not even valid, it immediately throws an error because it is missing required tags inside of it.
And if you do a maven package it will use the invalid maven generated application.xml, not the one MyEclipse made for you originally.
My wish would be that MyEclipse when adding maven capabilities would automatically configure your pom.xml so that it points to the original application.xml instead of creating a new one and ignoring any existing ones. Only create a new application.xml if you do not have one already.
I believe it could accomplish this by either altering the folder structure for you automatically to conform with maven’s structure, or including a secton in your pom.xml which explicitly points to your existing applciation.xml.
I think the same idea should apply to web projects, which in my experience also falls short on maven support as I had to do manual tweaking to get my web application working after I added maven support because maven was not automatically configured to use the web.xml MyEclipse generated for me and because the directory structure was not altered to make it ‘maven friendly’
This way, adding maaven support would be a pwoerful tool.
support-tonyKeymastertrant,
As I’ve indicated, there is a problem when enabling Maven support in existing projects. In a fresh workspace there is no “Enable Maven” context menu item, for a project. The menu item you mentioned is, presumably, “Enable Dependency Management” (not “Enable Maven”). This is a menu item provided by activating the “m2eclipse Extras” capability (via Window->Preferences->General->Capabilities, Click “Advanced” then expand “MyEclipse Standard Tools” and select “m2eclipse Extras”). This hasn’t been fully integrated into MyEclipse, so there may be issues with it (I’ve seen at least one m2eclipse bug associated with Enable Dependency Management: http://jira.codehaus.org/browse/MNGECLIPSE-1191).
The m2eclipse Extras capability is also added via a pop-up dialog if you try to add a POM file to non-maven project (New->MyEclipse->Maven->POM file – you may need to show all wizards to see it).
Enabling Dependency Management adds the POM file but it doesn’t do much else (though that maven bug indicates in can do some damage on anything other than a blank project). If you add maven to the EAR project first, you’re right, you get an empty application.xml. However, if you add maven to the web project first and run the maven install, then add maven support to the EAR project with the web project as a dependency, then the application.xml will not be empty. The steps are as follows.
When adding Enabling Dependency Management on the web project, change the packaging to war. Then either modify the src directory structure to match the maven convention for war projects or configure the war maven plug-in to point to the existing web root directory (for the warSourceDirectory property). Then run the maven install.
Now, when adding maven to the EAR project, don’t just take all the defaults. As well as changing the packaging to “ear”, click next and add the web project as a dependency. After that the generated application.xml file will have some valid content, though I’m not familiar with EAR projects so I’m not sure if more needs to be done to get a fully valid application.xml. For example, you’ll probably need to configure the ear maven plug-in to specify the web module properly.
The reason for maven generating the application.xml file is that it uses the POM to determine modules and dependencies. Also, since the name of the war file will be given a maven convention name, it’s best to let the maven build generate the application.xml file.
However, it’s certainly true that all this needs to be integrated into MyEclipse. There is a problem report already for the inability to (easily) add maven support to EAR projects and their modules; the fixing of this may lead to better integration.
Thanks for pointing this out and if you have any other questions on this, please ask.
-
AuthorPosts