You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Andrew Willerding <aw...@itsurcom.com> on 2015/06/12 15:40:53 UTC

Trouble with Web app deployment

Hi,

I am using Cayenne 4.0 for the first time with a Web app and I'm having 
trouble configuring it to create the ObjectContext I can access within 
my app.  When I attempt to start Tomcat and load my app I'm getting the 
following error:

SEVERE: Servlet.service() for servlet [CSCTCBridgeWeb] in context with 
path [/CSCTCBridgeWeb] threw exception
org.apache.cayenne.di.DIRuntimeException: Error instantiating class 
'org.apache.cayenne.velocity.VelocitySQLTemplateProcessor'

Caused by: java.lang.NoClassDefFoundError: 
org/apache/commons/lang/StringUtils
     at 
org.apache.velocity.runtime.VelocimacroFactory.initVelocimacro(VelocimacroFactory.java:189)
     at 
org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:261)
     at 
org.apache.cayenne.velocity.VelocitySQLTemplateProcessor.<init>(VelocitySQLTemplateProcessor.java:117)

And yet I have the proper library files in the Java path - or at least I 
believe I do...

My web.xml looks like this...

     <context-param>
<param-name>cayenne.configuration.path</param-name>
         <param-value>/WEB-INF/DBConfig</param-value>
     </context-param>
     <context-param>
         <param-name>configuration-location</param-name>
         <param-value>/WEB-INF/DBConfig</param-value>
     </context-param>

     <filter>
<filter-name>cayenne-CSCTCBridgeWeb</filter-name>
<filter-class>org.apache.cayenne.configuration.web.CayenneFilter</filter-class>
     </filter>

      <filter-mapping>
<filter-name>cayenne-CSCTCBridgeWeb</filter-name>
         <url-pattern>/*</url-pattern>
      </filter-mapping>

with the appropriate cayenne-CSCTCBridgeWeb.xml file in the 
/WEB-INF/DBConfig directory.

Any guidance on what I might be doing incorrectly would be appreciated.

Thanks,

Andrew




Re: Trouble with Web app deployment

Posted by Andrew Willerding <aw...@itsurcom.com>.

On 06/12/2015 10:27 AM, Tony Giaccone wrote:
> Andrew,
>
> The problem is your class loader can't find the jar files. I'd use 
> netbeans to create a war file then see what's missing from WEB-INF/lib.
>
> You're not adding everything you need to the classpath.

I added the commonslang3-3.4 to the project and this is what the WAR 
file now contains.  It looks like everything is there...

-rw-r--r-- 1 willerd willerd  42K Jun 12 11:54 cayenne-client-4.0.M2.jar
-rw-r--r-- 1 willerd willerd  60K Jun 12 11:54 cayenne-crypto-4.0.M2.jar
-rw-r--r-- 1 willerd willerd  60K Jun 12 11:54 cayenne-di-4.0.M2.jar
-rw-r--r-- 1 willerd willerd  59K Jun 12 11:54 cayenne-lifecycle-4.0.M2.jar
-rw-r--r-- 1 willerd willerd 2.1M Jun 12 11:54 cayenne-server-4.0.M2.jar
-rw-r--r-- 1 willerd willerd 135K Jun 12 11:54 cayenne-tools-4.0.M2.jar
-rw-r--r-- 1 willerd willerd 562K Jun 12 11:54 commons-collections-3.2.1.jar
-rw-r--r-- 1 willerd willerd 425K Jun 12 11:54 commons-lang3-3.4.jar
-rw-r--r-- 1 willerd willerd  52K Jun 12 11:54 commons-logging-1.1.jar
-rw-r--r-- 1 willerd willerd 575K Jun 12 11:54 joda-time-2.5.jar
-rw-r--r-- 1 willerd willerd  37K Jun 12 11:54 log4j-1.2-api-2.2.jar
-rw-r--r-- 1 willerd willerd 131K Jun 12 11:54 log4j-api-2.2.jar
-rw-r--r-- 1 willerd willerd 808K Jun 12 11:54 log4j-core-2.2.jar
-rw-r--r-- 1 willerd willerd  58K Jun 12 11:54 log4j-flume-ng-2.2.jar
-rw-r--r-- 1 willerd willerd  32K Jun 12 11:54 log4j-iostreams-2.2.jar
-rw-r--r-- 1 willerd willerd  13K Jun 12 11:54 log4j-jcl-2.2.jar
-rw-r--r-- 1 willerd willerd  31K Jun 12 11:54 log4j-taglib-2.2.jar
-rw-r--r-- 1 willerd willerd  24K Jun 12 11:54 log4j-web-2.2.jar
-rw-r--r-- 1 willerd willerd 829K Jun 12 11:54 
mysql-connector-java-5.1.25-bin.jar
-rw-r--r-- 1 willerd willerd 412K Jun 12 11:54 velocity-1.6.3.jar
-rw-r--r-- 1 willerd willerd 518K Jun 12 11:54 vpp-2.2.1.jar



>
>
> Tony
>
> On 6/12/15 10:20 AM, Andrew Willerding wrote:
>>
>>
>> On 06/12/2015 10:06 AM, Mike Kienenberger wrote:
>>> On Fri, Jun 12, 2015 at 9:40 AM, Andrew Willerding
>>> <aw...@itsurcom.com> wrote:
>>>> app.  When I attempt to start Tomcat and load my app I'm getting the
>>> Which version of tomcat?
>> I'm using 8.0.3 which comes with Netbeans version 8.0.2.  It's all 
>> run from the Netbeans environment for now...
>>>
>>>
>>>> Caused by: java.lang.NoClassDefFoundError:
>>>> org/apache/commons/lang/StringUtils
>>> Which commons lang version?
>> I'm including the one bundled with Cayenne - commons-collections-3.2.1
>>>
>>>> And yet I have the proper library files in the Java path - or at 
>>>> least I
>>> And where specifically do you have cayenne and commons-lang installed?
>> I'm deploying the app as any other Netbeans app so the libraries 
>> should automatically be added to the path
>>
>>
>


Re: Trouble with Web app deployment

Posted by Tony Giaccone <an...@nytimes.com>.
Andrew,

The problem is your class loader can't find the jar files. I'd use 
netbeans to create a war file then see what's missing from WEB-INF/lib.

You're not adding everything you need to the classpath.


Tony

On 6/12/15 10:20 AM, Andrew Willerding wrote:
>
>
> On 06/12/2015 10:06 AM, Mike Kienenberger wrote:
>> On Fri, Jun 12, 2015 at 9:40 AM, Andrew Willerding
>> <aw...@itsurcom.com> wrote:
>>> app.  When I attempt to start Tomcat and load my app I'm getting the
>> Which version of tomcat?
> I'm using 8.0.3 which comes with Netbeans version 8.0.2.  It's all run 
> from the Netbeans environment for now...
>>
>>
>>> Caused by: java.lang.NoClassDefFoundError:
>>> org/apache/commons/lang/StringUtils
>> Which commons lang version?
> I'm including the one bundled with Cayenne - commons-collections-3.2.1
>>
>>> And yet I have the proper library files in the Java path - or at 
>>> least I
>> And where specifically do you have cayenne and commons-lang installed?
> I'm deploying the app as any other Netbeans app so the libraries 
> should automatically be added to the path
>
>


Re: Trouble with Web app deployment

Posted by Andrus Adamchik <an...@objectstyle.org>.
> On Jun 12, 2015, at 5:37 PM, Mike Kienenberger <mk...@gmail.com> wrote:
> 
> Hah!   Well, you might want to hold off on that, as I took a different
> approach to the velocity issue -- I joined the project and am working
> on a new release :)

This is very nice :) Good luck with it.

>> And we do always have the option of using the velocity release that
>> internalizes all dependencies so that it has no external dependencies.
>> I'll have to look at these again, but I think it packages them.
> 
> No, I'm wrong.  It doesn't rename/repackage them, it only unpacks
> them, so that's not helpful.

Compartmentalizing Velocity dependency should be fairly easy. So we'll be still using it going forward, just that it won't be required. In general I think making Cayenne self-contained is a worthy goal. And it is a low-hanging fruit also.

Andrus

Re: Trouble with Web app deployment

Posted by Mike Kienenberger <mk...@gmail.com>.
Thanks.  I'll look into that for the next velocity release.

On Sat, Jun 13, 2015 at 11:43 AM, Dirk Olmes <di...@xanthippe.ping.de> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 06/12/2015 04:41 PM, Mike Kienenberger wrote:
>> On Fri, Jun 12, 2015 at 10:37 AM, Mike Kienenberger
>> <mk...@gmail.com> wrote:
>>> And we do always have the option of using the velocity release
>>> that internalizes all dependencies so that it has no external
>>> dependencies. I'll have to look at these again, but I think it
>>> packages them.
>>
>> No, I'm wrong.  It doesn't rename/repackage them, it only unpacks
>> them, so that's not helpful.
>
> Using maven-shade-plugin you should be able to build a version of
> velocity that puts all (or only some) of its dependencies under a
> different package name into the velocity jar.
>
> - -dirk
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2
>
> iEYEARECAAYFAlV8T60ACgkQASL+9Yb0srf3uACfR1xgvvCFP6cwKBAiuocz1rT0
> dL0An08MRo430lnURisTgCeSMAOHkep7
> =DATJ
> -----END PGP SIGNATURE-----

Re: Trouble with Web app deployment

Posted by Dirk Olmes <di...@xanthippe.ping.de>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 06/12/2015 04:41 PM, Mike Kienenberger wrote:
> On Fri, Jun 12, 2015 at 10:37 AM, Mike Kienenberger
> <mk...@gmail.com> wrote:
>> And we do always have the option of using the velocity release
>> that internalizes all dependencies so that it has no external
>> dependencies. I'll have to look at these again, but I think it
>> packages them.
> 
> No, I'm wrong.  It doesn't rename/repackage them, it only unpacks 
> them, so that's not helpful.

Using maven-shade-plugin you should be able to build a version of
velocity that puts all (or only some) of its dependencies under a
different package name into the velocity jar.

- -dirk

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iEYEARECAAYFAlV8T60ACgkQASL+9Yb0srf3uACfR1xgvvCFP6cwKBAiuocz1rT0
dL0An08MRo430lnURisTgCeSMAOHkep7
=DATJ
-----END PGP SIGNATURE-----

Re: Trouble with Web app deployment

Posted by Mike Kienenberger <mk...@gmail.com>.
On Fri, Jun 12, 2015 at 10:37 AM, Mike Kienenberger <mk...@gmail.com> wrote:
> And we do always have the option of using the velocity release that
> internalizes all dependencies so that it has no external dependencies.
> I'll have to look at these again, but I think it packages them.

No, I'm wrong.  It doesn't rename/repackage them, it only unpacks
them, so that's not helpful.

Re: Trouble with Web app deployment

Posted by Mike Kienenberger <mk...@gmail.com>.
Hah!   Well, you might want to hold off on that, as I took a different
approach to the velocity issue -- I joined the project and am working
on a new release :)

And we do always have the option of using the velocity release that
internalizes all dependencies so that it has no external dependencies.
I'll have to look at these again, but I think it packages them.

On Fri, Jun 12, 2015 at 10:34 AM, Andrus Adamchik
<an...@objectstyle.org> wrote:
> (taking to dev)
>
> Yeah, Velocity is the dirtiest of the remaining Cayenne dependencies that drags a bunch of other things into the stack.
>
> I am thinking of creating a pluggable syntax for SQLTemplate. By default Cayenne would provide a simple parser that is a subset of Velocity, but without Velocity (support for $var variables, #bind, #result and other Cayenne directives). And moving full Velocity integration into a separate module to avoid the dependency tail.
>
> Andrus
>
>> On Jun 12, 2015, at 5:27 PM, Mike Kienenberger <mk...@gmail.com> wrote:
>>
>> On Fri, Jun 12, 2015 at 10:20 AM, Andrew Willerding
>> <aw...@itsurcom.com> wrote:
>>>> Which commons lang version?
>>>
>>> I'm including the one bundled with Cayenne - commons-collections-3.2.1
>>
>> That's not a commons-lang library.   That's commons-collections.
>>
>> I took a quick peek at the cayenne binary distribution, and we do not
>> distribute commons-lang.
>>
>> The version of velocity distributed is 1.6.3.
>>
>> The dependency there is:
>>
>> jar.commons-lang.version= 2.4
>>
>> So you will need 2.4, 2.5, or 2.6 (2.4 is the safest if you have no
>> other commons-lang 2.x dependencies).
>>
>

Re: Trouble with Web app deployment

Posted by Andrus Adamchik <an...@objectstyle.org>.
(taking to dev)

Yeah, Velocity is the dirtiest of the remaining Cayenne dependencies that drags a bunch of other things into the stack.

I am thinking of creating a pluggable syntax for SQLTemplate. By default Cayenne would provide a simple parser that is a subset of Velocity, but without Velocity (support for $var variables, #bind, #result and other Cayenne directives). And moving full Velocity integration into a separate module to avoid the dependency tail.

Andrus

> On Jun 12, 2015, at 5:27 PM, Mike Kienenberger <mk...@gmail.com> wrote:
> 
> On Fri, Jun 12, 2015 at 10:20 AM, Andrew Willerding
> <aw...@itsurcom.com> wrote:
>>> Which commons lang version?
>> 
>> I'm including the one bundled with Cayenne - commons-collections-3.2.1
> 
> That's not a commons-lang library.   That's commons-collections.
> 
> I took a quick peek at the cayenne binary distribution, and we do not
> distribute commons-lang.
> 
> The version of velocity distributed is 1.6.3.
> 
> The dependency there is:
> 
> jar.commons-lang.version= 2.4
> 
> So you will need 2.4, 2.5, or 2.6 (2.4 is the safest if you have no
> other commons-lang 2.x dependencies).
> 


Re: Trouble with Web app deployment

Posted by Andrew Willerding <aw...@itsurcom.com>.

On 06/12/2015 12:07 PM, Mike Kienenberger wrote:
> On 06/12/2015 10:27 AM, Mike Kienenberger wrote:
>>> So you will need 2.4, 2.5, or 2.6 (2.4 is the safest if you have no
>>> other commons-lang 2.x dependencies).
> On Fri, Jun 12, 2015 at 12:02 PM, Andrew Willerding
> <aw...@itsurcom.com> wrote:
>> I added apache commons-lang3-3.4 to the project and it doesn't appear to
>> have made a difference.  The same error is generated
> 3.4 != [2.4, 2.5, or 2.6]
>
> commons-lang3 != commons-lang.
Hehe.  Of course - as I was looking for the jar file I was thinking 2.4 
but grabbed 3.4.  Of course using 2.4 did the trick.

Thanks for your patience and help.



Andrew




Re: Trouble with Web app deployment

Posted by Mike Kienenberger <mk...@gmail.com>.
On 06/12/2015 10:27 AM, Mike Kienenberger wrote:
>> So you will need 2.4, 2.5, or 2.6 (2.4 is the safest if you have no
>> other commons-lang 2.x dependencies).

On Fri, Jun 12, 2015 at 12:02 PM, Andrew Willerding
<aw...@itsurcom.com> wrote:
> I added apache commons-lang3-3.4 to the project and it doesn't appear to
> have made a difference.  The same error is generated

3.4 != [2.4, 2.5, or 2.6]

commons-lang3 != commons-lang.

Re: Trouble with Web app deployment

Posted by Andrew Willerding <aw...@itsurcom.com>.

On 06/12/2015 10:27 AM, Mike Kienenberger wrote:
> On Fri, Jun 12, 2015 at 10:20 AM, Andrew Willerding
> <aw...@itsurcom.com> wrote:
>>> Which commons lang version?
>> I'm including the one bundled with Cayenne - commons-collections-3.2.1
> That's not a commons-lang library.   That's commons-collections.
>
> I took a quick peek at the cayenne binary distribution, and we do not
> distribute commons-lang.
>
> The version of velocity distributed is 1.6.3.
>
> The dependency there is:
>
> jar.commons-lang.version= 2.4
>
> So you will need 2.4, 2.5, or 2.6 (2.4 is the safest if you have no
> other commons-lang 2.x dependencies).
I added apache commons-lang3-3.4 to the project and it doesn't appear to 
have made a difference.  The same error is generated


Re: Trouble with Web app deployment

Posted by Mike Kienenberger <mk...@gmail.com>.
On Fri, Jun 12, 2015 at 10:20 AM, Andrew Willerding
<aw...@itsurcom.com> wrote:
>> Which commons lang version?
>
> I'm including the one bundled with Cayenne - commons-collections-3.2.1

That's not a commons-lang library.   That's commons-collections.

I took a quick peek at the cayenne binary distribution, and we do not
distribute commons-lang.

The version of velocity distributed is 1.6.3.

The dependency there is:

jar.commons-lang.version= 2.4

So you will need 2.4, 2.5, or 2.6 (2.4 is the safest if you have no
other commons-lang 2.x dependencies).

Re: Trouble with Web app deployment

Posted by Andrew Willerding <aw...@itsurcom.com>.

On 06/12/2015 10:06 AM, Mike Kienenberger wrote:
> On Fri, Jun 12, 2015 at 9:40 AM, Andrew Willerding
> <aw...@itsurcom.com> wrote:
>> app.  When I attempt to start Tomcat and load my app I'm getting the
> Which version of tomcat?
I'm using 8.0.3 which comes with Netbeans version 8.0.2.  It's all run 
from the Netbeans environment for now...
>
>
>> Caused by: java.lang.NoClassDefFoundError:
>> org/apache/commons/lang/StringUtils
> Which commons lang version?
I'm including the one bundled with Cayenne - commons-collections-3.2.1
>
>> And yet I have the proper library files in the Java path - or at least I
> And where specifically do you have cayenne and commons-lang installed?
I'm deploying the app as any other Netbeans app so the libraries should 
automatically be added to the path



Re: Trouble with Web app deployment

Posted by Mike Kienenberger <mk...@gmail.com>.
On Fri, Jun 12, 2015 at 9:40 AM, Andrew Willerding
<aw...@itsurcom.com> wrote:
> app.  When I attempt to start Tomcat and load my app I'm getting the

Which version of tomcat?


> Caused by: java.lang.NoClassDefFoundError:
> org/apache/commons/lang/StringUtils

Which commons lang version?

> And yet I have the proper library files in the Java path - or at least I

And where specifically do you have cayenne and commons-lang installed?