I'm developing an application that should run on a server. The application uses some external jars.
I have build the application and run it on a local machine without a problem.
Now, I need to deploy it on the server. The server has some of the jars located.
What should I do to make my application work on the server, using the jars that are already there?
I don't have much experience with Java, but I understand that there is a manifest file which has a class-path field that points to all the jars needed. Should I change the manifest "manually", so that it points to the location of the jar on the server? What do you do in situations like this, what is the correct procedure?
Also, if I use one version of jar during development, and there is a bit older version of that jar on the server, what should I do to perform the deployment correctly?
And what is the procedure in case of using maven, should I copy the jars from where it locates them on the local drive to one directory, or is there a way for maven to do it itself?
I'm using NetBeans btw.
Thanks
Re "using the jars that are already there":
See Introduction to the Dependency Mechanism, Dependency Scope: "provided ... indicates you expect the JDK or a container to provide the dependency at runtime."
Re "there is a bit older version of that jar on the server":
Update the library on the server or use the older when developing. I'd consider it a really bad idea to use different versions of a library for developing and runtime. This can lead to subtle errors that are hard to identify.
Re "And what is the procedure in case of using maven":
Does the introduction linked above help you in answering this as well?
Maven is supposed to work the same with any type of IDE.
Related
I get this error in my project which I imported from my backup. Before I could run the project without issue in eclipse. I formatted my machine and now when I try to run the application I get this error. what could it be..
I am not using maven and I tried to remove the jars and adding them all back....
One thing that differs from my previous setting is that i was using java sdk 1.6.22 version before now i am using java 1.8
You are missing reference to the JAR file after you formatted your PC.
You put your JAR file again in classpath, and error will go off.
You have lost the reference to the jar.
Here you are two possible solutions:
If you are using Maven, check your pom.xml and then if all it's
correct make an Maven > Update Maven Project.
If you are adding directly the jars to the Buildpath, add again and
the error will dissapear.
Two issues:
There is no sun.utils.LocaleServiceProviderPool, at least not in the packages provided directly by the JDK (at least checked on my machine with JDK8 installed).
Maybe you mean sun.util.locale.provider.LocaleServiceProviderPool?
As stated before, the use of sun.* packages is not encouraged since they are internal API.
I have a web service and I'm using the Endpoint.publish("http://0.0.0.0:8080")
Thing is that JAX-WS 2.0 and 2.1 is affected by an issue that throw a NullPointerException when executing endpoint.stop().
The issue is fixed in 2.2 but when adding the dependency in the pom.xml publishing fails due to a java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName()Ljava/lang/String; since I'm using java 1.6.
The workaround is to add to the endorsed folder some libs. But I want to pack it all in jar-with-dependencies. An executable java jar.
Said this, I would be thankful if you help me:
Publishing the endpoint in 2.0 or 2.1 listening to all addresses (0.0.0.0)
or
Configuring dependencies in maven to pack everything using 2.2.x
but executable with JDK6
EDIT:
Requirements are a deliverable jar. A single jar that pack all of the dependencies (2 so far, about a 400k jar).
But if you think that the only way to make it work is to add an external shell script please let me know too.
Thank you!
The executable jar format does not allow for endorsed folders required for JAX-WS replacement (and neither does the Java WebStart launcher apparently).
You need to use something that can construct and execute a new "java" command on the fly. The best way from here is most likely to look for an installer which can run the program directly without needing to install.
What exactly do you need to happen?
EDIT: As the requirement is a runnable jar you simply cannot do this with JAX-WS 2.2 Find a workaround with the JAX-WS present in the latest release of the Java version you are targetting.
It is very nice that the JAX-WS stack ship with core Java allowign for very small deployments, but a pain that you cannot easily provide your own.
Note that you can provide your own with Java 5 but then you need to bring your own Endpoint implementation.
Do you need to use the JAX-WS RI? You could use CXF instead which is a fine JAX-WS implementation and doesn't suffer the same collision problems as the RI.
Edit: You could try to generate the classes with the RI, but use CXF in the deployment. JAX-WS is a spec after all so it should work...
1) I have old project that I need to modify. I need to add new web service. And I am having issues with some jar files.
I have created new service (Axis2), then I used Eclipse wizard to create Web Service Client code. Everything looks fine, except when my MyServiceStub.java showed up inside client java project, it failed to find some libraries.
I looked at few of them and it seems it is looking for Axis2-kernel-1.6.0.jar. Currently in my old project I see Axis2-kernel-1.3.0.jar and it seems that existing OtherServiceStub.java file there is using this Axis2-kernel-1.3.0.jar.
The first thing that dropped on my mind is that previously web services were created with earlier version of Axis2. My current version is 1.6.
The thing, I really don't understand is why in Project Facets it is telling me that Axis2 is of version 1.1....
Ideally, I would like to use Axis2-kernerl-1.3.0.jar, becase I want to keep changes to minimum. What Version of Axis2 do I need?
Any advice how to solve my problem?
And ...
2) If I have 2 projects, how can I automatically reference JAR of one project in another one, so when I make changes in referenced project, I see them effective when runing in project that is referencing? Right now, I export project to JAR, then I manually copy JAR (overwrite) to folder of the project that needs it.
1) You need to use whatever version of the kernel axis2 web service is currently running, ie wherever this is deployed to has a kernel version. You want your client code to talk to the server in the same version of axis basically.
You can download old releases here
http://axis.apache.org/axis2/java/core/download.cgi
2) Running vs debugging is different. If you are running axis2 on a server, not inside of eclipse, your best option is to export the jar and upload to the axis2 WEB-INF/lib directory. That way you can have a copy you debug and code upon, separate from the copy that is actually running.
I haven't been using Java extensively hence forget a lot fundamental things. Basically, I am working with a web-dynamic project (using Eclipse IDE with jdk 1.6), and during the build, I get errors that Cookie class and other web related classes cannot be found. What am I missing?
What Jars files do I need to add (and how)?
thanks
Think you need servlet-api.jar
Try here for any jar files you need http://www.java2s.com/Code/Jar/CatalogJar.htm
Sounds like you are missing servlet-api.jar
You can download it from the Maven repository.
Servlets are only part of the Enterprise Edition, not of the Standard Edition of Java. So you need the Java Enterprise Edition, AKA Java EE.
http://java.sun.com/javaee/
As others have said, you're missing the server api jar.
Having said that, downloading just the servlet api jar and not the server that goes with it means that you can't actually test your code.
In Eclipse, once you're installed a servlet container, such as Sun's Glassfish, Apache Tomcat, or Jetty, you can create a server instance of it so that Eclipse will compile against your server's servlet implementation. Creating a server instance also means that Eclipse's Run on Server command works.
IBM has a slightly outdated guide on Developing Web applications with Tomcat and Eclipse. The entire "Install the Web tools" section can be skipped if you have the Eclipse EE version, as Web Tools are already installed.
Essentially the only thing I can deploy to my deployment machine is a JAR file. I can't install JRuby, nor can I install Glassfish or Tomcat.
Is it possible to package up a Rails application (including Rails, vendored, of course) to a JAR file such that I can do
c:\my_server> java rails_app.jar
and have it run WEBRick or Mongrel within the JVM?
I wrote an article a year ago about how to embed your ruby sources with jruby and everything else you want into one jar file, and then run it with "java -jar myapp.jar".
It will need some work to make it boot rails I guess, but it should not be too hard. And with the complimentary jruby documentation on their wiki, i guess you can run a jetty+war thing fairly easily with this technique.
The article is here:
http://blog.kesor.net/2007/08/14/jruby-in-a-jar/
I'd recommend that you checkout Jetty. The process for Embedding Jetty is surprisingly easy, and it should be possible to give it your servlets from your current jar file. I haven't used Ruby/Rails, though, so I'm not sure if there are any complications there.
Is it normally possible to embed all of your rails templates/models into a jar inside of a war file for deployment on Tomcat? If so, then you should be able to get embedded Jetty to pull it from your single jar as well.
It may be a bit dated, but Nick Sieger, one of the JRuby contributors wrote about warbler a while ago.
Warbler is about packaging a Rails app into a .war file. Now I'm not a big Java guy, so I'm not sure where your .jar restriction comes from. war files are similar to jars but they're for whole websites or something.
Worst case, I'm pretty sure the JRuby wiki has something about the state of packaging Rails apps to be run on Java architectures. It's in their best interest to have info about that.
I don't think you can run Mongrel within the JVM. Trying to run a webserver of any kind without Tomcat or Jetty is probably way more trouble than it's worth. jsight's answer looks helpful for that problem. If you can get that far, here's a page on JRuby's site about running JRuby on Rails in Tomcat.
you might want to try asking this question on the JRuby mailing list/forum(http://xircles.codehaus.org/lists/user#jruby.codehaus.org).
Another place someone would have done the same is the glassfish mailing list
Yet another thing you might want to do is to bundle winstone embeddable servlet container AND jruby AND rails and use jarjar to create one big jar. You might be able to build an ant build file to build such a BIG jar that also includes your rails application. One project that used this approach is hudson(https://hudson.dev.java.net/) -- you may get some info on how to go about doing that.
BR,
~A
I just ran across this blog today, and I intend on giving it a try, if anyone else has let me know
http://matthewkwilliams.com/index.php/2010/03/02/rails-jruby-in-a-jar/