Problems getting started

1 view
Skip to first unread message

Cafesolo

unread,
Oct 30, 2008, 12:55:42 PM10/30/08
to Salve
Hello,

I'm trying to integrate Salve in my Wicket/Guice/warp-persist/
Hibernate stack.

I've built Salve from the sources, added the -javaagent:path/to/salve-
agent.jar switch to the JVM parameters and modified the Guice
initialization code as shown below:

injector = Guice.createInjector(
createWarpPersistenceModule(), new GuiceModule());
injector.getInstance(PersistenceService.class).start();
addComponentInstantiationListener(new GuiceComponentInjector(this,
injector));
DependencyLibrary.addLocator(new GuiceBeanLocator(injector));

I added the @Dependency annotation to one of my entities as follows:

@Entity
public class MyEntity extends AbstractEntity {

@Dependency
@Transient
private MyEntityRepository myEntityRepository;
private String name;

// getters and setters, etc.

public void foo() {
System.out.println("myEntity.myEntityRepository = " +
myEntityRepository);
}

}

And finally added code to call myEntity.foo() when I click a link in
one of my Wicket pages. After launching the web application and
clicking that link, the code prints "myEntity.myEntityRepository =
null" in the console.

Conclusion: the MyEntityRepository dependency is not being injected.

Any ideas?

Regards,
-- Cafesolo

Igor Vaynberg

unread,
Oct 30, 2008, 1:08:53 PM10/30/08
to salve...@googlegroups.com
if your dependency is null then your class was not instrumented.

how are you launching the app?

do you have salve.xml in the proper place and does it have the proper
package declaration?

also you wont need @Transient annotation because the field will be
removed through instrumentation.

-igor

Leandro Ezequiel Lovisolo

unread,
Oct 30, 2008, 1:14:33 PM10/30/08
to salve...@googlegroups.com
I'm launching the app from my embedded Jetty webserver. I have a
salve.xml file in my website/META-INF directory with the following
contents:

<config>
<package name="my.stack.demo">
<instrumentor class="salve.depend.DependencyInstrumentor"/>
</package>
</config>

Igor Vaynberg

unread,
Oct 30, 2008, 1:36:17 PM10/30/08
to salve...@googlegroups.com
ok, i just added some debugging stuff to the agent to help you
diagnose what goes wrong

start your app as usual and add -Dsalve.agent.debug=true

i havent tested the debugging code yet so let me know if it works ok

-igor

Edgar Merino

unread,
Oct 30, 2008, 3:34:19 PM10/30/08
to salve...@googlegroups.com
I was having the same problems as you, my projects were using ant
and I actually didn't want to switch to maven. However I had some free
time and I decided to migrate these projects to maven (specially because
I wanted to use salve and the maven plugin seemed to be the best
option). Now, no more problems regarding salve, if you have the time you
might think about migrating your projects to maven too.

Edgar Merino




Igor Vaynberg escribió:

Cafesolo

unread,
Oct 30, 2008, 9:33:55 PM10/30/08
to Salve
Igor:

I've updated and rebuilt Salve and added the -Dsalve.agent.debug=true
parameter. Now when I launch the web app I see thousands of lines
printed in the console that look like this:

Salve:Agent:Instrumenting my/stack/demo/Launcher using []
Salve:Agent:Instrumenting org/mortbay/jetty/Connector using []
Salve:Agent:Instrumenting org/mortbay/component/LifeCycle using []
Salve:Agent:Instrumenting org/mortbay/io/Buffers using []
Salve:Agent:Instrumenting org/mortbay/jetty/Handler using []
Salve:Agent:Instrumenting org/mortbay/jetty/Server using []
Salve:Agent:Instrumenting org/mortbay/util/Attributes using []
...
...
...
Salve:Agent:Instrumenting my/stack/demo/MyEntity using []
...
...
...

The debug info says that the MyEntity class is being instrumented.
However, I'm still getting a null pointer.

Edgar:

While switching to Maven could fix the problem, I'm sure it's still
possible to get Salve running without mavenizing my app. I really like
to have full control over the project structure and dependencies, so I
prefer to dig deeper before abandoning ant.

What else can I try?

Cheers,
-- Cafesolo

On Oct 30, 2:36 pm, "Igor Vaynberg" <igor.vaynb...@gmail.com> wrote:
> ok, i just added some debugging stuff to the agent to help you
> diagnose what goes wrong
>
> start your app as usual and add -Dsalve.agent.debug=true
>
> i havent tested the debugging code yet so let me know if it works ok
>
> -igor
>
> On Thu, Oct 30, 2008 at 10:14 AM, Leandro Ezequiel Lovisolo
>
> <cafes...@gmail.com> wrote:
>
> > I'm launching the app from my embedded Jetty webserver. I have a
> > salve.xml file in my website/META-INF directory with the following
> > contents:
>
> > <config>
> >        <package name="my.stack.demo">
> >                <instrumentor class="salve.depend.DependencyInstrumentor"/>
> >        </package>
> > </config>
>
> > On Thu, Oct 30, 2008 at 2:08 PM, Igor Vaynberg <igor.vaynb...@gmail.com> wrote:
>
> >> if your dependency is null then your class was not instrumented.
>
> >> how are you launching the app?
>
> >> do you have salve.xml in the proper place and does it have the proper
> >> package declaration?
>
> >> also you wont need @Transient annotation because the field will be
> >> removed through instrumentation.
>
> >> -igor
>

Igor Vaynberg

unread,
Oct 31, 2008, 12:38:33 AM10/31/08
to salve...@googlegroups.com
Actually the empty brackets mean that no instrumentors are used. Looks
like the agent doesn't see the config file.

Where exactly is salve.xml?

-igor

Leandro Ezequiel Lovisolo

unread,
Oct 31, 2008, 8:21:24 AM10/31/08
to salve...@googlegroups.com
It's located inside the web app's META-INF directory (which is next to WEB-INF).

Is that ok?

-- Cafesolo

francisco treacy

unread,
Oct 31, 2008, 9:36:43 AM10/31/08
to salve...@googlegroups.com
i would guess that is not the correct placement for META-INF/salve.xml

say your webapp layout is:

/
/META-INF (1)
/WEB-INF/classes
/WEB-INF/classes/META-INF (2)

try including salve.xml in (2), not in (1)

otherwise look at the approach taken in gluw
(http://code.google.com/p/gluw/source/browse/trunk/gluw/src/gluw/agent/GluwTransformer.java)
to implement your own package/instrumentor lookup - it might help.

francisco

Leandro Ezequiel Lovisolo

unread,
Oct 31, 2008, 9:54:57 AM10/31/08
to salve...@googlegroups.com
Hi Francisco,

I modified my web app layout to (2), but my entity is still not being
instrumented.

Any ideas before trying the Gluw approach?

Cheers,
-- Cafesolo

Kristof Jozsa

unread,
Oct 31, 2008, 9:57:58 AM10/31/08
to salve...@googlegroups.com
If your project is a basic one so you can pack up your project easily,
we (me for sure) could take a look..

Kristof

On Fri, Oct 31, 2008 at 2:54 PM, Leandro Ezequiel Lovisolo

francisco treacy

unread,
Oct 31, 2008, 10:25:07 AM10/31/08
to salve...@googlegroups.com
yes, if you send a simple app with your problem i could also take a look.

make sure you have WEB-INF/classes/META-INF/salve.xml once it's
deployed, and that your entity's base package is associated to
DependencyInstrumentor.

i actually asked igor if he could open salve to other configuration
implementations other than the xml file. he then restructured salve so
that anyone could provide an impl of Config, as i did in gluw (class
GluwConfig implements Config). you can just grab that code and use it
in your app - in 5 min.

francisco

pd: asi q estas en ingenieria en la uba? saludos por alla :)

Reply all
Reply to author
Forward
0 new messages