longhua828 / java-gearman-service

Automatically exported from code.google.com/p/java-gearman-service
0 stars 0 forks source link

exported .jar with 'echo' example produces errors #47

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. download the whole project into some local dir from the java-gearman-service 
svn
2.import the downloaded source into eclipse as a new maven project.
3. import the four 'echo' example files into the same eclipse project and put 
it in a package that matches what is in the source for those files (in this 
case it is 'package org.gearman.examples.echo')
4. run the 'echoWorkerServer.java' file by right clicking on it and choosing 
run as -> 'java application' 
5. let it run, then stop it.
6. export 'echoworkerserver.java' as a .jar by right clicking on the java file 
-> export -> select 'runnable JAR file' (click 'next') -> select 'package 
required libraries into generated JAR' (make sure that the 'echoWorkerServer' 
run configuration is selected)->   click on 'finish'
7. go to where the jar is saved and run it with the following command (in 
Ubuntu Linux 12.10) 'java -jar <theJARfileName>.jar'
8. see below error

What is the expected output? What do you see instead?
I would expect to see no output, or maybe just some output from log4j, and have 
the program continue to run. instead I get an error with the program 
terminating immediately after.  Here is the error that is being experienced:
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.ExceptionInInitializerError
        at org.gearman.Gearman.createGearman(Gearman.java:53)
        at org.gearman.examples.echo.EchoWorkerServer.main(EchoWorkerServer.java:22)
        ... 5 more
Caused by: java.lang.NullPointerException
        at java.util.Properties$LineReader.readLine(Properties.java:434)
        at java.util.Properties.load0(Properties.java:353)
        at java.util.Properties.load(Properties.java:341)
        at org.gearman.context.GearmanContext.loadProperties(GearmanContext.java:176)
        at org.gearman.context.GearmanContext.loadProperties(GearmanContext.java:159)
        at org.gearman.context.GearmanContext.loadProperties(GearmanContext.java:144)
        at org.gearman.context.GearmanContext.initProperties(GearmanContext.java:74)
        at org.gearman.context.GearmanContext.<clinit>(GearmanContext.java:66)
        ... 7 more

What version of the product are you using? On what operating system?

Java-gearman-service version: 0.7.0-SNAPSHOT

Operating system: Ubuntu 12.04 LTS. 

Please provide any additional information below.

Original issue reported on code.google.com by surfdog2...@gmail.com on 7 May 2013 at 10:56

Attachments:

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Also, using the following eclipse version:
Eclipse SDK Version: 3.7.2

with the M2e maven plugin

Original comment by surfdog2...@gmail.com on 7 May 2013 at 11:16

GoogleCodeExporter commented 8 years ago
It looks like eclipse is incorrectly constructing the jar. It's putting the 
resources into a "resources" directory when it needs to be in the root.

I've updated the maven pom to create an executable jar. The difference is that 
the decencies are external. This is to keep consistent with the main project.

If you want to create a standalone uber jar, use the "shade" maven plugin to 
build the jar. The following is an example of using the shade plugin:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-shade-plugin</artifactId>
  <version>2.0</version>
  <executions>
    <execution>
      <phase>package</phase>
      <goals>
        <goal>shade</goal>
      </goals>
      <configuration>
        <createDependencyReducedPom>false</createDependencyReducedPom>
        <transformers>
          <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
            <!-- <mainClass>org.gearman.examples.echo.EchoClient</mainClass> -->
            <!-- <mainClass>org.gearman.examples.echo.EchoClientAsynchronous</mainClass> -->
            <!-- <mainClass>org.gearman.examples.echo.EchoWorker</mainClass> -->
            <mainClass>org.gearman.examples.echo.EchoWorkerServer</mainClass>
          </transformer>
        </transformers>
      </configuration>
    </execution>
  </executions>
</plugin>

Original comment by isaiah.v...@gmail.com on 8 May 2013 at 3:30

GoogleCodeExporter commented 8 years ago
I'm closing this issue, but it can be reopened. If you are still having issues, 
let me know.

Original comment by isaiah.v...@gmail.com on 8 May 2013 at 3:35