[Javassist] - Generating a main method
by Rafael Nagure
Rafael Nagure [http://community.jboss.org/people/nagure] created the discussion
"Generating a main method"
To view the discussion, visit: http://community.jboss.org/message/546375#546375
--------------------------------------------------------------
Hi there, folks. Sorry if this is a dumb question, but I couldn't find any good explanation so far.
I have the following code, a plain and simple *HelloWorld*:
ClassPool pool = ClassPool.getDefault();
CtClass cc = pool.makeClass("HelloWorld");
CtMethod mt = CtNewMethod.make("public static void main(String[] args) { System.out.println(\"Hello World!\"); }", cc);
cc.addMethod(mt);
cc.writeFile();
As you see, there's a main method in this new generated class. So far, so good. It works like a charm.
I'd like to create this very same method using the other way:
CtClass cc = pool.makeClass("HelloWorld");
CtMethod m = new CtMethod(CtClass.voidType, "main", new CtClass[] { } , cc);
m.setModifiers(Modifier.PUBLIC & Modifier.STATIC);
cc.addMethod(m);
m.setBody("{ System.out.println(\"Hello World!\"); }");
cc.setModifiers(cc.getModifiers() & ~Modifier.ABSTRACT);
cc.writeFile();
Unfortunately, this code fails. I couldn't figure out how I'm supposed to handle String args[] with CtClass.TYPE, as it seems there are only primitive types.
Thanks a lot!
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/546375#546375]
Start a new discussion in Javassist at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
15 years, 11 months
[JBoss Tools] - Error JBoss Tools
by Kamal Ddin Elouaaziza
Kamal Ddin Elouaaziza [http://community.jboss.org/people/elouaaziza] created the discussion
"Error JBoss Tools"
To view the discussion, visit: http://community.jboss.org/message/546366#546366
--------------------------------------------------------------
An internal error occurred during: "JBoss Tools Model Update".
java.lang.NullPointerException
at java.util.zip.ZipFile.getInputStream(Unknown Source)
at org.jboss.tools.common.model.filesystems.impl.JarAccess.getContent(JarAccess.java:200)
at org.jboss.tools.common.model.filesystems.impl.JarAccess.isTextEntry(JarAccess.java:235)
at org.jboss.tools.common.model.filesystems.impl.JarFolderImpl.createFileObject(JarFolderImpl.java:90)
at org.jboss.tools.common.model.filesystems.impl.JarFolderImpl.loadChildren(JarFolderImpl.java:74)
at org.jboss.tools.common.model.filesystems.impl.JarSystemImpl.loadChildren(JarSystemImpl.java:46)
at org.jboss.tools.common.model.impl.RegularObjectImpl.getChildByPathPart(RegularObjectImpl.java:140)
at org.jboss.tools.common.model.filesystems.impl.JarFolderImpl.getChildByPathPart(JarFolderImpl.java:131)
at org.jboss.tools.common.model.impl.XModelObjectImpl.getChildByPath(XModelObjectImpl.java:335)
at org.jboss.tools.jst.web.tld.TaglibMapping.findTldsInJar(TaglibMapping.java:224)
at org.jboss.tools.jst.web.tld.TaglibMapping.findTldsInJars(TaglibMapping.java:208)
at org.jboss.tools.jst.web.tld.TaglibMapping.revalidate(TaglibMapping.java:84)
at org.jboss.tools.jsf.web.JSFWatcherContributor.updateProject(JSFWatcherContributor.java:49)
at org.jboss.tools.common.model.project.Watcher.updateAll(Watcher.java:106)
at org.jboss.tools.common.model.project.Watcher.access$0(Watcher.java:89)
at org.jboss.tools.common.model.project.Watcher$WatcherRunnable.run(Watcher.java:47)
at org.jboss.tools.common.model.XJob.runInWorkspace(XJob.java:158)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
help me
thanks
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/546366#546366]
Start a new discussion in JBoss Tools at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
15 years, 11 months
[Beginner's Corner] - Problem starting jboss-5.1.0.GA from Eclipse
by sam maj
sam maj [http://community.jboss.org/people/smajmund] created the discussion
"Problem starting jboss-5.1.0.GA from Eclipse"
To view the discussion, visit: http://community.jboss.org/message/546359#546359
--------------------------------------------------------------
Just installed jboss-5.1.0.GA on XP Pro, it starts in command line but errs in Eclipse.
*Environment:*
JVM:1.6.0_20
Eclipse using: 1.6.0_20 (windows-preferences-java-installed JREs)
CLASSPATH=.;c:\dev\jboss\jboss-5.1.0.GA\bin\run.jar;C:\Program Files\Java\jre6\lib\javaws.jar;C:\Program Files\Java\jre6\lib\ext\QTJava.zip
I was successful in start/stop from command line using net start/stop JBAS50SVC
*A side question:*
once started from cmd line, localhost:8080 says: The requested resource (/dev_home.html) is not available
I was expecting welcome/something else for a freshly installed jboss root.
I am novice.
Thanks in advance!
Error:
08:54:48,109 INFO [ServerImpl] Starting JBoss (Microcontainer)...
08:54:48,109 INFO [ServerImpl] Release ID: JBoss [The Oracle] 5.1.0.GA (build: SVNTag=JBoss_5_1_0_GA date=200905221053)
08:54:48,109 INFO [ServerImpl] Bootstrap URL: null
08:54:48,109 INFO [ServerImpl] Home Dir: C:\dev\jboss\jboss-5.1.0.GA
08:54:48,109 INFO [ServerImpl] Home URL: file:/C:/dev/jboss/jboss-5.1.0.GA/
08:54:48,109 INFO [ServerImpl] Library URL: file:/C:/dev/jboss/jboss-5.1.0.GA/lib/
08:54:48,109 INFO [ServerImpl] Patch URL: null
08:54:48,109 INFO [ServerImpl] Common Base URL: file:/C:/dev/jboss/jboss-5.1.0.GA/common/
08:54:48,109 INFO [ServerImpl] Common Library URL: file:/C:/dev/jboss/jboss-5.1.0.GA/common/lib/
08:54:48,109 INFO [ServerImpl] Server Name: default
08:54:48,109 INFO [ServerImpl] Server Base Dir: C:\dev\jboss\jboss-5.1.0.GA\server
08:54:48,109 INFO [ServerImpl] Server Base URL: file:/C:/dev/jboss/jboss-5.1.0.GA/server/
08:54:48,109 INFO [ServerImpl] Server Config URL: file:/C:/dev/jboss/jboss-5.1.0.GA/server/default/conf/
08:54:48,109 INFO [ServerImpl] Server Home Dir: C:\dev\jboss\jboss-5.1.0.GA\server\default
08:54:48,109 INFO [ServerImpl] Server Home URL: file:/C:/dev/jboss/jboss-5.1.0.GA/server/default/
08:54:48,109 INFO [ServerImpl] Server Data Dir: C:\dev\jboss\jboss-5.1.0.GA\server\default\data
08:54:48,109 INFO [ServerImpl] Server Library URL: file:/C:/dev/jboss/jboss-5.1.0.GA/server/default/lib/
08:54:48,109 INFO [ServerImpl] Server Log Dir: C:\dev\jboss\jboss-5.1.0.GA\server\default\log
08:54:48,109 INFO [ServerImpl] Server Native Dir: C:\dev\jboss\jboss-5.1.0.GA\server\default\tmp\native
08:54:48,109 INFO [ServerImpl] Server Temp Dir: C:\dev\jboss\jboss-5.1.0.GA\server\default\tmp
08:54:48,109 INFO [ServerImpl] Server Temp Deploy Dir: C:\dev\jboss\jboss-5.1.0.GA\server\default\tmp\deploy
08:54:48,500 INFO [ServerImpl] Starting Microcontainer, bootstrapURL=file:/C:/dev/jboss/jboss-5.1.0.GA/server/default/conf/bootstrap.xml
08:54:48,906 INFO [VFSCacheFactory] Initializing VFSCache [org.jboss.virtual.plugins.cache.CombinedVFSCache]
08:54:48,906 INFO [VFSCacheFactory] Using VFSCache [CombinedVFSCache[real-cache: null]]
08:54:49,093 INFO [CopyMechanism] VFS temp dir: C:\dev\jboss\jboss-5.1.0.GA\server\default\tmp
08:54:49,093 INFO [ZipEntryContext] VFS force nested jars copy-mode is enabled.
08:54:49,671 INFO [ServerInfo] Java version: 1.6.0_20,Sun Microsystems Inc.
08:54:49,671 INFO [ServerInfo] Java Runtime: Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
08:54:49,671 INFO [ServerInfo] Java VM: Java HotSpot(TM) Client VM 16.3-b01,Sun Microsystems Inc.
08:54:49,671 INFO [ServerInfo] OS-System: Windows XP 5.1,x86
08:54:49,671 INFO [ServerInfo] VM arguments: -Dprogram.name=run.bat -Xms128m -Xmx512m -XX:MaxPermSize=256m -Dfile.encoding=Cp1252
08:54:49,687 INFO [JMXKernel] Legacy JMX core initialized
08:54:50,500 ERROR [AbstractKernelController] Error installing to Instantiated: name=AttachmentStore state=Described
java.lang.IllegalArgumentException: Wrong arguments. new for target java.lang.reflect.Constructor expected=[java.net.URI] actual=[java.io.File]
at org.jboss.reflect.plugins.introspection.ReflectionUtils.handleErrors(ReflectionUtils.java:395)
at org.jboss.reflect.plugins.introspection.ReflectionUtils.newInstance(ReflectionUtils.java:153)
at org.jboss.reflect.plugins.introspection.ReflectConstructorInfoImpl.newInstance(ReflectConstructorInfoImpl.java:106)
at org.jboss.joinpoint.plugins.BasicConstructorJoinPoint.dispatch(BasicConstructorJoinPoint.java:80)
at org.jboss.aop.microcontainer.integration.AOPConstructorJoinpoint.createTarget(AOPConstructorJoinpoint.java:282)
at org.jboss.aop.microcontainer.integration.AOPConstructorJoinpoint.dispatch(AOPConstructorJoinpoint.java:103)
at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241)
at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)
at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109)
at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70)
at org.jboss.kernel.plugins.dependency.InstantiateAction.installActionInternal(InstantiateAction.java:66)
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)
at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:774)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540)
at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBean(AbstractKernelDeployer.java:319)
at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBeans(AbstractKernelDeployer.java:297)
at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deploy(AbstractKernelDeployer.java:130)
at org.jboss.kernel.plugins.deployment.BasicKernelDeployer.deploy(BasicKernelDeployer.java:76)
at org.jboss.bootstrap.microcontainer.TempBasicXMLDeployer.deploy(TempBasicXMLDeployer.java:91)
at org.jboss.bootstrap.microcontainer.TempBasicXMLDeployer.deploy(TempBasicXMLDeployer.java:161)
at org.jboss.bootstrap.microcontainer.ServerImpl.doStart(ServerImpl.java:138)
at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:450)
at org.jboss.Main.boot(Main.java:221)
at org.jboss.Main$1.run(Main.java:556)
at java.lang.Thread.run(Thread.java:619)
Failed to boot JBoss:
java.lang.IllegalStateException: Incompletely deployed:
DEPLOYMENTS IN ERROR:
Deployment "AttachmentStore" is in error due to: java.lang.IllegalArgumentException: Wrong arguments. new for target java.lang.reflect.Constructor expected=[java.net.URI] actual=[java.io.File]
DEPLOYMENTS MISSING DEPENDENCIES:
Deployment "ProfileServiceDeployer" is missing the following dependencies:
Dependency "AttachmentStore" (should be in state "Installed", but is actually in state "**ERROR**")
Deployment "ProfileServicePersistenceDeployer" is missing the following dependencies:
Dependency "AttachmentStore" (should be in state "Installed", but is actually in state "**ERROR**")
Deployment "ProfileServiceBootstrap" is missing the following dependencies:
Dependency "jboss.kernel:service=Kernel" (should be in state "Installed", but is actually in state "**ERROR**")
Dependency "ProfileService" (should be in state "Installed", but is actually in state "Instantiated")
Deployment "ProfileService" is missing the following dependencies:
Dependency "ProfileServiceDeployer" (should be in state "Installed", but is actually in state "Instantiated")
Dependency "jboss.kernel:service=KernelController" (should be in state "Installed", but is actually in state "**ERROR**")
at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.internalValidate(AbstractKernelDeployer.java:278)
at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.validate(AbstractKernelDeployer.java:174)
at org.jboss.bootstrap.microcontainer.ServerImpl.doStart(ServerImpl.java:142)
at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:450)
at org.jboss.Main.boot(Main.java:221)
at org.jboss.Main$1.run(Main.java:556)
at java.lang.Thread.run(Thread.java:619)
08:54:50,875 INFO [ServerImpl] Runtime shutdown hook called, forceHalt: true
08:54:50,875 INFO [ServerImpl] Shutdown complete
Shutdown complete
Halting VM
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/546359#546359]
Start a new discussion in Beginner's Corner at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
15 years, 11 months
Re: [jboss-user] [JBoss AOP] - Eclipse/JBoss AOP standalone
by Flavia Rainone
Flavia Rainone [http://community.jboss.org/people/flavia.rainone%40jboss.com] replied to the discussion
"Eclipse/JBoss AOP standalone"
To view the discussion, visit: http://community.jboss.org/message/546358#546358
--------------------------------------------------------------
The error you are seeing means it is not liking the space in the path, and it is interpreting tha the path is only C:\Documents:
-javaagent:C:\Documents and Settings\PC\Bureau\JBossAOP\eclipse\jboss-aop-2.1.8.GA\lib\jboss-aop.jar-Djboss.aop.path=C:\Documents and Settings\PC\Mes documents\Downloads\travail\jboss\SINGLETONS\jboss-aop.xml
I would try adding " or ' to see if the problem is solved:
-javaagent:"C:\Documents and Settings\PC\Bureau\JBossAOP\eclipse\jboss-aop-2.1.8.GA\lib\jboss-aop.jar" -Djboss.aop.path="C:\Documents and Settings\PC\Mes documents\Downloads\travail\jboss\SINGLETONS\jboss-aop.xml"
or
-javaagent:'C:\Documents and Settings\PC\Bureau\JBossAOP\eclipse\jboss-aop-2.1.8.GA\lib\jboss-aop.jar' -Djboss.aop.path='C:\Documents and Settings\PC\Mes documents\Downloads\travail\jboss\SINGLETONS\jboss-aop.xml'
It's been ages since I stopped working on Windows, so I'm not sure which one of those would work. Another (lame) alternative is adding your stuff to a path that has no spaces in it.
You also need to add a space char before the -D, as I did above, otherwise it won't work.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/546358#546358]
Start a new discussion in JBoss AOP at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
15 years, 11 months