Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.io.FileNotFoundException: log4j.xml #28

Open
GoogleCodeExporter opened this issue Nov 19, 2015 · 6 comments
Open

java.io.FileNotFoundException: log4j.xml #28

GoogleCodeExporter opened this issue Nov 19, 2015 · 6 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Make a class to refer other jar's classes which in turn should refer 
log4j.xml
2. Add that jar dependency in pom that contains log4j.xml
3. Excute java -jar

What is the expected output? What do you see instead?
Getting below error

log4j:ERROR Could not parse url 
[jar:file:/C:/rxspecialty%20batch/rxspecialty-batch/target/rxspecialty-batch-0.0
.1-SNAPSHOT.o
ne-jar.jar!/lib/services-commons-aspects-0.0.1-SNAPSHOT.jar!/log4j.xml].
java.io.FileNotFoundException: JAR entry 
lib/services-commons-aspects-0.0.1-SNAPSHOT.jar!/log4j.xml not found in 
C:\rxspecial
ty batch\rxspecialty-batch\target\rxspecialty-batch-0.0.1-SNAPSHOT.one-jar.jar
        at sun.net.www.protocol.jar.JarURLConnection.connect(Unknown Source)
        at sun.net.www.protocol.jar.JarURLConnection.getInputStream(Unknown Source)
        at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
        at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
        at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
        at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
        at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
        at org.apache.log4j.xml.DOMConfigurator$2.parse(DOMConfigurator.java:690)
        at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:789)



What version of onejar-maven-plugin are you using?
1.4.4


What is the output of "mvn -version" on your machine?
2.2.1


Please provide any additional information below.

<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.cvsc.specialty</groupId>
    <artifactId>rxspecialty-batch</artifactId>
    <packaging>jar</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>rxspecialty-batch</name>

    <properties>
        <compileSource>1.5</compileSource>      
        <spring.version>2.5.6.SEC01</spring.version>
    </properties>


    <build>

        <plugins>
            <!--  Java5 -->
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${compileSource}</source>
                    <target>${compileSource}</target>
                </configuration>
            </plugin>



        <plugin>                     
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>   


            </plugin>



    <plugin>
  <groupId>org.dstovall</groupId>
  <artifactId>onejar-maven-plugin</artifactId>
  <version>1.4.4</version>

        <configuration>

                            <onejarVersion>0.98</onejarVersion>

         </configuration>
  <executions>
    <execution>
      <goals>
        <goal>one-jar</goal>
      </goals>
    </execution>
  </executions>
</plugin>



        </plugins>
    </build>




        <dependencies>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <!--
                    To accommodate for the following Spring 2.5.x 's JUnit integration.
                    See: http://jira.springframework.org/browse/SPR-5145
                -->
                <version>4.4</version>
                <type>jar</type>
                <scope>test</scope>
            </dependency>                   
            <dependency>
                <groupId>com.oracle</groupId>
                <artifactId>ojdbc14</artifactId>
                <version>10.2.0.4.0</version>
            </dependency>

            <dependency>
                <groupId>com.cvsc.specialty</groupId>
                <artifactId>services-app</artifactId>
                <version>0.0.1-SNAPSHOT</version>

            </dependency>


                </dependencies>



</project>

Original issue reported on code.google.com by prabava...@gmail.com on 8 Feb 2011 at 2:55

@GoogleCodeExporter
Copy link
Author

I got same error in a likely setting.

Original comment by jinfan.d...@gmail.com on 9 Apr 2011 at 12:41

@GoogleCodeExporter
Copy link
Author

I am not using the maven plugin but just the Command Line approach document at 
http://one-jar.sourceforge.net/index.php?page=getting-started&file=quickstart 
and I also cannot load my log4j.xml from within the One Jar.

I get:

log4j:ERROR Could not parse url 
[jar:file:/AppLink.jar!/main/StubMsgSvc.jar!/log4j.xml].
java.io.FileNotFoundException: \FOpenLink.jar (The system cannot find the file 
specified) .....

Original comment by johngfer...@gmail.com on 30 Sep 2011 at 6:27

@GoogleCodeExporter
Copy link
Author

The only non-announcement post to this project's Google Group was about this 
issue, too:

https://groups.google.com/group/onejar/browse_thread/thread/cfc13effd6bfb9ef
>>>>>

I have a maven build using one-jar to create an executable test JAR. 
The JAR runs just fine, but during the execution of my main class I 
need to load my TestNG xml from the root of the JAR, but this fails. 
This mechanism works with an executable zip on another project. I 
would prefer to use one-jar so that I don't have to manually manage 
the dependencies. 
I've confirmed that files exist in the myProject.jar and the paths 
are: 
    /com/address/MyMain 
    /myFile.xml 
I added the following to the MyMain class: 
    ... 
    System.out.println("This is the path: " + 
MyMain.class.getClassLoader().getResource("myFile.xml").toString()); 
    ArrayList<String> suites = new ArrayList<String>(); 
    String xmlPath = 
MyMain.class.getClassLoader().getResource("myFile.xml").toString(); 
    suites.add(xmlPath) 
    testng.setTestSuites(suites); 
    ... 
When I run the JAR I get this as an output: 
    This is the path: jar:file:/myProject.one-jar.jar!/main/ 
myProject.jar!/myFile.xml 
    java.io.FileNotFoundException: jar:file:/myProject.one-jar.jar!/ 
main/myProject.jar!/myFile.xml (No such file or directory) 
I tried other paths but cannot find one that works. 
Any idea how I can get the path for the xml file? 

Original comment by edbran...@gmail.com on 2 Feb 2012 at 7:07

@GoogleCodeExporter
Copy link
Author

You may have to use the One-Jar-Expand mechanism (documented at 
http://one-jar.sourceforge.net) to expand the XML file into the filesystem 
(somewhere), then load it from there as a File resource.

Best guess as to cause: something in testng is not using a URL which delegates 
its handlers, hence it cannot understand the "jar" protocol.

Original comment by simontu...@gmail.com on 3 Feb 2012 at 5:19

@GoogleCodeExporter
Copy link
Author

The root-cause of this issue is that Jar-URLs don't survive being converted to 
a String and then back to a URL again. Somewhere there's a class that needs an 
actual reference to the resource (Jar) and that reference is likely not 
populated after being constructed back from a String again....

Original comment by joh...@gmail.com on 20 Mar 2012 at 5:10

@GoogleCodeExporter
Copy link
Author

Any direction on this? I'm getting the same issue and put the following into my 
maven configuration. It put log4j.xml in the Manifest but I'm not getting any 
different reaction.

<manifestEntries>
<One-Jar-Expand>log4j.xml</One-Jar-Expand>
</manifestEntries>

Original comment by eabrand on 23 May 2012 at 7:54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant