[EJB 3.0] - Re: Exploded jar containing persistence.xml with jar-file el
by jaikiran
I spent sometime on this, i can see where the problem is. There's a getRelativeURL method on org.jboss.ejb3.JmxDeploymentUnit class:
public URL getRelativeURL(String jar)
| {
| URL url = null;
| try
| {
| url = new URL(jar);
| }
| catch (MalformedURLException e)
| {
| try
| {
| if (jar.startsWith(".."))
| {
| if (getUrl() == null)
| throw new RuntimeException("relative <jar-file> not allowed when standalone deployment unit is used");
| String base = getUrl().toString();
| jar = jar.replaceAll("\\.\\./", "+");
| int idx = jar.lastIndexOf('+');
| jar = jar.substring(idx + 1);
| for (int i = 0; i < idx + 1; i++)
| {
| int slash = base.lastIndexOf('/');
| base = base.substring(0, slash + 1);
| }
| url = new URL(base + jar.substring(idx));
| }
| else
| {
| File fp = new File(jar);
| url = fp.toURL();
| }
| }
| catch (MalformedURLException e1)
| {
| throw new RuntimeException("Unable to find relative url: " + jar, e1);
| }
| }
| return url;
| }
|
This logic, using string manipulation, doesn't seem to work when the jar is exploded (i.e. ends with a / since its a directory ex: file:/D:/JBoss_4_2/server/default/deploy/EJB3Persistence.ear/myapp_ejb3.jar/) ).
To get this working, i modified this piece of code in the JBoss code as follows:
| public URL getRelativeURL(String jar)
| {
| URL url = null;
| try
| {
| url = new URL(jar);
| }
| catch (MalformedURLException e)
| {
| try
| {
| if (jar.startsWith(".."))
| {
| if (getUrl() == null)
| throw new RuntimeException("relative <jar-file> not allowed when standalone deployment unit is used");
| String base = getUrl().toString();
| jar = jar.replaceAll("\\.\\./", "+");
| int idx = jar.lastIndexOf('+');
| jar = jar.substring(idx + 1);
| File file = new File(getUrl().getFile());
|
| for (int i = 0; i < idx + 1; i++)
| {
|
| file = new File(file.getParent());
| }
| url = new URL(file.toURL().toString() + jar);
|
| }
| else
| {
| File fp = new File(jar);
| url = fp.toURL();
| }
| }
| catch (MalformedURLException e1)
| {
| throw new RuntimeException("Unable to find relative url: " + jar, e1);
| }
| }
| return url;
| }
Instead of relying on string manipulation i used the API available on java.io.File to parse the relative URL. I deployed the changed code in JBoss jar and was able to get my application deployed. Also, tested this change with an archived deployment (to make sure i did not break any existing behaviour), even that deployed fine.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4140012#4140012
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4140012
16 years, 9 months
[JBoss Tools (users)] - Re: How does -test project reference dependent libraries?
by max.andersen@jboss.com
"cpopetz" wrote :
| (1) I'm using junit rather than testng, because the latter's output leaves much to be desired, and we have testing tools that work with junit's xml output. Junit respects the "Exported" checkbox set in the the "Order and Export" section of the Java Build Path. Testng must not. Because if I don't check to export the EAR directories to dependent projects in the build path for the WAR, then the tests running from the test project don't find the ear directories. The jboss tools don't check this box by default.
|
This is disturbing if true ;(
But testng must really be doing funny things to get the classpath if it gets *more* than what junit does. Could you help us by reducing this to a simple testcase and submit it towards the testng project and show the diference in behavior ?
note: you can see the actual used classpath by right clicking on the process in the debug launch view and select Properties.
anonymous wrote :
| So I guess what I'd like to see: The test project is testing dependent EJB modules and the WAR module. The latter both pick up Utility Jar dependencies through Manifest.MF and EarContent, via that whizzy "EAR Libraries" thing. It would be nice if the test project did that as well.
|
This is what actually should just be happening....could you create a minimal testcase/project and submit it to jira so we can be sure we are actually doing the same thing ? Thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4140000#4140000
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4140000
16 years, 9 months