jersey - What is the difference between starting with exec:java and starting the package created with the maven-assembly-plugin? -


i created first web application following jersey user guide artifact jersey-quickstart-grizzly2. seems work expected: starting project using maven (mvn java:exec) or starting eclipse can call rest api c++, javascript etc...

now run web application on platform, used maven-assembly-plugin create jar containing whatever need run same application. create package using command:

mvn clean compile assembly:single 

and jar compiled. if try run with:

java -jar target/myjar.jar 

it seems start appropriately. if call rest api client, see logs indicating methods invoked expected, response 500. method invoked instance:

@get @produces(mediatype.application_json) public list<mttask> gettasks() {    mtlog.info("processing request.");    return new linkedlist<mttask>(); } 

this output of curl:

$ curl -x -v http://localhost:8080/myapp/tasks * adding handle: conn: 0x11d4c30 * adding handle: send: 0 * adding handle: recv: 0 * curl_addhandletopipeline: length: 1 * - conn 0 (0x11d4c30) send_pipe: 1, recv_pipe: 0 * connect() localhost port 8080 (#0) *   trying 127.0.0.1... * connected localhost (127.0.0.1) port 8080 (#0) > /myapp/tasks http/1.1 > user-agent: curl/7.32.0 > host: localhost:8080 > accept: */* >  < http/1.1 500 request failed. < content-type: text/html;charset=iso-8859-1 < date: fri, 21 mar 2014 22:31:11 gmt < connection: close < content-length: 1031 <  <html><head><title>grizzly 2.3.8</title><style><!--div.header {font-family:tahoma,arial,sans-serif;color:white;background-color:#003300;font-size:22px;-moz-border-radius-topleft: 10px;border-top-left-radius: 10px;-moz-border-radius-topright: 10px;border-top-right-radius: 10px;padding-left: 5px}div.body {font-family:tahoma,arial,sans-serif;color:black;background-color:#ffffcc;font-size:16px;padding-top:10px;padding-bottom:10px;padding-left:10px}div.footer {font-family:tahoma,arial,sans-serif;color:white;background-color:#666633;font-size:14px;-moz-border-radius-bottomleft: 10px;border-bottom-left-radius: 10px;-moz-border-radius-bottomright: 10px;border-bottom-right-radius: 10px;padding-left: 5px}body {font-family:tahoma,arial,sans-serif;color:black;background-color:white;}b {font-family:tahoma,arial,sans-serif;color:black;}a {color : black;}hr {color : #999966;}--></style> </head><body><div class="header">request failed.</div><div class="body">request failed.</div><div class="footer">grizzly 2.3.8</div></body>* closing connection 0 </html> 

if instead run same code mvn java:exec on same location , same machine, output:

$ curl -x -v http://localhost:8080/myapp/tasks * adding handle: conn: 0x17a2c30 * adding handle: send: 0 * adding handle: recv: 0 * curl_addhandletopipeline: length: 1 * - conn 0 (0x17a2c30) send_pipe: 1, recv_pipe: 0 * connect() localhost port 8080 (#0) *   trying 127.0.0.1... * connected localhost (127.0.0.1) port 8080 (#0) > /myapp/tasks http/1.1 > user-agent: curl/7.32.0 > host: localhost:8080 > accept: */* >  < http/1.1 200 ok < content-type: application/json < date: fri, 21 mar 2014 22:33:23 gmt < content-length: 2 <  * connection #0 host localhost left intact [] 

as expected. question is: difference? can somehow create jar deploy on server in similar simple , quick way?

edit: build portion of pom file:

<build> <plugins>     <plugin>         <groupid>org.apache.maven.plugins</groupid>         <artifactid>maven-compiler-plugin</artifactid>         <version>2.5.1</version>         <inherited>true</inherited>         <configuration>             <source>1.6</source>             <target>1.6</target>         </configuration>     </plugin>     <plugin>         <groupid>org.codehaus.mojo</groupid>         <artifactid>exec-maven-plugin</artifactid>         <version>1.2.1</version>         <executions>             <execution>                 <goals>                     <goal>java</goal>                 </goals>             </execution>         </executions>         <configuration>             <mainclass>com.luke.main</mainclass>         </configuration>     </plugin>     <plugin>         <artifactid>maven-assembly-plugin</artifactid>         <configuration>             <archive>                 <manifest>                     <mainclass>com.luke.main</mainclass>                 </manifest>             </archive>             <descriptorrefs>                 <descriptorref>jar-with-dependencies</descriptorref>             </descriptorrefs>         </configuration>         <executions>             <execution>                 <id>make-assembly</id> <!-- used inheritance merges -->                 <phase>package</phase> <!-- bind packaging phase -->                 <goals>                     <goal>single</goal>                 </goals>             </execution>         </executions>     </plugin> </plugins> </build> 

simply starting specifying classpath solved problem:

java -cp target/myjar.jar mymainclass 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -