Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploading a file using a file or an inputstream doesn't seem to work. #22

Closed
areese opened this issue Oct 17, 2013 · 14 comments
Closed

Comments

@areese
Copy link
Contributor

areese commented Oct 17, 2013

    <dependency>
        <groupId>org.jfrog.artifactory.client</groupId>
        <artifactId>api</artifactId>
        <version>0.8</version>
        <type>jar</type>
    </dependency>

    <dependency>
        <groupId>org.jfrog.artifactory.client</groupId>
        <artifactId>services</artifactId>
        <version>0.8</version>
        <type>jar</type>
    </dependency>

package bugs;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

import org.jfrog.artifactory.client.Artifactory;
import org.jfrog.artifactory.client.ArtifactoryClient;
import org.jfrog.artifactory.client.RepositoryHandle;
import org.jfrog.artifactory.client.UploadableArtifact;

public class TestUpload {
private static final Artifactory af = ArtifactoryClient.create(
"http://test.artifactory/artifactory/",
"areese",
"password");

private static final RepositoryHandle repository = af
        .repository("areese-ssh-proxy-test");

public static void main(String[] args) throws Exception {
    File file = new File(
            "src/main/yinst/package.txt");
    InputStream is = new FileInputStream(file);

    // UploadableArtifact uploadIs = repository
    // .upload("/com/yahoo/dps/sshd/0.0.1-SNAPSHOT/package.txt",
    // is);
    //uploadIs.doUpload();

    UploadableArtifact uploadFile = repository
            .upload("/com/yahoo/dps/sshd/0.0.1-SNAPSHOT/package.txt",
                    file);
    uploadFile.doUpload();
}

}

File Upload output:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/home/y/tmp/m2-repository/ch/qos/logback/logback-classic/1.0.9/logback-classic-1.0.9.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/home/y/tmp/m2-repository/org/slf4j/slf4j-log4j12/1.7.5/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
Exception in thread "main" groovy.lang.MissingMethodException: No signature of method: org.jfrog.artifactory.client.impl.ArtifactoryImpl.put() is applicable for argument types: (org.codehaus.groovy.ru
ntime.GStringImpl, java.util.LinkedHashMap, java.io.BufferedInputStream, java.util.LinkedHashMap, java.lang.Class, groovyx.net.http.ContentType, java.lang.Long) values: [/com/ya
hoo/dps/sshd/0.0.1-SNAPSHOT/package.txt, ...]
Possible solutions: wait(), any(), dump(), grep(), find()
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:55)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:51)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.jfrog.artifactory.client.impl.UploadableArtifactImpl$_uploadContent_closure1.doCall(UploadableArtifactImpl.groovy:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:901)
at groovy.lang.Closure.call(Closure.java:415)
at groovy.lang.Closure.call(Closure.java:428)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.withStream(DefaultGroovyMethods.java:17421)
at org.codehaus.groovy.runtime.dgm$953.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.jfrog.artifactory.client.impl.UploadableArtifactImpl.uploadContent(UploadableArtifactImpl.groovy:60)
at org.jfrog.artifactory.client.impl.UploadableArtifactImpl.this$3$uploadContent(UploadableArtifactImpl.groovy)
at org.jfrog.artifactory.client.impl.UploadableArtifactImpl$this$3$uploadContent.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at org.jfrog.artifactory.client.impl.UploadableArtifactImpl.doUpload(UploadableArtifactImpl.groovy:52)
at bugs.TestUpload.main(TestUpload.java:34)

InputStream upload output:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/home/y/tmp/m2-repository/ch/qos/logback/logback-classic/1.0.9/logback-classic-1.0.9.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/home/y/tmp/m2-repository/org/slf4j/slf4j-log4j12/1.7.5/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
Exception in thread "main" groovy.lang.MissingMethodException: No signature of method: org.jfrog.artifactory.client.impl.ArtifactoryImpl.put() is applicable for argument types: (org.codehaus.groovy.ru
ntime.GStringImpl, java.util.LinkedHashMap, java.io.FileInputStream, java.util.LinkedHashMap, java.lang.Class, groovyx.net.http.ContentType, java.lang.Integer) values: [/com/yah
oo/dps/sshd/0.0.1-SNAPSHOT/package.txt, ...]
Possible solutions: wait(), any(), dump(), grep(), find()
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:55)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:51)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.jfrog.artifactory.client.impl.UploadableArtifactImpl$_uploadContent_closure1.doCall(UploadableArtifactImpl.groovy:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:901)
at groovy.lang.Closure.call(Closure.java:415)
at groovy.lang.Closure.call(Closure.java:428)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.withStream(DefaultGroovyMethods.java:17421)
at org.codehaus.groovy.runtime.dgm$953.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.jfrog.artifactory.client.impl.UploadableArtifactImpl.uploadContent(UploadableArtifactImpl.groovy:60)
at org.jfrog.artifactory.client.impl.UploadableArtifactImpl.this$3$uploadContent(UploadableArtifactImpl.groovy)
at org.jfrog.artifactory.client.impl.UploadableArtifactImpl$this$3$uploadContent.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at org.jfrog.artifactory.client.impl.UploadableArtifactImpl.doUpload(UploadableArtifactImpl.groovy:52)
at bugs.TestUpload.main(TestUpload.java:29)

@jbaruch
Copy link
Contributor

jbaruch commented Oct 17, 2013

Thanks for reporting this.
What exactly didn't work for you?
Do you get an exception?

@areese
Copy link
Contributor Author

areese commented Oct 17, 2013

Sorry I hit enter and created it before I had copied everything. =)

@areese
Copy link
Contributor Author

areese commented Oct 18, 2013

This is the same as issue 15, but exercised a different way.

In issue 15, they used:
File testFile = new File("/path/to/libToUpload.jar");

private final String NEW_LOCAL = "http://"+username+":"+password+"@localhost:8081/artifactory";

artifactory.repository(NEW_LOCAL).upload("libs-release-local/junit/junit/4.9/juni-4.9.jar", testFile).doUpload();

I used:
private static final Artifactory af = ArtifactoryClient.create("http://test.artifactory/artifactory/", "areese", "password");

private static final RepositoryHandle repository = af.repository("areese-ssh-proxy-test");

Which I would assume passes the username/pass in.

@areese
Copy link
Contributor Author

areese commented Oct 18, 2013

the suggestion in issue 15 doesn't work:

    final String NEW_LOCAL = "http://" + username + ":" + password + "@"
            + hostname + ":" + port + "/artifactory";


    File file = new File("src/main/yinst/package.yicf");
    InputStream is = new FileInputStream(file);

    UploadableArtifact uploadIs = af
            .repository(NEW_LOCAL).upload(
            "/com/yahoo/dps/sshd/0.0.1-SNAPSHOT/package.txt", file);
    uploadIs.doUpload();

Exception in thread "main" groovy.lang.MissingMethodException: No signature of method: org.jfrog.artifactory.client.impl.ArtifactoryImpl.put() is applicable for argument types: (org.codehaus.groovy.ru
ntime.GStringImpl, java.util.LinkedHashMap, java.io.BufferedInputStream, java.util.LinkedHashMap, java.lang.Class, groovyx.net.http.ContentType, java.lang.Long) values: [/http://areese_sshd_prototype:
password@test.artifactory:4080/artifactory//com/yahoo/dps/sshd/0.0.1-SNAPSHOT/package.txt ...]
Possible solutions: wait(), dump(), any(), find(), grep()
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:55)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:51)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.jfrog.artifactory.client.impl.UploadableArtifactImpl$_uploadContent_closure1.doCall(UploadableArtifactImpl.groovy:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:901)
at groovy.lang.Closure.call(Closure.java:415)
at groovy.lang.Closure.call(Closure.java:428)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.withStream(DefaultGroovyMethods.java:17421)
at org.codehaus.groovy.runtime.dgm$953.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.jfrog.artifactory.client.impl.UploadableArtifactImpl.uploadContent(UploadableArtifactImpl.groovy:60)
at org.jfrog.artifactory.client.impl.UploadableArtifactImpl.this$3$uploadContent(UploadableArtifactImpl.groovy)
at org.jfrog.artifactory.client.impl.UploadableArtifactImpl$this$3$uploadContent.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at org.jfrog.artifactory.client.impl.UploadableArtifactImpl.doUpload(UploadableArtifactImpl.groovy:52)
at bugs.TestUpload.test2(TestUpload.java:55)
at bugs.TestUpload.main(TestUpload.java:26)

@jbaruch
Copy link
Contributor

jbaruch commented Oct 21, 2013

Why do you embed the username the password and the url in the repository name and don't put the repository name itself?
The url, username and password are provided during the creation of the client. Repository name is, well, the repository name.

@areese
Copy link
Contributor Author

areese commented Oct 21, 2013

I tried that because of issue 15, which made me think that was a fix.

It fails either way. I actually have to pass user/pass to the repository, because at some point I need to use Header based auth instead of user/path auth, but that's a different problem.

@jbaruch
Copy link
Contributor

jbaruch commented Oct 22, 2013

Well, there is no chance it is going to work this way. The repository() method expects only repository name. Not a full Artifactory URL, not a username, not a password, just the repository name.

@areese
Copy link
Contributor Author

areese commented Oct 22, 2013

Yeah it doesn't work either way, see the first comment. :)

package bugs;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

import org.jfrog.artifactory.client.Artifactory;
import org.jfrog.artifactory.client.ArtifactoryClient;
import org.jfrog.artifactory.client.RepositoryHandle;
import org.jfrog.artifactory.client.UploadableArtifact;

public class TestUpload {
private static final Artifactory af = ArtifactoryClient.create(
"http://test.artifactory/artifactory/",
"areese",
"password");

private static final RepositoryHandle repository = af
.repository("areese-ssh-proxy-test");

public static void main(String[] args) throws Exception {
File file = new File(
"src/main/yinst/package.txt");
InputStream is = new FileInputStream(file);

// UploadableArtifact uploadIs = repository
// .upload("/com/yahoo/dps/sshd/0.0.1-SNAPSHOT/package.txt",
// is);
//uploadIs.doUpload();

UploadableArtifact uploadFile = repository
        .upload("/com/yahoo/dps/sshd/0.0.1-SNAPSHOT/package.txt",
                file);
uploadFile.doUpload();

}

}

@jbaruch
Copy link
Contributor

jbaruch commented Oct 23, 2013

Did you look at the tests? I just ran them again and they are fine.

@areese
Copy link
Contributor Author

areese commented Oct 25, 2013

The tests pass fine, but running it from a java app in eclipse it fails.
I've had to go deal with other things, but I'll come back to this.

@jbaruch
Copy link
Contributor

jbaruch commented Oct 25, 2013

If the tests are fine on your side, I'd suggest starting altering them towards your needs and see where they break. Then we'll have the cause and will be able to fix it.

@areese
Copy link
Contributor Author

areese commented Oct 25, 2013

That's where I ran out of time. I copied the url from the tests to my java project, and it still failed, and I haven't had a chance to come back and figure out why it acts differently.

@jbaruch
Copy link
Contributor

jbaruch commented Oct 25, 2013

NP, let me know your findings when you're back on it.

@areese
Copy link
Contributor Author

areese commented Nov 6, 2013

We ended up writing a ning service provider for the api, and using that instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants