Seems like your container comes with Guava. What version of Guava does
it use?
On 03/02/2017 02:09 AM, Desenv wrote:
> Hi,
>
> I'm developing an application using BitcoinJ using Java JEE 7, Glassfish
> 4 server, Netbeans IDE.
>
> When debugging the application's code at method "addListener" from
> WalletAppKit the an exception shows up.
>
> Could someone help me solve this problem?
>
> Here is the code:
>
> package apkt.opreturn;
>
> import apkt.dao.jpa.GenericDaoJpa;
> import apkt.model.OpReturn;
> import apkt.service.OpReturnService;
> import com.google.common.util.concurrent.Service;
> import java.io.File;
> import java.io.IOException;
> import java.io.UnsupportedEncodingException;
> import java.util.Date;
> import java.util.logging.Level;
> import java.util.logging.Logger;
> import javax.annotation.PostConstruct;
> import javax.annotation.Resource;
> import javax.ejb.Asynchronous;
> import javax.ejb.EJB;
> import javax.ejb.Singleton;
> import javax.ejb.Startup;
> //import javax.enterprise.concurrent.ManagedThreadFactory;
> import javax.persistence.EntityManager;
> import javax.persistence.EntityManagerFactory;
> import javax.persistence.Persistence;
> import org.bitcoinj.core.Coin;
> import org.bitcoinj.core.InsufficientMoneyException;
> import org.bitcoinj.core.NetworkParameters;
> import org.bitcoinj.core.Transaction;
> import org.bitcoinj.kits.WalletAppKit;
> import org.bitcoinj.params.TestNet3Params;
> import org.bitcoinj.script.ScriptBuilder;
> import org.bitcoinj.wallet.DeterministicSeed;
> import org.bitcoinj.wallet.SendRequest;
> import org.bitcoinj.wallet.Wallet;
> import org.bitcoinj.wallet.listeners.WalletChangeEventListener;
>
> @Singleton
> @Startup
> public class Demo {
>
> @EJB
> private Demo self;
>
> public static NetworkParameters params = TestNet3Params.get();
> public static final String APP_NAME = "WalletTemplate";
> private static final String WALLET_FILE_NAME =
> APP_NAME.replaceAll("[^a-zA-Z0-9.-]", "_") + "-"
> + params.getPaymentProtocolId();
> private WalletAppKit bitcoin;
>
>
> @PostConstruct
> public void startup() {
> self.startThread();
> }
>
> @Asynchronous
> public void startThread() {
> try {
> start();
> } catch (IOException ex) {
> Logger.getLogger(Demo.class.getName()).log(Level.SEVERE,
> null, ex);
> }
> }
>
> public void start() throws IOException {
>
> setupWalletKit(null);
>
> // when debugging gets to this line of code, the exception shows up
> bitcoin.addListener(new Service.Listener() {
> @Override
> public void running() {
> try {
> super.running();
> byte[] b = "17-01-2017 Mane, dobrodosao! vole te
> tata i mama. Gospodi pomiluj nas.".getBytes("UTF-8");
> // Create a tx with an OP_RETURN output
> Transaction tx = new Transaction(params);
> tx.addOutput(Coin.ZERO,
> ScriptBuilder.createOpReturnScript(b));
>
> System.out.println("before: " +
> bitcoin.wallet().getBalance().toString());
>
> // Send it to the Bitcoin network
> bitcoin.wallet().sendCoins(SendRequest.forTx(tx));
> } catch (UnsupportedEncodingException ex) {
>
> Logger.getLogger(Demo.class.getName()).log(Level.SEVERE, null, ex);
> } catch (InsufficientMoneyException ex) {
>
> Logger.getLogger(Demo.class.getName()).log(Level.SEVERE, null, ex);
> }
> }
> }, Runnable::run);
> bitcoin.addListener(new Service.Listener() {},
> OpReturnRunnable::runLater);
> bitcoin.startAsync();
> }
>
> public void setupWalletKit(DeterministicSeed seed) {
> bitcoin = new WalletAppKit(params, new File("."),
> WALLET_FILE_NAME) {
> @Override
> protected void onSetupCompleted() {
> // Don't make the user wait for confirmations for now,
> as the intention is they're sending it
> // their own money!
> bitcoin.wallet().allowSpendingUnconfirmedTransactions();
>
> }
> };
> }
> }
>
> Warning: Context path from ServletContext: differs from path from
> bundle: /
> Warning: A system exception occurred during an invocation on EJB Demo,
> method: public void apkt.opreturn.Demo.startThread()
> Warning: javax.ejb.EJBException
> at
> com.sun.ejb.containers.EJBContainerTransactionManager.processSystemException(EJBContainerTransactionManager.java:752)
> at
> com.sun.ejb.containers.EJBContainerTransactionManager.completeNewTx(EJBContainerTransactionManager.java:702)
> at
> com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:507)
> at
> com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4566)
> at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2074)
> at com.sun.ejb.containers.EjbAsyncTask.call(EjbAsyncTask.java:114)
> at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> at java.lang.Thread.run(Thread.java:745)
> Caused by: java.lang.IncompatibleClassChangeError: class
> apkt.opreturn.Demo$1 has interface
> com.google.common.util.concurrent.Service$Listener as super class
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
> at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
> at
> org.glassfish.web.loader.WebappClassLoader.findClass(WebappClassLoader.java:1220)
> at
> org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1750)
> at
> org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1633)
> at apkt.opreturn.Demo.write(Demo.java:80)
> at apkt.opreturn.Demo.startThread(Demo.java:62)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at
> org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081)
> at
> org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153)
> at
> com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4786)
> at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:656)
> at
> com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
> at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:608)
> at
> org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:73)
> at
> org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:52)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at
> com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
> at
> com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
> at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:608)
> at
> com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
> at
> com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:140)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at
> com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
> at
> com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
> at
> com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:369)
> at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4758)
> at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4746)
> at com.sun.ejb.containers.EjbAsyncTask.call(EjbAsyncTask.java:101)
>
> --
> You received this message because you are subscribed to the Google
> Groups "bitcoinj" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected]
> <mailto:[email protected]>.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"bitcoinj" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.