How to use class.java from service.jws in an Axis project? - java

I'm building a java web service using Apache Axis 1.4. My service.jws is already working well on Tomcat. Now I want to expand this web service, adding more classes which should be used from service.jws. The problem is when I create a class on src folder, I can't import it from my service.jws (located at WebContent folder), how can I do it?
By the way, other thing i've tried was to create the classes I need in another project, generated .jar and added to lib by configuring buildpath, but from service.jws it can't be imported/recognized. However, the lib from axis, that I've added to path by the same way, can be imported and work fine.
Somebody can help me? Thanks.

It worked when I copied otherproject.jar, that I generated, into WEB-INF/lib in my axis project and added it to buildpath by "import jars" in Eclipse (not "import external jars").

Related

Java REST API adding folders to the project

I'm using jersey to build a REST webservice in eclipse everything's work fine but when i added a jar to my project (webContent/WEB-INF/lib) and this jar make use of other files. This files are in folders named "configs". When a use this jar in java project i added configs folder to the java project folder and it work okay :)
So how to add folders to the web project?
i found the answer you just change the working directory.
Run configuration > Arguments > at the bottom you change the working directory

J2EE project with using classes from J2SE project [duplicate]

I'm using Eclipse 3.7 (STS) with Tomcat 7 running inside the IDE. I've created a new Dynamic Web project and added a single JSP file to the web content root folder. I can run Tomcat and access the JSP from within Eclipse with no problems.
I've added a few 3rd party JAR's to the project from User Libraries (I'm not using maven or auto dependecies managment). In the JSP I reference a class from the project's JAR file, I can compile this with no problem, but when I deploy on Tomcat the JSP throws ClassNotFoundException. Clearly, Tomcat can't find the JAR's from my library settings. I tried creating a Run As configuration for Tomcat Server and I set the classpath to match the classpath settings of the project, but I still get the same classnotfound problem.
I could get around the issue by manually copying all project JARs to the WEB-INF/lib directory so the webapp can find all dependencies, but that's absurd and I don't expect that to be the solution since it's a maintenance nightmare.
Am I missing something?
In project's properties, go to Deployment Assembly. Add there the buildpath entries as well which you've manually added as user libraries. It'll end up in /WEB-INF/lib of the deployed WAR.
You'll need to copy the jar files to the WEB-INF/lib folder: that is where they are supposed to be.
Eclipse should offer you the option of generating a WAR file that includes all the dependencies: I haven't used Web Tools for a good while but one way or another all dependencies have to be in WEB-INF/lib or the class loader won't be able to find them.

ClassNotFoundException from jar in Dynamic Web Project

I created a JPA project that I want to use in a dynamic web project.
I made a jar from this JPA project and added it in a lib folder in the dynamic webproject. I then added this to the buildpath of the dynamic web project and also ticked it in the "Order and Export" tab.
First question : I created the jar file with a normal export to jar with these options;
Are these ok or do I have to add something.
Second question: After I added this jar to the buildpath and I use a instance of a class from within this jar I can add it to the imports and the class is know so I don't see any errors.
When I try to run the jsp and servlet where I use the class I get a java.lang.NoClassDefFoundError error in my apache with a java.lang.ClassNotfoundEception at the line where I use the class. So for some reason he doesn' find the class at runtime.
I tried to make the jar over and over again with different options. I tried to import the class I need on different way's (ctrl-T) but I only see one class.
The only thing I find strange is the way the import looks. In my JPA project I have a package structure like :
be.JPA.project6
in my dynamic web project I have a package structure like :
be.project6
when I see the import, I see : be.JPA.project6.data.classname
I would expect that a different structure so he would know that he needs to search outside the "normal" package structure. But also with "ctrl-T" I only can see this class
I don't want to make a reference to the other project but use it like this with a jar.
I'm out of any clues at the moment, so any advise would be more then welcome.
The build path is that: a build path. A path used to build the application.
The runtime classpath of a webapp is composed from the WEB-INF/class directory, and the set of jars in WEB-INF/lib.
Remove the jar from the build path of the dynamic web project. The just drop it into the WebContent/WEB-INF/lib directory. Eclipse will automatically add all the jars in this directory to the build path, and will put them in the WEB-INF/lib directory of the deployed web application, so that they're also part of the runtime classpath.

Netbeans can't find external jar

I'm fairly new to Java and need to add an external Jar to the project in netbeans. I've created a library with that Jar using Tools --> Libraries, and added the library in the project Properties --> Libraries under compile, but it still returns "Package does not exist".
Any help?
What version of Netbeans are you using? Make sure your libraries are located outside of the project directory. Just making sure when you add the jar, you don't just add the folder containing them but the actual jar -right?
Try building the project to see if that helps.
Perhaps the library was created incorrectly. If the package structure in the JAR isn't correct, the class loader won't be able to find the .class file.
Open the JAR with WinZip and confirm the contents.

jsf and eclipse setup. Lib in Explorer is different than lib in tomcat. How come?

I am starter in JSF2.0, and I have a question related to Eclipse (I am using Helios).
1)I create a Dynamic Project
2)I add JSF project facet.
3)I choose JSF user library (I have created it using MyFaces)
All ok so far.
I notice though that in the Project Explorer in WebContent/WEB-INF/lib the lib directory is empty instead of having MyFaces jars.
The application works fine though.
I looked into this and the jars are actually being placed in the corresponding lib directory of the app deployed under wtpwebapps of the Tomcat instance of eclipse in the .pluggins directory.
Ok, it works but IMHO it is incorrect to have the Project Explorer inconsistent with the directories actually deployed.
I.e. lib is shown empty in Project Explorer but with jars under wtpwebapps.
Am I wrong to dislike this inconsistency?
Is this how it should work or am I doing something wrong in the way I am setting my project?
Thanks!
That's normal for user-definied libraries. It's listed in libraries folder of the Java Resources folder. It's just an extra layer on managing libraries. If you dislike this, then choose Disable Library Configuration in the wizard and drop the JAR's in /WEB-INF/lib yourself.

Categories

Resources