Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Eclipse WTP Web Service, Axis2, and JAR project dependencies
Eclipse WTP Web Service, Axis2, and JAR project dependencies [message #687690] Thu, 23 June 2011 02:41 Go to next message
James Cleland is currently offline James ClelandFriend
Messages: 5
Registered: June 2011
Junior Member
Searching didn't return any results on this, I apologize if it's been answered.

I'm using Helios with WTP and Axis2 Tools to generate a web service from a dynamic web project class. There are numerous tutorials on this and it's pretty straight forward. Here's where I throw myself a curve ball:

I have another library project that is a dependancy of my web service project. References and build path are configured, of course, so it builds fine. The dependancy is apparently not deployed to the server as I get a classnotfoundexception on an interface that is defined in the library project that my WS depends on.

How do I go about solving this problem? I could build a JAR from a jardesc and add it to my web service project, but that manual step annoys me. Is there a way to say, essentially, "This project produces a library and my web service depends on it. Either a JAR of my library or its class files need to be published to the server and it needs to be part of the automatic build/publish?

Here are some relevant versions:
Axis2 Tools 1.1.100
Eclipse Web Developer Tools 3.2.4
JAX-WS Tools 1.0.2
WST Server Adapter Plug-in Developer Resources 3.2.1
WST Server Adapters 3.2.1
WST Web Plug-in Developer Resources 3.2.4

Thanks in advance for suggestions!
Re: Eclipse WTP Web Service, Axis2, and JAR project dependencies [message #688383 is a reply to message #687690] Fri, 24 June 2011 15:33 Go to previous messageGo to next message
James Cleland is currently offline James ClelandFriend
Messages: 5
Registered: June 2011
Junior Member
So the more accurate and concise question appears to be: How do you build a jar in your workspace, reference it with another project in the same workspace, and have the JAR publish to your server. This is what is not happening.

The dependency builds fine. I have an ANT script that automatically builds the JAR in the dependency project root directory. The dependant project builds fine with the project dependency configured in the Java Build Path (Libraries->Add JAR...). I have NOT added the dependency as a project reference, just added the JAR and checked it under Java Build Path->Order and Export.

My dependency is missing from the server deployment WEB-INF/lib directory. How can I make Eclipse publish this jar to the server? My next step is to add it to the deployable project's libraries and build the JAR directly into the dependant project, but this seems gross.

Re: Eclipse WTP Web Service, Axis2, and JAR project dependencies [message #688391 is a reply to message #688383] Fri, 24 June 2011 15:48 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 24-Jun-11 09:33, James Cleland wrote:
> So the more accurate and concise question appears to be: How do you
> build a jar in your workspace, reference it with another project in the
> same workspace, and have the JAR publish to your server. This is what is
> not happening.
> The dependency builds fine. I have an ANT script that automatically
> builds the JAR in the dependency project root directory. The dependant
> project builds fine with the project dependency configured in the Java
> Build Path (Libraries->Add JAR...). I have NOT added the dependency as a
> project reference, just added the JAR and checked it under Java Build
> Path->Order and Export.
> My dependency is missing from the server deployment WEB-INF/lib
> directory. How can I make Eclipse publish this jar to the server? My
> next step is to add it to the deployable project's libraries and build
> the JAR directly into the dependant project, but this seems gross.

At the risk of injecting confusion here, I would not do Add JARs or Add
External JARs from one project to get a JAR created inside another. I
think that might result in a full path in .classpath rendering this file
unportable (so, if you're committing to a version-control system, ...).

Instead, perhaps Build Path -> Libraries -> Web App Libraries? Or just
make any update the JAR from the original project to the consuming one?

On deployment...

I assume you're familiar with Preferences -> Deployment Assembly? That's
how Eclipse gives you control over deployment, however, it's not
necessary if you're not trying to run from within Eclipse and you've got
a separate build solution like ant.

There are many build solutions including pure Eclipse/non-ant, ant,
Maven, Ivy, etc. that will solve this.

This might not be very helpful, but it might be a catalyst to a solution
you come up with. I hope it helps a little.

Russ
Re: Eclipse WTP Web Service, Axis2, and JAR project dependencies [message #688528 is a reply to message #688391] Fri, 24 June 2011 21:22 Go to previous messageGo to next message
James Cleland is currently offline James ClelandFriend
Messages: 5
Registered: June 2011
Junior Member
Thank you for the reply. I read your initial comment a few times and I understand what you're suggesting: Don't build a JAR in one project and add it as a JAR in another. I will remove this and try the web app library suggestion that you made.

I'm not sure I understand the second sentence "Or just make any update the JAR from the original project to the consuming one?" Let me try adding the JAR as a web app first and see what happens.

I've looked into Deployment Assembly, but I wasn't sure it was what I wanted. Thank you for pointing this out, I am trying to run this from within Eclipse initially for debugging/testing, so maybe I can force that JAR to deploy here if nowhere else Smile

Again, I appreciate the input.
Re: Eclipse WTP Web Service, Axis2, and JAR project dependencies [message #688547 is a reply to message #688528] Fri, 24 June 2011 21:54 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 24-Jun-11 15:22, James Cleland wrote:
> Thank you for the reply. I read your initial comment a few times and I
> understand what you're suggesting: Don't build a JAR in one project and
> add it as a JAR in another. I will remove this and try the web app
> library suggestion that you made.
>
> I'm not sure I understand the second sentence "Or just make any update
> the JAR from the original project to the consuming one?" Let me try
> adding the JAR as a web app first and see what happens.
>
> I've looked into Deployment Assembly, but I wasn't sure it was what I
> wanted. Thank you for pointing this out, I am trying to run this from
> within Eclipse initially for debugging/testing, so maybe I can force
> that JAR to deploy here if nowhere else :)
>
> Again, I appreciate the input.

Sorry, I meant, "Or just make ANT update the JAR from..." Typing is
sometimes a lower motor skill and my brain doesn't notice what I've typed.
Re: Eclipse WTP Web Service, Axis2, and JAR project dependencies [message #688566 is a reply to message #688547] Fri, 24 June 2011 23:20 Go to previous messageGo to next message
James Cleland is currently offline James ClelandFriend
Messages: 5
Registered: June 2011
Junior Member
Ah, that makes sense, thanks! Typos happen.

Adding the dependency to the Web Deployment Assembly worked great for getting my JAR to publish, thanks! Now I'm seeing this:

Caused by: java.lang.ClassNotFoundException: org.apache.axis2.transport.http.AxisServlet
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)

Keeping Tomcat down. I found a thread that mentioned copying all of your axis2 jars into your project WEB-INF/lib and, sure enough, lots of them weren't in there. I also grabbed the endorsed jars from the axis2 distribution. Still, here I am. Any ideas?

James
Re: Eclipse WTP Web Service, Axis2, and JAR project dependencies [message #688739 is a reply to message #688566] Sat, 25 June 2011 14:57 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

So, there are several ways to do JARs in a web application. One is, as
you mention, to copy all of your JARs to WebContent/WEB-INF/lib. Once
you do that, however, there are two additional steps.

First, using Build Path -> Libraries -> Add (internal) JAR, you link
each JAR on that path into the project.

Second, using Preferences -> Deployment Assembly, (I think this has been
discussed) you mark all of those JARs for deployment. Otherwise, despite
that they exist in WebContent/WEB-INF/lib, they aren't deployed in the WAR.

I'm not an Axis guy, so I'll have to punt at this point and hope for
someone else to come along if the is an Axis component to this question.

Best of luck.
Re: Eclipse WTP Web Service, Axis2, and JAR project dependencies [message #689088 is a reply to message #688739] Sun, 26 June 2011 19:31 Go to previous messageGo to next message
James Cleland is currently offline James ClelandFriend
Messages: 5
Registered: June 2011
Junior Member
Thanks again Russell, I've had luck with the Web Deployment Assembly by specifying my JAR project (as a Project, under Add...). The JAR file ends up published in the wptwebapps/<project>/WEB-INF/lib directory, along with all of the axis2 JARS. My current problem is the following exception starting Tomcat from within Eclipse:

java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.NoClassDefFoundError: org/apache/axis2/transport/http/AxisServlet
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(Unknown Source)
	at java.lang.ClassLoader.defineClass(Unknown Source)
	at java.security.SecureClassLoader.defineClass(Unknown Source)
	at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2733)
	at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1124)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1612)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(Unknown Source)
	at java.lang.ClassLoader.defineClass(Unknown Source)
	at java.security.SecureClassLoader.defineClass(Unknown Source)
	at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2733)
	at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1124)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1612)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1095)
	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4350)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4659)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
	at org.apache.catalina.core.StandardService.start(StandardService.java:519)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
	... 6 more
Caused by: java.lang.ClassNotFoundException: org.apache.axis2.transport.http.AxisServlet
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
	... 33 more

AxisServlet is defined in axis2-kernel-1.4.1.jar and this file is in WEB-INF/lib, so I'm not sure why the exception. Ideas?
Re: Eclipse WTP Web Service, Axis2, and JAR project dependencies [message #689363 is a reply to message #688739] Mon, 27 June 2011 13:54 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
On 6/25/2011 10:57 AM, Russell Bateman wrote:
> So, there are several ways to do JARs in a web application. One is, as
> you mention, to copy all of your JARs to WebContent/WEB-INF/lib. Once
> you do that, however, there are two additional steps.
>
> First, using Build Path -> Libraries -> Add (internal) JAR, you link
> each JAR on that path into the project.
>
> Second, using Preferences -> Deployment Assembly, (I think this has been
> discussed) you mark all of those JARs for deployment. Otherwise, despite
> that they exist in WebContent/WEB-INF/lib, they aren't deployed in the WAR.
>
> I'm not an Axis guy, so I'll have to punt at this point and hope for
> someone else to come along if the is an Axis component to this question.
>
> Best of luck.

These two additional steps should not be necessary for jars placed in
the WebContent/WEB-INF/lib folder of the project. The jars should
automatically get published because they are under "WebContent" and WTP
handling should automatically include them in the Java Build Path as
children of the "Web App Library" classpath container. If this isn't
happening, then there is a bug somewhere.

Cheers,
Larry
Re: Eclipse WTP Web Service, Axis2, and JAR project dependencies [message #689364 is a reply to message #689088] Mon, 27 June 2011 13:57 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
On 6/26/2011 3:31 PM, James Cleland wrote:
> Thanks again Russell, I've had luck with the Web Deployment Assembly by
> specifying my JAR project (as a Project, under Add...). The JAR file
> ends up published in the wptwebapps/<project>/WEB-INF/lib directory,
> along with all of the axis2 JARS. My current problem is the following
> exception starting Tomcat from within Eclipse:
>
> java.lang.reflect.InvocationTargetException
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
> at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
> Caused by: java.lang.NoClassDefFoundError:
> org/apache/axis2/transport/http/AxisServlet
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClassCond(Unknown Source)
> at java.lang.ClassLoader.defineClass(Unknown Source)
> at java.security.SecureClassLoader.defineClass(Unknown Source)
> at
> org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2733)
>
> at
> org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1124)
>
> at
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1612)
>
> at
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
>
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClassCond(Unknown Source)
> at java.lang.ClassLoader.defineClass(Unknown Source)
> at java.security.SecureClassLoader.defineClass(Unknown Source)
> at
> org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2733)
>
> at
> org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1124)
>
> at
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1612)
>
> at
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
>
> at
> org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1095)
>
> at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
> at
> org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4350)
>
> at
> org.apache.catalina.core.StandardContext.start(StandardContext.java:4659)
> at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
> at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
> at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
> at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
> at org.apache.catalina.core.StandardService.start(StandardService.java:519)
> at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
> at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
> ... 6 more
> Caused by: java.lang.ClassNotFoundException:
> org.apache.axis2.transport.http.AxisServlet
> at
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
>
> at
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
>
> ... 33 more
> AxisServlet is defined in axis2-kernel-1.4.1.jar and this file is in
> WEB-INF/lib, so I'm not sure why the exception. Ideas?

Unfortunately, class loading mysteries can be difficult with respect to
guessing their cause, and a bit challenging to debug. Since the JVM
doesn't know where the class will be loaded from, it makes many
different attempts to load it. If one attempt fails, it tries the next
attempt to see if that will succeed. Because the JVM doesn't know which
attempt should have succeeded when they all fail, the real problem often
gets swallowed and you are left with a generic ClassNotFoundException.

During the loading process exceptions routinely get thrown and caught
internally. As a result, your stack trace doesn't show much with
respect to useful clues. You may want to enable logging at TRACE for
"org.apache.catalina.loader.WebappClassLoader". This should give you
more clues about what is actually happening.

Cheers,
Larry
Re: Eclipse WTP Web Service, Axis2, and JAR project dependencies [message #689411 is a reply to message #689363] Mon, 27 June 2011 15:38 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 27-Jun-11 07:54, Larry Isaacs wrote:
> On 6/25/2011 10:57 AM, Russell Bateman wrote:
>> So, there are several ways to do JARs in a web application. One is, as
>> you mention, to copy all of your JARs to WebContent/WEB-INF/lib. Once
>> you do that, however, there are two additional steps.
>>
>> First, using Build Path -> Libraries -> Add (internal) JAR, you link
>> each JAR on that path into the project.
>>
>> Second, using Preferences -> Deployment Assembly, (I think this has been
>> discussed) you mark all of those JARs for deployment. Otherwise, despite
>> that they exist in WebContent/WEB-INF/lib, they aren't deployed in the
>> WAR.
>>
>> I'm not an Axis guy, so I'll have to punt at this point and hope for
>> someone else to come along if the is an Axis component to this question.
>>
>> Best of luck.
>
> These two additional steps should not be necessary for jars placed in
> the WebContent/WEB-INF/lib folder of the project. The jars should
> automatically get published because they are under "WebContent" and WTP
> handling should automatically include them in the Java Build Path as
> children of the "Web App Library" classpath container. If this isn't
> happening, then there is a bug somewhere.
>
> Cheers,
> Larry

I'm glad to hear officially what the score is. This hasn't been my
observation, but then I'd have to be able to swear to the state of a
number of things in whatever project failed to deploy and I can't do
that. It was probably some other fault on my part.

Thanks, Larry.
Re: Eclipse WTP Web Service, Axis2, and JAR project dependencies [message #689520 is a reply to message #689411] Mon, 27 June 2011 18:50 Go to previous message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
On 6/27/2011 11:38 AM, Russell Bateman wrote:
> On 27-Jun-11 07:54, Larry Isaacs wrote:
>> On 6/25/2011 10:57 AM, Russell Bateman wrote:
>>> So, there are several ways to do JARs in a web application. One is, as
>>> you mention, to copy all of your JARs to WebContent/WEB-INF/lib. Once
>>> you do that, however, there are two additional steps.
>>>
>>> First, using Build Path -> Libraries -> Add (internal) JAR, you link
>>> each JAR on that path into the project.
>>>
>>> Second, using Preferences -> Deployment Assembly, (I think this has been
>>> discussed) you mark all of those JARs for deployment. Otherwise, despite
>>> that they exist in WebContent/WEB-INF/lib, they aren't deployed in the
>>> WAR.
>>>
>>> I'm not an Axis guy, so I'll have to punt at this point and hope for
>>> someone else to come along if the is an Axis component to this question.
>>>
>>> Best of luck.
>>
>> These two additional steps should not be necessary for jars placed in
>> the WebContent/WEB-INF/lib folder of the project. The jars should
>> automatically get published because they are under "WebContent" and WTP
>> handling should automatically include them in the Java Build Path as
>> children of the "Web App Library" classpath container. If this isn't
>> happening, then there is a bug somewhere.
>>
>> Cheers,
>> Larry
>
> I'm glad to hear officially what the score is. This hasn't been my
> observation, but then I'd have to be able to swear to the state of a
> number of things in whatever project failed to deploy and I can't do
> that. It was probably some other fault on my part.
>
> Thanks, Larry.

On very rare occasions I've see publishing go wrong somehow, but too
infrequently to get much of a handle on what isn't right. I've wondered
if the problem is in the publishing or whether WTP has somehow gotten
the "list" of what is in the project incorrect. If "Clean..." doesn't
fix it, that would suggest the latter. If it happens more reliably for
you, I would be curious if closing and re-opening the project would
straighten out the publishing.

Cheers,
Larry
Previous Topic:Publish working sporadically
Next Topic:HTML5 attributes in JSPs
Goto Forum:
  


Current Time: Thu Apr 18 06:10:29 GMT 2024

Powered by FUDForum. Page generated in 0.02591 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top